Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/contextlib.cpython-37.opt-2.pyc

B

YI~d�`�@sZddlZddlZddlZddlmZddlmZdddddd	d
ddd
ddgZGdd�dej�Z	Gdd	�d	ej�Z
Gdd�de�ZGdd�d�Z
Gdd�de
e	e�ZGdd�de
e
�Zdd�Zdd�ZGdd�de	�ZGdd�de	�ZGdd
�d
e�ZGdd�de�ZGd d�de	�ZGd!d"�d"�ZGd#d�dee	�ZGd$d
�d
ee
�ZGd%d�de	�ZdS)&�N)�deque)�wraps�asynccontextmanager�contextmanager�closing�nullcontext�AbstractContextManager�AbstractAsyncContextManager�AsyncExitStack�ContextDecorator�	ExitStack�redirect_stdout�redirect_stderr�suppressc@s.eZdZdd�Zejdd��Zedd��ZdS)rcCs|S)N�)�selfrr�//opt/alt/python37/lib64/python3.7/contextlib.py�	__enter__sz AbstractContextManager.__enter__cCsdS)Nr)r�exc_type�	exc_value�	tracebackrrr�__exit__szAbstractContextManager.__exit__cCs|tkrt�|dd�StS)Nrr)r�_collections_abc�_check_methods�NotImplemented)�cls�Crrr�__subclasshook__sz'AbstractContextManager.__subclasshook__N)	�__name__�
__module__�__qualname__r�abc�abstractmethodr�classmethodrrrrrrsc@s.eZdZdd�Zejdd��Zedd��ZdS)r	c�s|S)Nr)rrrr�
__aenter__&sz&AbstractAsyncContextManager.__aenter__c�sdS)Nr)rrrrrrr�	__aexit__*sz%AbstractAsyncContextManager.__aexit__cCs|tkrt�|dd�StS)Nr$r%)r	rrr)rrrrrr/sz,AbstractAsyncContextManager.__subclasshook__N)	rrr r$r!r"r%r#rrrrrr	"sc@seZdZdd�Zdd�ZdS)rcCs|S)Nr)rrrr�_recreate_cm:s
zContextDecorator._recreate_cmcst����fdd��}|S)Nc	s�����||�SQRXdS)N)r&)�args�kwds)�funcrrr�innerGs
z(ContextDecorator.__call__.<locals>.inner)r)rr)r*r)r)rr�__call__FszContextDecorator.__call__N)rrr r&r+rrrrr7sc@seZdZdd�ZdS)�_GeneratorContextManagerBasecCsJ|||�|_||||_|_|_t|dd�}|dkr@t|�j}||_dS)N�__doc__)�genr)r'r(�getattr�typer-)rr)r'r(�docrrr�__init__Qs
z%_GeneratorContextManagerBase.__init__N)rrr r2rrrrr,Nsr,c@s$eZdZdd�Zdd�Zdd�ZdS)�_GeneratorContextManagercCs|�|j|j|j�S)N)�	__class__r)r'r()rrrrr&esz%_GeneratorContextManager._recreate_cmcCs:|`|`|`y
t|j�Stk
r4td�d�YnXdS)Nzgenerator didn't yield)r'r(r)�nextr.�
StopIteration�RuntimeError)rrrrrks

