
    vKga                         S SK r S SKrS SKJrJr  S SKJr  S SKJr  \R                  " \
5      r\" S/ SQ5      rS rSrSr " S	 S\5      rSS
 jr " S S5      r " S S\5      r " S S\5      r " S S5      rg)    N)deque
namedtuple)accepts_kwargs)EVENT_ALIASESNodeList)firstmiddlelast      c                       \ rS rSrS rSrg)r      c                     [         R                   " U R                  5      n[         R                   " U R                  5      n[         R                   " U R                  5      n[	        XU5      nU$ N)copyr   r	   r
   r   )self
first_copymiddle_copy	last_copycopieds        N/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/botocore/hooks.py__copy__NodeList.__copy__   sI    YYtzz*
ii,IIdii(	*9=     N)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r      s    r   c                 2    U  H  nUS   c  M  US   s  $    U$ )a  Find first non None response in a list of tuples.

This function can be used to find the first non None response from
handlers connected to an event.  This is useful if you are interested
in the returned responses from event handlers. Example usage::

    print(first_non_none_response([(func1, None), (func2, 'foo'),
                                   (func3, 'bar')]))
    # This will print 'foo'

:type responses: list of tuples
:param responses: The responses from the ``EventHooks.emit`` method.
    This is a list of tuples, and each tuple is
    (handler, handler_response).

:param default: If no non-None responses are found, then this default
    value will be returned.

:return: The first non-None response in the list of tuples.

r   r   )	responsesdefaultresponses      r   first_non_none_responser%   &   s)    , A;"A;  Nr   c                   `    \ rS rSrS r SS jr SS jr SS jrS r   SS jr	S	 r
S
 rSrg)BaseEventHooksB   c                     / $ )a  Call all handlers subscribed to an event.

:type event_name: str
:param event_name: The name of the event to emit.

:type **kwargs: dict
:param **kwargs: Arbitrary kwargs to pass through to the
    subscribed handlers.  The ``event_name`` will be injected
    into the kwargs so it's not necessary to add this to **kwargs.

:rtype: list of tuples
:return: A list of ``(handler_func, handler_func_return_value)``

r   r   
event_namekwargss      r   emitBaseEventHooks.emitC   s	     	r   Nc                 >    U R                  UUUU R                  US9  g)a  Register an event handler for a given event.

If a ``unique_id`` is given, the handler will not be registered
if a handler with the ``unique_id`` has already been registered.

Handlers are called in the order they have been registered.
Note handlers can also be registered with ``register_first()``
and ``register_last()``.  All handlers registered with
``register_first()`` are called before handlers registered
with ``register()`` which are called before handlers registered
with ``register_last()``.

register_methodunique_id_uses_countN)_verify_and_register	_registerr   r+   handler	unique_idr2   s        r   registerBaseEventHooks.registerT   s*      	!! NN!5 	" 	
r   c                 >    U R                  UUUU R                  US9  g)zRegister an event handler to be called first for an event.

All event handlers registered with ``register_first()`` will
be called before handlers registered with ``register()`` and
``register_last()``.

r0   N)r3   _register_firstr5   s        r   register_firstBaseEventHooks.register_firstl   s,     	!! 00!5 	" 	
r   c                 >    U R                  UUUU R                  US9  g)zRegister an event handler to be called last for an event.

All event handlers registered with ``register_last()`` will be called
after handlers registered with ``register_first()`` and ``register()``.

r0   N)r3   _register_lastr5   s        r   register_lastBaseEventHooks.register_last~   s,     	!! //!5 	" 	
r   c                 Z    U R                  U5        U R                  U5        U" XX55        g r   )_verify_is_callable_verify_accept_kwargs)r   r+   r6   r7   r1   r2   s         r   r3   #BaseEventHooks._verify_and_register   s*     	  )""7+
YMr   c                     g)zUnregister an event handler for a given event.

If no ``unique_id`` was given during registration, then the
first instance of the event handler is removed (if the event
handler has been registered multiple times).

