Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/wrapt/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/wrapt/__pycache__/decorators.cpython-37.pyc

B

���X�N�@sLdZddlZejddkZejddkZerHefZddlZeed�Z	[ne
fZddd�Z	ddlmZdd	l
mZmZmZdd
lmZddlmZmZyddl
mZWnek
r�YnXd
dlmZmZmZmZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de!�Z"Gdd�de"�Z#e#Z$d dd�Z%dd�Z&dS)!zoThis module implements decorators for implementing other decorators
as well as some commonly used decorators.

�N���execcCsB|dkr*t�d�}|j}|dkr&|j}~n|dkr6|}td�dS)zExecute code in a namespace.N�zexec _code_ in _globs_, _locs_)�sys�	_getframe�	f_globals�f_localsr)Z_code_Z_globs_Z_locs_�frame�r�C/opt/alt/python37/lib64/python3.7/site-packages/wrapt/decorators.py�exec_s
r
)�partial)�ismethod�isclass�
formatargspec)�
namedtuple)�Lock�RLock)�	signaturer)�FunctionWrapper�BoundFunctionWrapper�ObjectProxy�CallableObjectProxycsXeZdZ�fdd�Zedd��Zedd��Zedd��Zed	d
��Zedd��Z	�Z
S)
�_AdapterFunctionCodecstt|��|�||_dS)N)�superr�__init__�_self_adapter_code)�selfZwrapped_codeZadapter_code)�	__class__rrr6sz_AdapterFunctionCode.__init__cCs|jjS)N)r�co_argcount)rrrrr :sz _AdapterFunctionCode.co_argcountcCs|jjS)N)r�co_code)rrrrr!>sz_AdapterFunctionCode.co_codecCs|jjS)N)r�co_flags)rrrrr"Bsz_AdapterFunctionCode.co_flagscCs|jjS)N)r�co_kwonlyargcount)rrrrr#Fsz&_AdapterFunctionCode.co_kwonlyargcountcCs|jjS)N)r�co_varnames)rrrrr$Jsz _AdapterFunctionCode.co_varnames)�__name__�
__module__�__qualname__r�propertyr r!r"r#r$�
__classcell__rr)rrr4srcsXeZdZ�fdd�Zedd��Zedd��Zedd��Zed	d
��Ze	rPeZ
eZ�ZS)�_AdapterFunctionSurrogatecstt|��|�||_dS)N)rr*r�
_self_adapter)r�wrapped�adapter)rrrrPsz"_AdapterFunctionSurrogate.__init__cCst|jj|jj�S)N)r�__wrapped__�__code__r+)rrrrr/Tsz"_AdapterFunctionSurrogate.__code__cCs|jjS)N)r+�__defaults__)rrrrr0Ysz&_AdapterFunctionSurrogate.__defaults__cCs|jjS)N)r+�__kwdefaults__)rrrrr1]sz(_AdapterFunctionSurrogate.__kwdefaults__cCs dt�kr|jjSt|j�SdS)Nr)�globalsr+�
__signature__r)rrrrr3as
z'_AdapterFunctionSurrogate.__signature__)
r%r&r'rr(r/r0r1r3�PY2�	func_code�
func_defaultsr)rr)rrr*Nsr*c@s eZdZedd��ZereZdS)�_BoundAdapterWrappercCst|jj|jj�S)N)r*r.�__func__Z_self_parentr+)rrrrr8ssz_BoundAdapterWrapper.__func__N)r%r&r'r(r8r4Zim_funcrrrrr7qsr7cs\eZdZeZ�fdd�Zedd��Zedd��Zedd��Z	e
rHeZeZed	d
��Z
�ZS)�AdapterWrappercs4|�d�}tt|�j||�t|j|�|_||_dS)Nr-)�poprr9rr*r.�_self_surrogater+)r�args�kwargsr-)rrrrs