z"_GeneratorContextManager.__enter__c
Cs�|dkr6yt|j�Wntk
r*dSXtd��n�|dkrD|�}y|j�|||�Wn�tk
r~}z||k	Sd}~XYnftk
r�}z(||kr�dS|tkr�|j|kr�dS�Wdd}~XYn"t��d|kr�dS�YnXtd��dS)NFzgenerator didn't stop�z#generator didn't stop after throw())r5r.r6r7�throw�	__cause__�sys�exc_info)rr0�valuer�excrrrrts.
z!_GeneratorContextManager.__exit__N)rrr r&rrrrrrr3`s	r3c@seZdZdd�Zdd�ZdS)�_AsyncGeneratorContextManagerc�s4y|j��IdHStk
r.td�d�YnXdS)Nzgenerator didn't yield)r.�	__anext__�StopAsyncIterationr7)rrrrr$�sz(_AsyncGeneratorContextManager.__aenter__c
�s|dkr<y|j��IdHWntk
r0dSXtd��n�|dkrJ|�}y"|j�|||�IdHtd��Wn�tk
r�}z||k	Sd}~XYnztk
r�}z.||kr�dSt|ttf�r�|j|kr�dS�Wdd}~XYn0tk
�r
}z||k	�r��Wdd}~XYnXdS)Nzgenerator didn't stopz$generator didn't stop after athrow()F)	r.r@rAr7�athrow�
isinstancer6r:�
BaseException)r�typr=rr>rrrr%�s.


z'_AsyncGeneratorContextManager.__aexit__N)rrr r$r%rrrrr?�sr?cst���fdd��}|S)Ncst�||�S)N)r3)r'r()r)rr�helper�szcontextmanager.<locals>.helper)r)r)rFr)r)rr�scst���fdd��}|S)Ncst�||�S)N)r?)r'r()r)rrrFsz#asynccontextmanager.<locals>.helper)r)r)rFr)r)rr�sc@s$eZdZdd�Zdd�Zdd�ZdS)rcCs
||_dS)N)�thing)rrGrrrr2%szclosing.__init__cCs|jS)N)rG)rrrrr'szclosing.__enter__cGs|j��dS)N)rG�close)rr<rrrr)szclosing.__exit__N)rrr r2rrrrrrrsc@s(eZdZdZdd�Zdd�Zdd�ZdS)�_RedirectStreamNcCs||_g|_dS)N)�_new_target�_old_targets)r�
new_targetrrrr21sz_RedirectStream.__init__cCs*|j�tt|j��tt|j|j�|jS)N)rK�appendr/r;�_stream�setattrrJ)rrrrr6sz_RedirectStream.__enter__cCstt|j|j���dS)N)rOr;rNrK�pop)r�exctype�excinst�exctbrrrr;sz_RedirectStream.__exit__)rrr rNr2rrrrrrrI-srIc@seZdZdZdS)r
�stdoutN)rrr rNrrrrr
?s
c@seZdZdZdS)r�stderrN)rrr rNrrrrrOsc@s$eZdZdd�Zdd�Zdd�ZdS)rcGs
||_dS)N)�_exceptions)r�
exceptionsrrrr2`szsuppress.__init__cCsdS)Nr)rrrrrcszsuppress.__enter__cCs|dk	ot||j�S)N)�
issubclassrV)rrQrRrSrrrrfs
zsuppress.__exit__N)rrr r2rrrrrrrUsc@s^eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zddd�ZdS)�_BaseExitStackcs��fdd�}|S)Ncs��|||�S)Nr)rr>�tb)�cm�cm_exitrr�
_exit_wrapperxsz:_BaseExitStack._create_exit_wrapper.<locals>._exit_wrapperr)r[r\r]r)r[r\r�_create_exit_wrappervsz#_BaseExitStack._create_exit_wrappercs�^�����fdd�}|S)Ncs����dS)Nr)rr>rZ)r'�callbackr(rrr]sz8_BaseExitStack._create_cb_wrapper.<locals>._exit_wrapperr)r'r(r]r)r'r_r(r�_create_cb_wrapper|sz!_BaseExitStack._create_cb_wrappercCst�|_dS)N)r�_exit_callbacks)rrrrr2�sz_BaseExitStack.__init__cCst|��}|j|_t�|_|S)N)r0rar)r�	new_stackrrr�pop_all�s
z_BaseExitStack.pop_allcCsBt|�}y
|j}Wntk
r0|�|�YnX|�||�|S)N)r0r�AttributeError�_push_exit_callback�
_push_cm_exit)r�exit�_cb_type�exit_methodrrr�push�s	
z_BaseExitStack.pushcCs(t|�}|j}|�|�}|�||�|S)N)r0rrrf)rr[�_cm_type�_exit�resultrrr�
enter_context�s

z_BaseExitStack.enter_contextcOs|t|�dkr|^}}}n>|s&td��n0d|krB|�d�}|^}}ntdt|�d��|j|f|�|�}||_|�|�|S)N�zBdescriptor 'callback' of '_BaseExitStack' object needs an argumentr_z8callback expected at least 1 positional argument, got %dr8)�len�	TypeErrorrPr`�__wrapped__re)r'r(rr_r]rrrr_�s



z_BaseExitStack.callbackcCs"|�||�}||_|�|d�dS)NT)r^�__self__re)rr[r\r]rrrrf�sz_BaseExitStack._push_cm_exitTcCs|j�||f�dS)N)rarM)rr_�is_syncrrrre�sz"_BaseExitStack._push_exit_callbackN)T)
rrr �staticmethodr^r`r2rcrjrnr_rfrerrrrrYssrYc@s$eZdZdd�Zdd�Zdd�ZdS)rcCs|S)Nr)rrrrr�szExitStack.__enter__c
s�|ddk	}t��d��fdd�}d}d}x`|jr�|j��\}}y||�rXd}d}d}Wq.t��}||d|d�d}|}Yq.Xq.W|r�y|dj}	|d�Wn tk
r�|	|d_�YnX|o�|S)Nrr8cs8x,|j}||krdS|dks$|�kr&P|}qW||_dS)N)�__context__)�new_exc�old_exc�exc_context)�	frame_excrr�_fix_exception_context�sz2ExitStack.__exit__.<locals>._fix_exception_contextFT)NNN)r;r<rarPrvrD)
r�exc_details�received_excr{�suppressed_exc�
pending_raisert�cb�new_exc_details�	fixed_ctxr)rzrr�s2

zExitStack.__exit__cCs|�ddd�dS)N)r)rrrrrHszExitStack.closeN)rrr rrrHrrrrr�s1c@s\eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)r
cs��fdd�}|S)Nc�s��|||�IdHS)Nr)rr>rZ)r[r\rrr]'sz@AsyncExitStack._create_async_exit_wrapper.<locals>._exit_wrapperr)r[r\r]r)r[r\r�_create_async_exit_wrapper%sz)AsyncExitStack._create_async_exit_wrappercs�^�����fdd�}|S)Nc�s����IdHdS)Nr)rr>rZ)r'r_r(rrr].sz>AsyncExitStack._create_async_cb_wrapper.<locals>._exit_wrapperr)r'r(r]r)r'r_r(r�_create_async_cb_wrapper+sz'AsyncExitStack._create_async_cb_wrapperc�s.t|�}|j}|�|�IdH}|�||�|S)N)r0r%r$�_push_async_cm_exit)rr[rkrlrmrrr�enter_async_context2s
z"AsyncExitStack.enter_async_contextcCsDt|�}y
|j}Wn tk
r2|�|d�YnX|�||�|S)NF)r0r%rdrer�)rrgrhrirrr�push_async_exit>s
zAsyncExitStack.push_async_exitcOs~t|�dkr|^}}}n>|s&td��n0d|krB|�d�}|^}}ntdt|�d��|j|f|�|�}||_|�|d�|S)NrozMdescriptor 'push_async_callback' of 'AsyncExitStack' object needs an argumentr_zCpush_async_callback expected at least 1 positional argument, got %dr8F)rprqrPr�rrre)r'r(rr_r]rrr�push_async_callbackPs


z"AsyncExitStack.push_async_callbackc�s|�ddd�IdHdS)N)r%)rrrr�acloseiszAsyncExitStack.aclosecCs"|�||�}||_|�|d�dS)NF)r�rsre)rr[r\r]rrrr�msz"AsyncExitStack._push_async_cm_exitc�s|S)Nr)rrrrr$tszAsyncExitStack.__aenter__c�s�|ddk	}t��d��fdd�}d}d}xx|jr�|j��\}}y0|rR||�}n||�IdH}|rpd}d}d}Wq.t��}	||	d|d�d}|	}Yq.Xq.W|r�y|dj}
|d�Wn tk
r�|
|d_�YnX|o�|S)Nrr8cs8x,|j}||krdS|dks$|�kr&P|}qW||_dS)N)rv)rwrxry)rzrrr{}sz8AsyncExitStack.__aexit__.<locals>._fix_exception_contextFT)NNN)r;r<rarPrvrD)rr|r}r{r~rrtr��cb_suppressr�r�r)rzrr%ws8


zAsyncExitStack.__aexit__N)
rrr rur�r�r�r�r�r�r�r$r%rrrrr
s
c@s&eZdZddd�Zdd�Zdd�ZdS)	rNcCs
||_dS)N)�enter_result)rr�rrrr2�sznullcontext.__init__cCs|jS)N)r�)rrrrr�sznullcontext.__enter__cGsdS)Nr)r�excinforrrr�sznullcontext.__exit__)N)rrr r2rrrrrrr�s
)r!r;r�collectionsr�	functoolsr�__all__�ABCrr	�objectrr,r3r?rrrrIr
rrrYrr
rrrrr�<module>s:
B-!!`E

Hacked By AnonymousFox1.0, Coded By AnonymousFox