
    4jI                         S r SSKJr  SSKJrJr  SSKJr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 S\5      r\rg)zoThis module implements decorators for implementing other decorators
as well as some commonly used decorators.

    )partial)isclass	signature   )BaseObjectProxy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      O/root/lseg-credit/backend/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_varnames0   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$ )_AdapterFunctionSurrogate5   c                 8   > [         [        U ]  U5        X l        g r   )r   r5   r   _self_adapter)r   wrappedadapterr   s      r   r   "_AdapterFunctionSurrogate.__init__7   s     	'7@$r   c                 j    [        U R                  R                  U R                  R                  5      $ r   )r   __wrapped____code__r8   r   s    r   r>   "_AdapterFunctionSurrogate.__code__>   s,    #%%t'9'9'B'B
 	
r   c                 .    U R                   R                  $ r   )r8   __defaults__r   s    r   rA   &_AdapterFunctionSurrogate.__defaults__D   s    !!...r   c                 .    U R                   R                  $ r   )r8   __kwdefaults__r   s    r   rD   (_AdapterFunctionSurrogate.__kwdefaults__H   s    !!000r   c                 ,    [        U R                  5      $ r   )r   r8   r   s    r   __signature__'_AdapterFunctionSurrogate.__signature__L   s    ++,,r   )r8   )r,   r-   r.   r/   r   r0   r>   rA   rD   rG   r1   r2   r3   s   @r   r5   r5   5   sX    % 
 

 / / 1 1 - -r   r5   c                   4    \ rS rSr\S 5       r\S 5       rSrg)_BoundAdapterFunctionWrapperQ   c                 j    [        U R                  R                  U R                  R                  5      $ r   )r5   r=   __func___self_parentr8   r   s    r   rM   %_BoundAdapterFunctionWrapper.__func__S   s,    (%%t'8'8'F'F
 	
r   c                 @    [        U R                  R                  5      $ r   )r   rN   r8   r   s    r   rG   *_BoundAdapterFunctionWrapper.__signature__Y   s    **8899r    N)r,   r-   r.   r/   r0   rM   rG   r1   rR   r   r   rJ   rJ   Q   s(    
 

 : :r   rJ   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$ )_AdapterFunctionWrapper^   c                    > UR                  S5      n[        [        U ]  " U0 UD6  [	        U R
                  U5      U l        X0l        g )Nr:   )popr   rT   r   r5   r=   _self_surrogater8   )r   argskwargsr:   r   s       r   r    _AdapterFunctionWrapper.__init__b   sC    **Y' 	%t5tFvF89I9I7S$r   c                 .    U R                   R                  $ r   )rX   r>   r   s    r   r>    _AdapterFunctionWrapper.__code__k   s    ##,,,r   c                 .    U R                   R                  $ r   )rX   rA   r   s    r   rA   $_AdapterFunctionWrapper.__defaults__o   s    ##000r   c                 .    U R                   R                  $ r   )rX   rD   r   s    r   rD   &_AdapterFunctionWrapper.__kwdefaults__s   s    ##222r   c                 .    U R                   R                  $ r   )rX   rG   r   s    r   rG   %_AdapterFunctionWrapper.__signature__w   s    ##111r   )r8   rX   )r,   r-   r.   r/   rJ   __bound_function_wrapper__r   r0   r>   rA   rD   rG   r1   r2   r3   s   @r   rT   rT   ^   s^    !=% - - 1 1 3 3 2 2r   rT   c                       \ rS rSrS rSrg)AdapterFactory|   c                     [        5       er   )NotImplementedErrorr   r9   s     r   __call__AdapterFactory.__call__}   s    !##r   rR   N)r,   r-   r.   r/   rk   r1   rR   r   r   rf   rf   |   s    $r   rf   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   rn   r   factory)r   rq   r   s     r   r   !_DelegatedAdapterFactory.__init__   s    &68r   c                 $    U R                  U5      $ r   rq   rj   s     r   rk   !_DelegatedAdapterFactory.__call__   s    ||G$$r   rt   )r,   r-   r.   r/   r   rk   r1   r2   r3   s   @r   rn   rn      s    
% %r   rn   N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:   )r9   wrapperrw   r:   )r9   r}   rw   )	
isinstancerf   callablestrlenr   exec__annotations__rT   )r9   r}   rw   r:   nsannotationsrx   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      $ )NrR   )typebool)target_wrapped_enabledtarget_wrapperr   r:   rw   rZ   r9   s      r   _capture-decorator.<locals>._wrapper.<locals>._capture   sD      'HH~-'#11#' &-%6v%6N ".(GTTr   r   )r   r   r   __get__)r9   instancerY   rZ   r   r   r   r   r   r:   rw   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:   rv   )NN)	decoratorr   )r}   rw   r:   rx   r   r   s   ```` @r   r   r      sE    4 &	L^f	M f	M^ gx;; y'7%PPr   c                   @   ^  \ rS rSrSrSS.U 4S jjrS rS rSrU =r	$ )	_StateBindingWrapperi  a  A descriptor decorator that binds the owner instance to wrappers
produced by a wrapper factory method.

When applied on top of a method decorated with ``function_wrapper``
or ``decorator``, it intercepts the descriptor ``__get__`` so that
when the method is accessed through an instance, the owner instance
is automatically attached as an attribute on the resulting wrapper
via ``__self_setattr__``.

The *name* keyword argument controls the attribute name under which
the owner instance is stored on the wrapper (default ``"state"``).
state)namec                0   > [         TU ]  S 5        Xl        g r   )r   r   
_self_name)r   r   r   s     r   r   _StateBindingWrapper.__init__  s     	r   c                     Xl         U $ r   )r=   )r   wrapper_factorys     r   rk   _StateBindingWrapper.__call__  s     +r   c                 v   ^^^ Tc  U $ U R                   R                  TU5      mU R                  mUUU4S jnU$ )Nc                 <   > T" U 5      nUR                  TT5        U$ r   )__self_setattr__)funcr}   r   r   r   s     r   _bind+_StateBindingWrapper.__get__.<locals>._bind  s$    %d+G
 $$T84Nr   )r=   r   r   )r   r   ownerr   r   r   s    `  @@r   r   _StateBindingWrapper.__get__  s?    
 K
 **228UC	 r   )r=   r   )
r,   r-   r.   r/   __doc__r   rk   r   r1   r2   r3   s   @r   r   r     s&      '   r   r   r   )r   	functoolsr   inspectr   r   	__wrapt__r   r   r	   r
   	argumentsr   r   r5   rJ   rT   rf   rn   adapter_factoryr   r   bind_state_to_wrapperrR   r   r   <module>r      s   
  &  %3. 3<- 3 -8
:#7 
:2o 2<$ $
%~ % +DQ$O DQb7? 7t - r   