§
    ¼Ë”j¼K  ã                   ó&  — d Z ddlmZ ddlmZmZ ddlmZmZm	Z	m
Z
 ddlmZ  G d„ de	¦  «        Z G d	„ d
e	¦  «        Z G d„ de¦  «        Z G d„ de
¦  «        Z G d„ d¦  «        Z G d„ de¦  «        ZeZddde
dœd„Z G d„ de¦  «        ZeZdS )zoThis module implements decorators for implementing other decorators
as well as some commonly used decorators.

é    )Úpartial)ÚisclassÚ	signatureé   )ÚBaseObjectProxyÚBoundFunctionWrapperÚCallableObjectProxyÚFunctionWrapper)Úformatargspecc                   óŒ   ‡ — e Zd Zˆ fd„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	ˆ xZ
S )Ú_AdapterFunctionCodec                 óf   •— t          t          | ¦  «                             |¦  «         || _        d S ©N)Úsuperr   Ú__init__Ú_self_adapter_code)ÚselfÚwrapped_codeÚadapter_codeÚ	__class__s      €ú>C:\Projects\DSCons\.venv\Lib\site-packages\wrapt/decorators.pyr   z_AdapterFunctionCode.__init__   s2   ø€ õ 	Õ" DÑ)Ô)×2Ò2°<Ñ@Ô@Ð@Ø".ˆÔÐÐó    c                 ó   — | j         j        S r   )r   Úco_argcount©r   s    r   r   z _AdapterFunctionCode.co_argcount    ó   € àÔ&Ô2Ð2r   c                 ó   — | j         j        S r   )r   Úco_coder   s    r   r   z_AdapterFunctionCode.co_code$   s   € àÔ&Ô.Ð.r   c                 ó   — | j         j        S r   )r   Úco_flagsr   s    r   r    z_AdapterFunctionCode.co_flags(   s   € àÔ&Ô/Ð/r   c                 ó   — | j         j        S r   )r   Úco_kwonlyargcountr   s    r   r"   z&_AdapterFunctionCode.co_kwonlyargcount,   s   € àÔ&Ô8Ð8r   c                 ó   — | j         j        S r   )r   Úco_varnamesr   s    r   r$   z _AdapterFunctionCode.co_varnames0   r   r   )Ú__name__Ú
__module__Ú__qualname__r   Úpropertyr   r   r    r"   r$   Ú__classcell__©r   s   @r   r   r      s¿   ø€ € € € € ð/ð /ð /ð /ð /ð ð3ð 3ñ „Xð3ð ð/ð /ñ „Xð/ð ð0ð 0ñ „Xð0ð ð9ð 9ñ „Xð9ð ð3ð 3ñ „Xð3ð 3ð 3ð 3ð 3r   r   c                   óv   ‡ — e Zd Zˆ fd„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zˆ xZ	S )Ú_AdapterFunctionSurrogatec                 óf   •— t          t          | ¦  «                             |¦  «         || _        d S r   )r   r,   r   Ú_self_adapter)r   ÚwrappedÚadapterr   s      €r   r   z"_AdapterFunctionSurrogate.__init__7   s2   ø€ õ 	Õ'¨Ñ.Ô.×7Ò7¸Ñ@Ô@Ð@Ø$ˆÔÐÐr   c                 óJ   — t          | j        j        | j        j        ¦  «        S r   )r   Ú__wrapped__Ú__code__r.   r   s    r   r3   z"_AdapterFunctionSurrogate.__code__>   s%   € å#ØÔÔ% tÔ'9Ô'Bñ
ô 
ð 	
r   c                 ó   — | j         j        S r   )r.   Ú__defaults__r   s    r   r5   z&_AdapterFunctionSurrogate.__defaults__D   s   € àÔ!Ô.Ð.r   c                 ó   — | j         j        S r   )r.   Ú__kwdefaults__r   s    r   r7   z(_AdapterFunctionSurrogate.__kwdefaults__H   s   € àÔ!Ô0Ð0r   c                 ó*   — t          | j        ¦  «        S r   )r   r.   r   s    r   Ú__signature__z'_AdapterFunctionSurrogate.__signature__L   s   € å˜Ô+Ñ,Ô,Ð,r   )
r%   r&   r'   r   r(   r3   r5   r7   r9   r)   r*   s   @r   r,   r,   5   s¤   ø€ € € € € ð%ð %ð %ð %ð %ð ð
ð 
ñ „Xð
ð
 ð/ð /ñ „Xð/ð ð1ð 1ñ „Xð1ð ð-ð -ñ „Xð-ð -ð -ð -ð -r   r,   c                   ó:   — e Zd Zed„ ¦   «         Zed„ ¦   «         ZdS )Ú_BoundAdapterFunctionWrapperc                 óJ   — t          | j        j        | j        j        ¦  «        S r   )r,   r2   Ú__func__Ú_self_parentr.   r   s    r   r=   z%_BoundAdapterFunctionWrapper.__func__S   s%   € å(ØÔÔ% tÔ'8Ô'Fñ
ô 
ð 	
r   c                 ó4   — t          | j        j        ¦  «        S r   )r   r>   r.   r   s    r   r9   z*_BoundAdapterFunctionWrapper.__signature__Y   s   € å˜Ô*Ô8Ñ9Ô9Ð9r   N)r%   r&   r'   r(   r=   r9   © r   r   r;   r;   Q   sH   € € € € € àð
ð 
ñ „Xð
ð
 ð:ð :ñ „Xð:ð :ð :r   r;   c                   óz   ‡ — e Zd ZeZˆ fd„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	ed„ ¦   «         Z