Nr   r5   s        r   
unregisterBaseEventHooks.unregister   s     	r   c                 B    [        U5      (       d  [        SU S35      eg )NEvent handler z must be callable.)callable
ValueErrorr   funcs     r   rC   "BaseEventHooks._verify_is_callable   s%    ~~~dV3EFGG r   c                 d     [        U5      (       d  [        SU S35      eg! [         a     gf = f)zVerifies a callable accepts kwargs

:type func: callable
:param func: A callable object.

:returns: True, if ``func`` accepts kwargs, otherwise False.

rJ   z) must accept keyword arguments (**kwargs)FN)r   rL   	TypeErrorrM   s     r   rD   $BaseEventHooks._verify_accept_kwargs   sI    	!$'' $TF ++ ,  (
  		s   " 
//r   NFNNF)r   r   r   r   r-   r8   r<   r@   r3   rG   rC   rD   r    r   r   r   r'   r'   B   sL    $ IN
2 IN
& IN
"
N " Hr   r'   c                   p    \ rS rSrS rSS jrS rS r SS jr SS jr	 SS	 jr
S
 r   SS jrS rSrg)HierarchicalEmitter   c                 >    0 U l         [        5       U l        0 U l        g r   )_lookup_cache_PrefixTrie	_handlers_unique_id_handlersr   s    r   __init__HierarchicalEmitter.__init__   s      $ $& r   c                 J   / nU R                   R                  U5      nUc*  U R                  R                  U5      nXPR                   U'   O	U(       d  / $ XS'   / nU HC  n[        R                  SX5        U" S0 UD6nUR                  Xg45        U(       d  M<  Uc  MA  Us  $    U$ )a~  
Emit an event with optional keyword arguments.

:type event_name: string
:param event_name: Name of the event
:type kwargs: dict
:param kwargs: Arguments to be passed to the handler functions.
:type stop_on_response: boolean
:param stop_on_response: Whether to stop on the first non-None
                        response. If False, then all handlers
                        will be called. This is especially useful
                        to handlers which mutate data and then
                        want to stop propagation of the event.
:rtype: list
:return: List of (handler, response) tuples from all processed
         handlers.
r+   zEvent %s: calling handler %sr   )rY   getr[   prefix_searchloggerdebugappend)r   r+   r,   stop_on_responser"   handlers_to_callr6   r$   s           r   _emitHierarchicalEmitter._emit   s    $ 	  --11*=##~~;;JG-=z*! I)|	'GLL7M((Hg01H$8   ( r   c                 $    U R                  X5      $ )a  
Emit an event by name with arguments passed as keyword args.

    >>> responses = emitter.emit(
    ...     'my-event.service.operation', arg1='one', arg2='two')

:rtype: list
:return: List of (handler, response) tuples from all processed
         handlers.
rh   r*   s      r   r-   HierarchicalEmitter.emit   s     zz*--r   c                 <    U R                  XSS9nU(       a  US   $ g)a  
Emit an event by name with arguments passed as keyword args,
until the first non-``None`` response is received. This
method prevents subsequent handlers from being invoked.

    >>> handler, response = emitter.emit_until_response(
        'my-event.service.operation', arg1='one', arg2='two')

:rtype: tuple
:return: The first (handler, response) tuple where the response
         is not ``None``, otherwise (``None``, ``None``).