zAdapterWrapper.__init__cCs|jjS)N)r;r/)rrrrr/�szAdapterWrapper.__code__cCs|jjS)N)r;r0)rrrrr0�szAdapterWrapper.__defaults__cCs|jjS)N)r;r1)rrrrr1�szAdapterWrapper.__kwdefaults__cCs|jjS)N)r;r3)rrrrr3�szAdapterWrapper.__signature__)r%r&r'r7Z__bound_function_wrapper__rr(r/r0r1r4r5r6r3r)rr)rrr9{sr9c@seZdZdd�ZdS)�AdapterFactorycCs
t��dS)N)�NotImplementedError)rr,rrr�__call__�szAdapterFactory.__call__N)r%r&r'r@rrrrr>�sr>cs$eZdZ�fdd�Zdd�Z�ZS)�DelegatedAdapterFactorycstt|���||_dS)N)rrAr�factory)rrB)rrrr�sz DelegatedAdapterFactory.__init__cCs
|�|�S)N)rB)rr,rrrr@�sz DelegatedAdapterFactory.__call__)r%r&r'rr@r)rr)rrrA�srAcs@�dk	r.ddd������fdd�}��|�Stt��d�SdS)NcSsl|r^t|t�r||�}t|�sNi}t|t�s4t|�}td�|�||�|d}t||||d�St|||d�S)Nzdef adapter{0}: passr-)r,�wrapper�enabledr-)r,rCrD)	�
isinstancer>�callable�string_typesrr
�formatr9r)r,rCrDr-�nsrrr�_build�s


zdecorator.<locals>._buildcs�|dkr,t��r,|s,�����fdd�}|S|d}�}t|�tkrP|sL|Sd}|dkrnt��rh��}q��}n&t|�r���d|�}n��|t|��}�|||��S)Ncs4�}t|�tkr|s|Sd}�f��}�|||��S)N)�type�bool)�target_wrapped�_enabled�target_wrapper)rJr-rDr=r,rr�_capture�s
z-decorator.<locals>._wrapper.<locals>._capturer)rrKrL�__get__)r,�instancer<r=rPrMrNrO)rJr-rDrC)r=r,r�_wrapper�s"zdecorator.<locals>._wrapper)rDr-)NN)r�	decorator)rCrDr-rSr)rJr-rDrCrrT�s
.
rTcszt|d�rFt|d�rF|�t�fdd��}G�fdd�dt�}||d�Sdd	���fd
d�}G�fdd
�d
t�}|||d�S)N�acquire�releasec	s��|||�SQRXdS)Nr)r,rRr<r=)�lockrr�
_synchronized�sz#synchronized.<locals>._synchronizedcs$eZdZ�fdd�Z�fdd�ZdS)z'synchronized.<locals>._PartialDecoratorcs����S)N)rU)r)rWrr�	__enter__�sz1synchronized.<locals>._PartialDecorator.__enter__cs���dS)N)rV)rr<)rWrr�__exit__�sz0synchronized.<locals>._PartialDecorator.__exit__N)r%r&r'rYrZr)rWrr�_PartialDecorator�sr[)r,c	Ssht|��dd�}|dkrdtt��dt��}|�0t|��dd�}|dkrZt�}t|d|�WdQRX|S)N�_synchronized_lockZ_synchronized_meta_lock)�vars�get�synchronized�
setdefaultrr�setattr)�contextrWZ	meta_lockrrrr\�s

z(synchronized.<locals>._synchronized_lockc	s"�|p|��|||�SQRXdS)Nr)r,rRr<r=)r\rr�_synchronized_wrapper�sz+synchronized.<locals>._synchronized_wrappercs eZdZ�fdd�Zdd�ZdS)z%synchronized.<locals>._FinalDecoratorcs�|j�|_|j��|jS)N)r.�
_self_lockrU)r)r\rrrY�s
z/synchronized.<locals>._FinalDecorator.__enter__cWs|j��dS)N)rdrV)rr<rrrrZ�sz.synchronized.<locals>._FinalDecorator.__exit__N)r%r&r'rYrZr)r\rr�_FinalDecorator�sre)r,rC)�hasattrrTrr)r,rXr[rcrer)r\rWrr_�s	
#
r_)NN)NNN)'�__doc__r�version_infor4ZPY3�strrG�builtins�getattrr
Z
basestring�	functoolsr�inspectrrr�collectionsr�	threadingrrr�ImportErrorZwrappersrrrrrr*r7r9�objectr>rAZadapter_factoryrTr_rrrr�<module>s:

	#
	
u