
    -2iM'                       U d dl mZ dZd dlZd dlZd dlmZ d dlmZm	Z	m
Z
mZmZmZ d dlmZ d dlmZ d dlmZmZmZmZmZmZmZmZ d d	lmZ d
dlmZ d
dlmZm Z  ej!        dk    rd dlm"Z" nd dl#m"Z"  ed          Z$ ed          Z% e"d          Z& ed          Z'de(d<    G d d          Z) e)            Z*de(d<    G d de          Z+ G d de          Z,e G d dee&e$f                               Z- G d dee$                   Z.edGd#            Z/edHd&            Z/dId)Z/ed*d*d*d+dJd2            Z0edGd3            Z0edHd4            Z0	 dKd5d6d6d+dLd9Z0edMd?            Z1edNdB            Z1e*fdOdFZ1dS )P    )annotations)AsyncCacheInfoAsyncCacheParametersAsyncLRUCacheWrappercache	lru_cachereduceN)OrderedDict)AsyncIterable	AwaitableCallable	CoroutineHashableIterable)update_wrapper)iscoroutinefunction)AnyGeneric
NamedTuple	TypedDictTypeVarcastfinaloverload)WeakKeyDictionary   )Lock)RunVar
checkpoint)      )	ParamSpecTSPlru_cache_itemszRunVar[WeakKeyDictionary[AsyncLRUCacheWrapper[Any, Any], OrderedDict[Hashable, tuple[_InitialMissingType, Lock] | tuple[Any, None]]]]c                      e Zd ZdS )_InitialMissingTypeN)__name__
__module____qualname__     N/var/www/html/pixcura-vrs/venv/lib/python3.11/site-packages/anyio/functools.pyr(   r(   8   s        Dr-   r(   initial_missingc                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )r   inthitsmisses
int | NonemaxsizecurrsizeNr)   r*   r+   __annotations__r,   r-   r.   r   r   ?   s7         IIIKKKMMMMMr-   r   c                  .    e Zd ZU ded<   ded<   ded<   dS )r   r4   r5   booltypedalways_checkpointNr7   r,   r-   r.   r   r   F   s3         KKKr-   r   c                  6    e Zd ZddZddZddZddZddZdS )r   funcCallable[..., Awaitable[T]]r5   r4   r;   r:   r<   c                    || _         d| _        d| _        |t          |d          nd | _        d| _        || _        || _        t          | |           d S Nr   )	__wrapped___hits_missesmax_maxsize	_currsize_typed_always_checkpointr   )selfr>   r5   r;   r<   s        r.   __init__zAsyncLRUCacheWrapper.__init__N   s^      
+2+>GQD"3tT"""""r-   returnr   c                N    t          | j        | j        | j        | j                  S N)r   rC   rD   rF   rG   rJ   s    r.   
cache_infozAsyncLRUCacheWrapper.cache_info^   s    dj$,t~VVVr-   r   c                ,    | j         | j        | j        dS )Nr5   r;   r<   rF   rH   rI   rO   s    r.   cache_parametersz%AsyncLRUCacheWrapper.cache_parametersa   s!    }[!%!8
 
 	
r-   Nonec                    t                               d           x}r-|                    | d            dx| _        x| _        | _        d S d S rA   )r&   getpoprC   rD   rG   )rJ   r   s     r.   cache_clearz AsyncLRUCacheWrapper.cache_clearh   sT    #''---5 	;IIdD!!!9::DJ:	; 	;r-   argsP.argskwargsP.kwargsr#   c                  K   | j         dk    r% | j        |i | d {V }| xj        dz  c_        |S |}|r.|t          ft	          |                                d          z   z  }| j        rU|t          d |D                       z  }|r7|t          ft          d |                                D                       z   z  }	 t          
                                }n8# t          $ r+ t                      }t                              |           Y nw xY w	 ||          }n## t          $ r t                      x}|| <   Y nw xY w	 ||         \  }}n4# t          $ r' t          t!          | j                   }}||f||<   Y nw xY w|U| xj        dz  c_        |                    |           | j        rt)                       d {V  t+          t,          |          S |4 d {V  ||         d         x}t          u ri| xj        dz  c_        | j         '| j        | j         k    r|                    d           n| xj        dz  c_         | j        |i | d {V }|d f||<   n:| xj        dz  c_        |                    |           t+          t,          |          }	 d d d           d {V  n# 1 d {V swxY w Y   |S )	Nr   r   r,   c              3  4   K   | ]}t          |          V  d S rN   type).0args     r.   	<genexpr>z0AsyncLRUCacheWrapper.__call__.<locals>.<genexpr>{   s(      33sc333333r-   c              3  4   K   | ]}t          |          V  d S rN   r`   )rb   vals     r.   rd   z0AsyncLRUCacheWrapper.__call__.<locals>.<genexpr>}   s(      1W1W$s))1W1W1W1W1W1Wr-   )fast_acquireF)last)rF   rB   rD   r/   sumitemsrH   tuplevaluesr&   rW   LookupErrorr   setKeyErrorr
   r   rI   rC   move_to_endr   r   r#   rG   popitem)	rJ   rZ   r\   valuekeyr   cache_entrycached_valuelocks	            r.   __call__zAsyncLRUCacheWrapper.__call__m   s     =A*$*D;F;;;;;;;;ELLALLL  $ 	@O%FLLNNB(?(???C; 	X533d333333C X)E1W1Wv}}1W1W1W,W,WWW	'#''))EE 	' 	' 	'%''E&&&&&	'	6+KK 	6 	6 	6(35K%+++	6	2!,S!1L$$ 	2 	2 	2  d&="=>>> L  ,T1K	2 <JJ!OJJ##C(((& # ll"""""""<((( 	. 	. 	. 	. 	. 	. 	. 	. +C 0 33GG!=,4=1P1P''U'3333NNa'NN.d.?????????#($;C   

a

'',,,Q---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	." sI   C 2DDD D>=D>E .E?>E?!B;J//
J9<J9N)r>   r?   r5   r4   r;   r:   r<   r:   )rL   r   )rL   r   )rL   rU   )rZ   r[   r\   r]   rL   r#   )r)   r*   r+   rK   rP   rT   rY   rw   r,   r-   r.   r   r   L   s        # # # # W W W W
 
 
 
; ; ; ;
B B B B B Br-   r   c                  N    e Zd ZddZedd            Zedd            ZddZdS )_LRUCacheWrapperr5   r4   r;   r:   r<   c                0    || _         || _        || _        d S rN   rS   )rJ   r5   r;   r<   s       r.   rK   z_LRUCacheWrapper.__init__   s    "3r-   r>   #Callable[P, Coroutine[Any, Any, T]]rL   AsyncLRUCacheWrapper[P, T]c                   d S rN   r,   rJ   r>   s     r.   rw   z_LRUCacheWrapper.__call__   s	     &)Sr-   Callable[..., T]functools._lru_cache_wrapper[T]c                   d S rN   r,   r~   s     r.   rw   z_LRUCacheWrapper.__call__   s	     +.#r-   f6Callable[P, Coroutine[Any, Any, T]] | Callable[..., T]<AsyncLRUCacheWrapper[P, T] | functools._lru_cache_wrapper[T]c                   t          |          r!t          || j        | j        | j                  S  t          j        | j        | j                  |          S )N)r5   r;   )r   r   rF   rH   rI   	functoolsr   )rJ   r   s     r.   rw   z_LRUCacheWrapper.__call__   s]     q!! 	'4=$+t/F   My"4=LLLQOOOr-   N)r5   r4   r;   r:   r<   r:   r>   r{   rL   r|   r>   r   rL   r   )r   r   rL   r   )r)   r*   r+   rK   r   rw   r,   r-   r.   ry   ry      s        4 4 4 4
 ) ) ) X) . . . X.P P P P P Pr-   ry   r>   r{   rL   r|   c                   d S rN   r,   r>   s    r.   r   r      	     "%r-   r   r   c                   d S rN   r,   r   s    r.   r   r      s    ILr-   6Callable[..., T] | Callable[P, Coroutine[Any, Any, T]]r   c               4     t          d          |           S )z
    A convenient shortcut for :func:`lru_cache` with ``maxsize=None``.

    This is the asynchronous equivalent to :func:`functools.cache`.

    N)r5   )r   r   s    r.   r   r      s     #9T"""4(((r-   .rR   r5   r4   r;   r:   r<   _LRUCacheWrapper[Any]c                    d S rN   r,   rR   s      r.   r   r      s	      Cr-   c                   d S rN   r,   r   s    r.   r   r      r   r-   c                   d S rN   r,   r   s    r.   r   r      s    MPSr-      F=Callable[P, Coroutine[Any, Any, T]] | Callable[..., T] | NoneTAsyncLRUCacheWrapper[P, T] | functools._lru_cache_wrapper[T] | _LRUCacheWrapper[Any]c                  | t          t                   |||          S t          |           st          d           t          t                   |||          |           S )a  
    An asynchronous version of :func:`functools.lru_cache`.

    If a synchronous function is passed, the standard library
    :func:`functools.lru_cache` is applied instead.

    :param always_checkpoint: if ``True``, every call to the cached function will be
        guaranteed to yield control to the event loop at least once

    .. note:: Caches and locks are managed on a per-event loop basis.

    Nz#the first argument must be callable)ry   r   callable	TypeErrorr#   )r>   r5   r;   r<   s       r.   r   r      sa    , |$We5FGGGD>> ?=>>>AAw/@AA$GGGr-   initialfunctionCallable[[T, S], Awaitable[T]]iterableIterable[S] | AsyncIterable[S]c               
   K   d S rN   r,   )r   r   r   s      r.   r	   r	     s       	r-   Callable[[T, T], Awaitable[T]]Iterable[T] | AsyncIterable[T]c               
   K   d S rN   r,   )r   r   s     r.   r	   r	     s      
 	r-   T | _InitialMissingType?Callable[[T, T], Awaitable[T]] | Callable[[T, S], Awaitable[T]]?Iterable[T] | Iterable[S] | AsyncIterable[T] | AsyncIterable[S]c                 K   d}t          |t                    r|                                }|t          u rM	 t	          t
          |                                 d{V           }n3# t          $ r t          d          dw xY wt	          t
          |          }|2 3 d{V } | ||           d{V }d}6 nt          |t                    rt          |          }|t          u rB	 t	          t
          t          |                    }n3# t          $ r t          d          dw xY wt	          t
          |          }|D ]} | ||           d{V }d}nt          d          |st                       d{V  |S )at  
    Asynchronous version of :func:`functools.reduce`.

    :param function: a coroutine function that takes two arguments: the accumulated
        value and the next element from the iterable
    :param iterable: an iterable or async iterable
    :param initial: the initial value (if missing, the first element of the iterable is
        used as the initial value)

    FNz0reduce() of empty sequence with no initial valueTz9reduce() argument 2 must be an iterable or async iterable)
