
    HAicR                        S r SSKrSSKJr  SSKJrJr  SSKJrJ	r	  SSK
JrJrJr  SSKJr   " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      r " S S5      r " S S\5      r\rSSS\S.S jjrS r\" 5       \l        g)zoThis module implements decorators for implementing other decorators
as well as some commonly used decorators.

    N)partial)isclass	signature)LockRLock   )BoundFunctionWrapperCallableObjectProxyFunctionWrapper)formatargspecc                   x   ^  \ rS rSrU 4S jr\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
SrU =r$ )	_AdapterFunctionCode   c                 8   > [         [        U ]  U5        X l        g N)superr   __init___self_adapter_code)selfwrapped_codeadapter_code	__class__s      L/var/www/html/land-ocr/venv/lib/python3.13/site-packages/wrapt/decorators.pyr   _AdapterFunctionCode.__init__   s    "D2<@".    c                 .    U R                   R                  $ r   )r   co_argcountr   s    r   r    _AdapterFunctionCode.co_argcount       &&222r   c                 .    U R                   R                  $ r   )r   co_coder   s    r   r"   _AdapterFunctionCode.co_code   s    &&...r   c                 .    U R                   R                  $ r   )r   co_flagsr   s    r   r%   _AdapterFunctionCode.co_flags"   s    &&///r   c                 .    U R                   R                  $ r   )r   co_kwonlyargcountr   s    r   r(   &_AdapterFunctionCode.co_kwonlyargcount&   s    &&888r   c                 .    U R                   R                  $ r   )r   co_varnamesr   s    r   r+    _AdapterFunctionCode.co_varnames*   r    r   )r   )__name__
__module____qualname____firstlineno__r   propertyr   r"   r%   r(   r+   __static_attributes____classcell__r   s   @r   r   r      sl    / 3 3 / / 0 0 9 9 3 3r   r   c                   h   ^  \ rS rSrU 4S jr\S 5       r\S 5       r\S 5       r\S 5       r	Sr
U =r$ )_AdapterFunctionSurrogate/   c                 8   > [         [        U ]  U5        X l        g r   )r   r6   r   _self_adapter)r   wrappedadapterr   s      r   r   "_AdapterFunctionSurrogate.__init__1   s    '7@$r   c                 j    [        U R                  R                  U R                  R                  5      $ r   )r   __wrapped____code__r9   r   s    r   r?   "_AdapterFunctionSurrogate.__code__5   s,    #%%t'9'9'B'B
 	