T)rf   )NNrk   )r   r+   r,   r"   s       r   emit_until_response'HierarchicalEmitter.emit_until_response  s&     JJzDJI	R= r   Nc                 2    U R                  UUUU[        S9  g Nsection)_register_section_MIDDLEr5   s        r   r4   HierarchicalEmitter._register  s&     	  	 	
r   c                 2    U R                  UUUU[        S9  g rr   )ru   _FIRSTr5   s        r   r;   #HierarchicalEmitter._register_first   s&     	  	 	
r   c                 .    U R                  XX4[        S9  g rr   )ru   _LASTr5   s        r   r?   "HierarchicalEmitter._register_last+  s     	% 	 	
r   c                    Ub  X0R                   ;   ao  U R                   U   R                  SS 5      nU(       a2  U(       d  [        SU S35      eU R                   U   S==   S-  ss'    g U(       a  [        SU S35      eg U R                  R	                  XUS9  SU0nU(       a  SUS'   XpR                   U'   OU R                  R	                  XUS9  0 U l        g )	Ncountz#Initial registration of  unique id zn was specified to use a counter. Subsequent register calls to unique id must specify use of a counter as well.r   "Initial registration of unique id zv was specified to not use a counter. Subsequent register calls to unique id must specify not to use a counter as well.rs   r6   )r\   ra   rL   r[   append_itemrY   )r   r+   r6   r7   r2   rt   r   unique_id_handler_items           r   ru   %HierarchicalEmitter._register_section2  s     444 00;??N' (A) M' '  00;GDID  (@ L5 5  
 ** +  +4W)=&'67*736L((3NN&&zG&L  r   c                    Ub   U R                   U   R                  SS 5      nU(       aR  Uc  [        SU S35      eUS:X  a  U R                   R	                  U5      S   nOOU R                   U   S==   S-  ss'   g U(       a  [        SU S35      eU R                   R	                  U5      S   n U R
                  R                  X5        0 U l        g ! [         a     g f = f! [         a     g f = f)Nr   r   zp was specified to use a counter. Subsequent unregister calls to unique id must specify use of a counter as well.r   r6   zx was specified to not use a counter. Subsequent unregister calls to unique id must specify not to use a counter as well.)r\   ra   KeyErrorrL   popr[   remove_itemrY   )r   r+   r6   r7   r2   r   s         r   rG   HierarchicalEmitter.unregister^  s%     00;??N
 $=$<YK HD D 
 aZ"66::9E!G ,,Y7@AE@$<YK H     2266yA)L	NN&&z;!#D;   <  		s#   C 2"C% 
C"!C"%
C21C2c                     U R                  5       nU R                  R                  5       n[        R                  " U R                  5      US'   [        R                  " U R                  5      US'   X!l        U$ )Nr[   r\   )	__class____dict__r   r[   r\   )r   new_instance	new_states      r   r   HierarchicalEmitter.__copy__  s]    ~~'MM&&(	!%4>>!:	++/99T5M5M+N	'( )r   )r[   rY   r\   )FrS   rT   )r   r   r   r   r^   rh   r-   ro   r4   r;   r?   ru   rG   r   r    r   r   r   rV   rV      sW    &&P. ( IN	
 IN	
 DI
* ^ ")Vr   rV   c                   p    \ rS rSrSS jrS rS r SS jr SS jr SS jr	   SS	 jr
S
 rS rS rSrg)EventAliaseri  Nc                 F    X l         Uc  [        U l         0 U l        Xl        g r   )_event_aliasesr   _alias_name_cache_emitter)r   event_emitterevent_aliasess      r   r^   EventAliaser.__init__  s#    + "/D!#%r   c                 ^    U R                  U5      nU R                  R                  " U40 UD6$ r   )_alias_event_namer   r-   r   r+   r,   aliased_event_names       r   r-   EventAliaser.emit  s.    !33J?}}!!"4???r   c                 ^    U R                  U5      nU R                  R                  " U40 UD6$ r   )r   r   ro   r   s       r   ro    EventAliaser.emit_until_response  s.    !33J?}}001CNvNNr   c                 \    U R                  U5      nU R                  R                  XRX45      $ r   )r   r   r8   r   r+   r6   r7   r2   r   s         r   r8   EventAliaser.register  s1     "33J?}}%%
 	
r   c                 \    U R                  U5      nU R                  R                  XRX45      $ r   )r   r   r<   r   s         r   r<   EventAliaser.register_first  s1     "33J?}}++
 	
r   c                 \    U R                  U5      nU R                  R                  XRX45      $ r   )r   r   r@   r   s         r   r@   EventAliaser.register_last  s1     "33J?}}**
 	
r   c                 \    U R                  U5      nU R                  R                  XRX45      $ r   )r   r   rG   r   s         r   rG   EventAliaser.unregister  s1     "33J?}}''
 	
r   c                    XR                   ;   a  U R                   U   $ U R                  R                  5        H  u  p#UR                  S5      nSU;  a   X4UR	                  U5      '   O+X!;   a$  UR                  S5      nU R                  XEU5        OM\  SR                  U5      n[        R                  SU SU 35        X`R                   U'   Us  $    XR                   U'   U$ ! [
         a     M  f = f)N.zChanging event name from z to )
r   r   itemssplitindexrL   _replace_subsectionjoinrc   rd   )r   r+   old_partnew_partevent_parts	old_partsnew_names          r   r   EventAliaser._alias_event_name  s   ///))*55"&"5"5";";"=H %**3/K(" @H 1 1( ;< '$NN3/	((Jxx,HLL+J<tH:F 2:"":.O9 #>< .8z*' " s   C%%
C32C3c                     [        [        U5      5       H7  nX   US   :X  d  M  XU[        U5      -    U:X  d  M&  U/XU[        U5      -   &   g    g )Nr   )rangelen)r   sectionsr   r   is        r   r    EventAliaser._replace_subsection  sQ    s8}%Ay|+S^!34	A4<:QY/0 &r   c                     U R                  [        R                  " U R                  5      [        R                  " U R                  5      5      $ r   )r   r   r   r   r]   s    r   r   EventAliaser.__copy__  s4    ~~IIdmm$dii0C0C&D
 	
r   )r   r   r   r   rS   rT   )r   r   r   r   r^   r-   ro   r8   r<   r@   rG   r   r   r   r    r   r   r   r   r     sW    &@O
 IN
 IN
 IN
 "

#J
r   r   c                   N    \ rS rSrSrS r\4S jrS rS r	S r
S rS	 rS
 rSrg)rZ   i  a6  Specialized prefix trie that handles wildcards.

The prefixes in this case are based on dot separated
names so 'foo.bar.baz' is::

    foo -> bar -> baz

Wildcard support just means that having a key such as 'foo.bar.*.baz' will
be matched with a call to ``get_items(key='foo.bar.ANYTHING.baz')``.