isinstancer   	__aiter__r/   r   r#   	__anext__StopAsyncIterationr   r   iternextStopIterationr   )r   r   r   function_calledasync_itrr   elementits           r.   r	   r	   #  s     " O(M** U%%''o%%Qh&8&8&:&: : : : : : :;;%   F 
 G$$E% 	# 	# 	# 	# 	# 	# 	#'"(5'22222222E"OO &X 
Hh	'	' U(^^o%%QR))    F 
 G$$E 	# 	#G"(5'22222222E"OO	# STTT  llLs   -A& &BB7'"D
 
D%r   r   )r>   r   rL   r   )r5   r4   r;   r:   r<   r:   rL   r   rN   )
r>   r   r5   r4   r;   r:   r<   r:   rL   r   )r   r#   r   r   r   r   rL   r#   )r   r   r   r   rL   r#   )r   r   r   r   r   r   rL   r#   )2
__future__r   __all__r   syscollectionsr
   collections.abcr   r   r   r   r   r   r   inspectr   typingr   r   r   r   r   r   r   r   weakrefr   _core._synchronizationr   lowlevelr   r   version_infor"   typing_extensionsr#   r$   r%   r&   r8   r(   r/   r   r   r   ry   r   r   r	   r,   r-   r.   <module>r      sU   " " " " " " "     



 # # # # # #                % $ $ $ $ $ ' ' ' ' ' '	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 & % % % % % ( ( ( ( ( ( ( ( ( ( ( ( ( (w       ++++++GCLLGCLLIcNN F     	 	 	 	 	 	 	 	 (;':'<'< < < < <    Z       9    b b b b b71a4= b b bJP P P P Pwqz P P P6 
% % % 
%
 
 L L L 
 L	) 	) 	) 	) 
 s          
 
 
% % % 
%
 
 P P P 
 P KOH #H H H H H H> 
   
 
   
 (7	8 8 8 8 8 8 8r-   