r   c                 .    U R                   R                  $ r   )r9   __defaults__r   s    r   rB   &_AdapterFunctionSurrogate.__defaults__;   s    !!...r   c                 .    U R                   R                  $ r   )r9   __kwdefaults__r   s    r   rE   (_AdapterFunctionSurrogate.__kwdefaults__?   s    !!000r   c                 t    S[        5       ;  a  U R                  R                  $ [        U R                  5      $ Nr   )globalsr9   __signature__r   r   s    r   rJ   '_AdapterFunctionSurrogate.__signature__C   s/    gi'%%333T//00r   )r9   )r-   r.   r/   r0   r   r1   r?   rB   rE   rJ   r2   r3   r4   s   @r   r6   r6   /   sX    % 
 

 / / 1 1 1 1r   r6   c                   4    \ rS rSr\S 5       r\S 5       rSrg)_BoundAdapterWrapperK   c                 j    [        U R                  R                  U R                  R                  5      $ r   )r6   r>   __func___self_parentr9   r   s    r   rP   _BoundAdapterWrapper.__func__M   s,    (%%t'8'8'F'F
 	
r   c                     S[        5       ;  a  U R                  R                  $ [        U R                  R
                  5      $ rH   )rI   r>   rJ   r   rQ   r9   r   s    r   rJ   "_BoundAdapterWrapper.__signature__S   s5    gi'##111T..<<==r    N)r-   r.   r/   r0   r1   rP   rJ   r2   rU   r   r   rM   rM   K   s(    
 

 > >r   rM   c                   l   ^  \ rS rSr\rU 4S jr\S 5       r\S 5       r	\S 5       r
\S 5       rSrU =r$ )AdapterWrapper[   c                    > UR                  S5      n[        [        U ]  " U0 UD6  [	        U R
                  U5      U l        X0l        g )Nr;   )popr   rW   r   r6   r>   _self_surrogater9   )r   argskwargsr;   r   s       r   r   AdapterWrapper.__init___   s@    **Y'nd,d=f=89I9I7S$r   c                 .    U R                   R                  $ r   )r[   r?   r   s    r   r?   AdapterWrapper.__code__e   s    ##,,,r   c                 .    U R                   R                  $ r   )r[   rB   r   s    r   rB   AdapterWrapper.__defaults__i   s    ##000r   c                 .    U R                   R                  $ r   )r[   rE   r   s    r   rE   AdapterWrapper.__kwdefaults__m   s    ##222r   c                 .    U R                   R                  $ r   )r[   rJ   r   s    r   rJ   AdapterWrapper.__signature__q   s    ##111r   )r9   r[   )r-   r.   r/   r0   rM   __bound_function_wrapper__r   r1   r?   rB   rE   rJ   r2   r3   r4   s   @r   rW   rW   [   s^    !5% - - 1 1 3 3 2 2r   rW   c                       \ rS rSrS rSrg)AdapterFactoryv   c                     [        5       er   )NotImplementedErrorr   r:   s     r   __call__AdapterFactory.__call__w   s    !##r   rU   N)r-   r.   r/   r0   rn   r2   rU   r   r   ri   ri   v   s    $r   ri   c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )DelegatedAdapterFactory{   c                 6   > [         [        U ]  5         Xl        g r   )r   rq   r   factory)r   rt   r   s     r   r    DelegatedAdapterFactory.__init__|   s    %t57r   c                 $    U R                  U5      $ r   rt   rm   s     r   rn    DelegatedAdapterFactory.__call__   s    ||G$$r   rw   )r-   r.   r/   r0   r   rn   r2   r3   r4   s   @r   rq   rq   {   s    % %r   rq   enabledr;   proxyc               l   ^ ^^^^ T b  SU4S jjmUUUU 4S jnT" T U[         S9$ [        [         TTTS9$ )aw  
The decorator should be supplied with a single positional argument
which is the `wrapper` function to be used to implement the
decorator. This may be preceded by a step whereby the keyword
arguments are supplied to customise the behaviour of the
decorator. The `adapter` argument is used to optionally denote a
separate function which is notionally used by an adapter
decorator. In that case parts of the function `__code__` and
`__defaults__` attributes are used from the adapter function
rather than those of the wrapped function. This allows for the
argument specification from `inspect.getfullargspec()` and similar
functions to be overridden with a prototype for a different
function than what was wrapped. The `enabled` argument provides a
way to enable/disable the use of the decorator. If the type of
`enabled` is a boolean, then it is evaluated immediately and the
wrapper not even applied if it is `False`. If not a boolean, it will
be evaluated when the wrapper is called for an unbound wrapper,
and when binding occurs for a bound wrapper. When being evaluated,
if `enabled` is callable it will be called to obtain the value to
be checked. If `False`, the wrapper will not be called and instead
the original wrapped function will be called directly instead.
The `proxy` argument provides a way of passing a custom version of
the `FunctionWrapper` class used in decorating the function.
c                 F  > U(       a  [        U[        5      (       a  U" U 5      n[        U5      (       d\  0 n0 n[        U[        5      (       d!  [	        U5      S:X  a
  US   nUS S n[        U6 n[        SU S3XD5        US   nU(       a  XSl        [        XX#S9$ T" XUS9$ )N   zdef adapterz: passr;   )r:   wrapperrz   r;   )r:   r   rz   )	
isinstanceri   callablestrlenr   exec__annotations__rW   )r:   r   rz   r;   nsannotationsr{   s         r   _builddecorator.<locals>._build   s    g~66%g.G((B #%K%gs33w<1,*1"+K&-crlG"/"9;wiv6? mG #2=/%#g  7KKr   c                 h  >^ ^ Uc#  [        T 5      (       a  U(       d  UU	U
UU 4S jnU$ US   nT
n[        U5      [        L a  U(       d  U$ S nUc  [        T 5      (       a  T " 5       nOATnO>[        U5      (       a  TR                  S U5      nOTR                  U[        U5      5      nT" XWUT	5      $ )Nc                 f   > Tn[        U5      [        L a  U(       d  U $ S nT" S0 TD6nT" XUT5      $ )NrU   )typebool)target_wrapped_enabledtarget_wrapperr   r;   rz   r]   r:   s      r   _capture-decorator.<locals>._wrapper.<locals>._capture   sD      'HH~-'#11#' &-%6v%6N ".(GTTr   r   )r   r   r   __get__)r:   instancer\   r]   r   r   r   r   r   r;   rz   r   s   `  `    r   _wrapperdecorator.<locals>._wrapper   s    * GG$4$4T
U U2  
 "!WN HH~%))
 7##, &-YN$ &-N 8$$. &-__T8%DN0 &-__XtH~%NN .(GLLr   )r;   ry   )NN)	decoratorr   )r   rz   r;   r{   r   r   s   ```` @r   r   r      sE    4 &	L^f	M f	M^ gx;; y'7%PPr   c                    ^^ [        U S5      (       a:  [        U S5      (       a)  U m[        U4S j5       n " U4S jS[        5      nU" US9$ S mU4S jn " U4S	 jS
[        5      nU" XS9$ )a  Depending on the nature of the `wrapped` object, will either return a
decorator which can be used to wrap a function or method, or a context
manager, both of which will act accordingly depending on how used, to
synchronize access to calling of the wrapped function, or the block of
code within the context manager. If it is an object which is a
synchronization primitive, such as a threading Lock, RLock, Semaphore,
Condition, or Event, then it is assumed that the object is to be used
directly as the synchronization primitive, otherwise a lock is created
automatically and attached to the wrapped object and used as the
synchronization primitive.
acquirereleasec                 N   > T   U " U0 UD6sS S S 5        $ ! , (       d  f       g = fr   rU   )r:   r   r\   r]   locks       r   _synchronized#synchronized.<locals>._synchronized  s    
 // s   
$c                   .   > \ rS rSrU 4S jrU 4S jrSrg)'synchronized.<locals>._PartialDecoratori  c                 (   > TR                  5         T$ r   )r   )r   r   s    r   	__enter__1synchronized.<locals>._PartialDecorator.__enter__  s    r   c                 &   > TR                  5         g r   )r   )r   r\   r   s     r   __exit__0synchronized.<locals>._PartialDecorator.__exit__  s    r   rU   Nr-   r.   r/   r0   r   r   r2   )r   s   r   _PartialDecoratorr     s     r   r   )r:   c                    [        U 5      R                  SS 5      nUcP  [        R                     [        U 5      R                  SS 5      nUc  [	        5       n[        U SU5        S S S 5        U$ U$ ! , (       d  f       U$ = f)N_synchronized_lock)varsgetsynchronized_synchronized_meta_lockr   setattr)contextr   s     r   r   (synchronized.<locals>._synchronized_lock  s}     G}  !5t<< 55 G}(()=tD< 7DG%94@ 6 t 65 s   6A11
B c                 d   > T" Ub  UOU 5         U " U0 UD6sS S S 5        $ ! , (       d  f       g = fr   rU   )r:   r   r\   r]   r   s       r   _synchronized_wrapper+synchronized.<locals>._synchronized_wrapper  s.    
  H,@gND+F+ ONNs   !
/c                   (   > \ rS rSrU 4S jrS rSrg)%synchronized.<locals>._FinalDecoratori  c                 ~   > T" U R                   5      U l        U R                  R                  5         U R                  $ r   )r>   
_self_lockr   )r   r   s    r   r   /synchronized.<locals>._FinalDecorator.__enter__  s/    01A1ABDOOO##%??"r   c                 8    U R                   R                  5         g r   )r   r   )r   r\   s     r   r   .synchronized.<locals>._FinalDecorator.__exit__  s    OO##%r   )r   Nr   )r   s   r   _FinalDecoratorr     s    	#
	&r   r   )r:   r   )hasattrr   r
   r   )r:   r   r   r   r   r   r   s        @@r   r   r     su    & w	""ww	'B'B 		0 
	0	 3 	 !77@,&/ & 7JJr   r   )__doc__sys	functoolsr   inspectr   r   	threadingr   r   	__wrapt__r	   r
   r   	argumentsr   r   r6   rM   rW   ri   rq   adapter_factoryr   r   r   rU   r   r   <module>r      s   
   & ! Q Q $3. 361 3 18>/ > 2_ 26$ $
%n % *DQ$O DQdgKT (,v $r   