ˆ xZS )Ú_AdapterFunctionWrapperc                 ó´   •— |                      d¦  «        } t          t          | ¦  «        j        |i |¤Ž t	          | j        |¦  «        | _        || _        d S )Nr0   )Úpopr   rB   r   r,   r2   Ú_self_surrogater.   )r   ÚargsÚkwargsr0   r   s       €r   r   z _AdapterFunctionWrapper.__init__b   s\   ø€ Ø—*’*˜YÑ'Ô'ˆð 	6�Õ% tÑ,Ô,Ô5°tÐF¸vÐFÐFÐFÝ8¸Ô9IÈ7ÑSÔSˆÔØ$ˆÔÐÐr   c                 ó   — | j         j        S r   )rE   r3   r   s    r   r3   z _AdapterFunctionWrapper.__code__k   s   € àÔ#Ô,Ð,r   c                 ó   — | j         j        S r   )rE   r5   r   s    r   r5   z$_AdapterFunctionWrapper.__defaults__o   s   € àÔ#Ô0Ð0r   c                 ó   — | j         j        S r   )rE   r7   r   s    r   r7   z&_AdapterFunctionWrapper.__kwdefaults__s   s   € àÔ#Ô2Ð2r   c                 ó   — | j         j        S r   )rE   r9   r   s    r   r9   z%_AdapterFunctionWrapper.__signature__w   s   € àÔ#Ô1Ð1r   )r%   r&   r'   r;   Ú__bound_function_wrapper__r   r(   r3   r5   r7   r9   r)   r*   s   @r   rB   rB   ^   sª   ø€ € € € € à!=Ðð%ð %ð %ð %ð %ð ð-ð -ñ „Xð-ð ð1ð 1ñ „Xð1ð ð3ð 3ñ „Xð3ð ð2ð 2ñ „Xð2ð 2ð 2ð 2ð 2r   rB   c                   ó   — e Zd Zd„ ZdS )ÚAdapterFactoryc                 ó   — t          ¦   «         ‚r   )ÚNotImplementedError©r   r/   s     r   Ú__call__zAdapterFactory.__call__}   s   € Ý!Ñ#Ô#Ð#r   N)r%   r&   r'   rR   r@   r   r   rN   rN   |   s#   € € € € € ð$ð $ð $ð $ð $r   rN   c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )Ú_DelegatedAdapterFactoryc                 ód   •— t          t          | ¦  «                             ¦   «          || _        d S r   )r   rT   r   Úfactory)r   rV   r   s     €r   r   z!_DelegatedAdapterFactory.__init__‚   s+   ø€ åÕ&¨Ñ-Ô-×6Ò6Ñ8Ô8Ð8ØˆŒˆˆr   c                 ó,   — |                       |¦  «        S r   )rV   rQ   s     r   rR   z!_DelegatedAdapterFactory.__call__‡   s   € Ø�|Š|˜GÑ$Ô$Ð$r   )r%   r&   r'   r   rR   r)   r*   s   @r   rT   rT   �   sG   ø€ € € € € ðð ð ð ð ð
%ð %ð %ð %ð %ð %ð %r   rT   N©Úenabledr0   Úproxyc               ó‚   ‡ ‡‡‡‡— ‰ �!dˆfd„	Šˆˆˆˆ fd„} ‰‰ |t           ¬¦  «        S t          t           ‰‰‰¬¦  «        S )aÓ  
    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.
    Nc                 ó‚  •— |r¯t          |t          ¦  «        r || ¦  «        }t          |¦  «        smi }i }t          |t          ¦  «        s.t	          |¦  «        dk    r|d         }|d d…         }t          |Ž }t          d|› d�||¦  «         |d         }|r||_        t          | |||¬¦  «        S  ‰| ||¬¦  «        S )Né   éÿÿÿÿzdef adapterz: passr0   )r/   ÚwrapperrY   r0   )r/   r_   rY   )	Ú