You can think of this prefix trie as the equivalent as defaultdict(list),
except that it can do prefix searches:

    foo.bar.baz -> A
    foo.bar -> B
    foo -> C

Calling ``get_items('foo.bar.baz')`` will return [A + B + C], from
most specific to least specific.

c                     S 0 S S.U l         g )N)chunkchildrenvalues_rootr]   s    r   r^   _PrefixTrie.__init__  s      $tD
r   c                     UR                  S5      nU R                  nU H$  nXeS   ;  a  US0 S.nXuS   U'   UnM  US   U   nM&     US   c  [        / / / 5      US'   US   U   R                  U5        g)zzAdd an item to a key.

If a value is already associated with that key, the new
value is appended to the list for the key.
r   r   N)r   r   r   r   )r   r   r   re   )r   keyvaluert   	key_partscurrentpart	new_childs           r   r   _PrefixTrie.append_item  s     IIcN	**D:..&*dK	,5
#D)#!*-d3  8$ (R 4GH'"))%0r   c                 z    [        5       nUR                  S5      nU R                  nU R                  XCUS5        U$ )zCollect all items that are prefixes of key.

Prefix in this case are delineated by '.' characters so
'foo.bar.baz' is a 3 chunk sequence of 3 "prefixes" (
"foo", "bar", and "baz").

r   r   )r   r   r   
_get_items)r   r   	collectedr   r   s        r   rb   _PrefixTrie.prefix_search,  s7     G	IIcN	**Iq9r   c                    X4/n[        U5      nU(       a  UR                  5       u  pxUS   (       aE  US   n	U	R                  U	R                  -   U	R                  -   n
UR                  [        U
5      5        X:X  dX  US   nUR                  X(   5      nUR                  S5      nUS-   nUb  UR                  X45        Ub  UR                  X45        U(       a  M  g g )Nr   r   *r   )	r   r   r   r	   r
   
extendleftreversedra   re   )r   starting_noder   r   starting_indexstackkey_parts_lencurrent_noder   	node_listcomplete_orderr   directswildcard
next_indexs                  r   r   _PrefixTrie._get_items:  s    01I
 "'))+LH% )2	OOi&6&66G  $$Xn%=>)'
3",,y'78#<<,"QY
'LL(!78&LL'!67/ er   c                 `    UR                  S5      nU R                  nU R                  XCUSS9  g)zRemove an item associated with a key.

If the value is not associated with the key a ``ValueError``
will be raised.  If the key does not exist in the trie, a
``ValueError`` will be raised.

r   r   )r   N)r   r   _remove_item)r   r   r   r   r   s        r   r   _PrefixTrie.remove_itemZ  s/     IIcN	**'e1=r   c                 .   Uc  g U[        U5      :  Ga  US   R                  X$   5      nUb  U R                  XRX4S-   5        U[        U5      S-
  :X  a  US   nX6R                  ;   a  UR                  R	                  U5        OUX6R
                  ;   a  UR
                  R	                  U5        O*X6R                  ;   a  UR                  R	                  U5        US   (       d  US   (       d	  US   X$   	 g g g [        SSR                  U5       35      eg )Nr   r   r   zkey is not in trie: r   )	r   ra   r   r   remover	   r
   rL   r   )r   r   r   r   r   	next_noder   s          r   r   _PrefixTrie._remove_itemf  s
   S^#$Z044Y5EFI$!!)qyIC	NQ.. )( 3I/!..u5"2"22!((//6..0!--e4 ,Yx5H
 %Z01AB 6I, !#78K7L!MNN' $r   c                 h    U R                  5       nU R                  U R                  5      nX!l        U$ r   )r   _recursive_copyr   )r   new_copycopied_attrss      r   r   _PrefixTrie.__copy__~  s/    
 >>#++DMM:(r   c                     0 nUR                  5        Hb  u  p4[        U[        5      (       a  [        R                  " U5      X#'   M4  [        U[        5      (       a  U R                  U5      X#'   M^  XBU'   Md     U$ r   )r   
isinstancer   r   dictr   )r   nodecopied_noder   r   s        r   r   _PrefixTrie._recursive_copy  si     **,JC%**#'99U#3 E4((#'#7#7#> #(C  ' r   r   N)r   r   r   r   __doc__r^   rv   r   rb   r   r   r   r   r   r    r   r   r   rZ   rZ     s7    ,E /6 1&8@
>O0r   rZ   r   )r   loggingcollectionsr   r   botocore.compatr   botocore.utilsr   	getLoggerr   rc   	_NodeListry   rv   r|   r   r%   r'   rV   r   rZ   r   r   r   <module>r      s      ) * (			8	$ z#>?		

	y 8} }@M. M`e
> e
PZ Zr   