isinstancerN   ÚcallableÚstrÚlenr   ÚexecÚ__annotations__rB   )r/   r_   rY   r0   ÚnsÚannotationsrZ   s         €r   Ú_buildzdecorator.<locals>._build³   sý   ø€ Øð #Ý˜g¥~Ñ6Ô6ð /Ø%˜g gÑ.Ô.�Gå Ñ(Ô(ð >Ø�Bð #%�Kå% g­sÑ3Ô3ð :Ý˜w™<œ<¨1Ò,Ð,Ø*1°"¬+˜KØ&-¨c¨r¨c¤l˜GÝ"/°Ð"9˜åÐ6 wÐ6Ð6Ð6¸¸BÑ?Ô?Ð?Ø  œm�Gð #ð >Ø2=˜Ô/å.Ø#¨W¸gÈwðñ ô ð ð �5 °'À7ÐKÑKÔKÐKr   c                 ó|  •‡ ‡— |€t          ‰ ¦  «        r|sˆˆ	ˆ
ˆˆ fd„}|S |d         }‰
}t          |¦  «        t          u r|s|S d }|€t          ‰ ¦  «        r ‰ ¦   «         }nL‰}nIt          |¦  «        r‰                     d |¦  «        }n#‰                     |t          |¦  «        ¦  «        } ‰|||‰	¦  «        S )Nc                 ól   •— ‰}t          |¦  «        t          u r|s| S d } ‰di ‰¤Ž} ‰| ||‰¦  «        S )Nr@   )ÚtypeÚbool)Útarget_wrappedÚ_enabledÚtarget_wrapperrh   r0   rY   rG   r/   s      €€€€€r   Ú_capturez-decorator.<locals>._wrapper.<locals>._captureü   s]   ø€ ð  '�HÝ˜H‘~”~­Ð-Ð-Ø'ð 2Ø#1Ð1Ø#'˜ð &- WÐ%6Ð%6¨vÐ%6Ð%6�Nð "˜6 .°.À(ÈGÑTÔTÐTr   r   )r   rk   rl   Ú__get__)r/   ÚinstancerF   rG   rp   rm   rn   ro   rh   r0   rY   r_   s   `  `    €€€€r   Ú_wrapperzdecorator.<locals>._wrapperâ   s  øøø€ ð* Ð¥G¨GÑ$4Ô$4Ð¸TÐð
Uð Uð Uð Uð Uð Uð Uð Uð Uð2  �ð
 " !œWˆNð ˆHÝ�H‰~Œ~¥Ð%Ð%Øð *Ø)Ð)Ø�ð
 ÐÝ˜7Ñ#Ô#ð (-ð, &- W¡Y¤Y�N�Nð$ &-�N�Nõ ˜8Ñ$Ô$ð /Oð. &-§_¢_°T¸8Ñ%DÔ%D�N�Nð0 &-§_¢_°X½tÀH¹~¼~Ñ%NÔ%N�Nð �6˜.¨.¸(ÀGÑLÔLÐLr   )r0   rX   )NN)Ú	decoratorr   )r_   rY   r0   rZ   rs   rh   s   ```` @r   rt   rt   •   sŸ   øøøøø€ ð4 Ðð&	Lð &	Lð &	Lð &	Lð &	Lð &	Lð^f	Mð f	Mð f	Mð f	Mð f	Mð f	Mð f	Mð f	Mð^ ˆv�g˜xµÐ;Ñ;Ô;Ð;õ •y¨'¸7È%ÐPÑPÔPÐPr   c                   ó4   ‡ — e Zd ZdZddœˆ fd„
Zd„ Zd„ Zˆ xZS )Ú_StateBindingWrappera<  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                óX   •— t          ¦   «                              d ¦  «         || _        d S r   )r   r   Ú_self_attr_name)r   rx   r   s     €r   r   z_StateBindingWrapper.__init__´  s+   ø€ õ 	‰Œ×Ò˜ÑÔÐà#ˆÔÐÐr   c                 ó   — || _         | S r   )r2   )r   Úwrapper_factorys     r   rR   z_StateBindingWrapper.__call__¼  s   € ð +ˆÔàˆr   c                 óf   ‡‡‡— ‰€| S | j                              ‰|¦  «        Š| j        Šˆˆˆfd„}|S )Nc                 óJ   •—  ‰| ¦  «        }|                      ‰‰¦  «         |S r   )Ú__self_setattr__)Úfuncr_   rr   rx   r|   s     €€€r   Ú_bindz+_StateBindingWrapper.__get__.<locals>._bindÓ  s/   ø€ Ø%�o dÑ+Ô+ˆGð
 ×$Ò$ T¨8Ñ4Ô4Ð4àˆNr   )r2   rq   rz   )r   rr   Úownerr�   rx   r|   s    `  @@r   rq   z_StateBindingWrapper.__get__Ä  s^   øøø€ ð
 ÐØˆKð
 Ô*×2Ò2°8¸UÑCÔCˆàÔ#ˆð	ð 	ð 	ð 	ð 	ð 	ð 	ð ˆr   )r%   r&   r'   Ú__doc__r   rR   rq   r)   r*   s   @r   rv   rv   ¦  so   ø€ € € € € ðð ð  'ð $ð $ð $ð $ð $ð $ð $ðð ð ðð ð ð ð ð ð r   rv   r   )rƒ   Ú	functoolsr   Úinspectr   r   Ú	__wrapt__r   r   r	   r
   Ú	argumentsr   r   r,   r;   rB   rN   rT   Úadapter_factoryrt   rv   Úbind_state_to_wrapperr@   r   r   ú<module>rŠ      sù  ððð ð
 Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &ðð ð ð ð ð ð ð ð ð ð ð ð %Ð $Ð $Ð $Ð $Ð $ð3ð 3ð 3ð 3ð 3Ð.ñ 3ô 3ð 3ð<-ð -ð -ð -ð -Ð 3ñ -ô -ð -ð8
:ð 
:ð 
:ð 
:ð 
:Ð#7ñ 
:ô 
:ð 
:ð2ð 2ð 2ð 2ð 2˜oñ 2ô 2ð 2ð<$ð $ð $ð $ð $ñ $ô $ð $ð
%ð %ð %ð %ð %˜~ñ %ô %ð %ð +€ðDQ¨$¸ÀOð DQð DQð DQð DQð DQðb7ð 7ð 7ð 7ð 7˜?ñ 7ô 7ð 7ðt -Ð Ð Ð r   