Your IP : 3.148.105.127


Current Path : /opt/alt/python38/lib64/python3.8/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/__pycache__/contextlib.cpython-38.opt-2.pyc

U

i�f�a�@sfddlZddlZddlZddlmZddlmZddlmZddddd	d
ddd
dddgZ	Gdd	�d	ej
�ZGdd
�d
ej
�ZGdd�de
�ZGdd�d�ZGdd�deee�ZGdd�dee�Zdd�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�ZGd d�de�ZGd!d�de�ZGd"d#�d#�ZGd$d
�d
ee�ZGd%d�dee�ZGd&d�de�ZdS)'�N)�deque��wraps��
MethodType�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/python38/lib64/python3.8/contextlib.py�	__enter__sz AbstractContextManager.__enter__cCsdSrr�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�classmethodr$rrrrrs

c@s.eZdZdd�Zejdd��Zedd��ZdS)rc�s|Srrrrrr�
__aenter__'sz&AbstractAsyncContextManager.__aenter__c�sdSrrrrrr�	__aexit__+sz%AbstractAsyncContextManager.__aexit__cCs|tkrt�|dd�StS)Nr+r,)rrrr r!rrrr$0s
�z,AbstractAsyncContextManager.__subclasshook__N)	r%r&r'r+r(r)r,r*r$rrrrr#s

c@seZdZdd�Zdd�ZdS)rcCs|Srrrrrr�_recreate_cm;s
zContextDecorator._recreate_cmcst����fdd��}|S)Nc
s*�����||�W5QR�SQRXdSr)r-��args�kwds��funcrrr�innerHs
z(ContextDecorator.__call__.<locals>.innerr)rr2r3rr1r�__call__GszContextDecorator.__call__N)r%r&r'r-r4rrrrr8sc@seZdZdd�ZdS)�_GeneratorContextManagerBasecCsJ|||�|_||||_|_|_t|dd�}|dkr@t|�j}||_dS)N�__doc__)�genr2r/r0�getattr�typer6)rr2r/r0�docrrr�__init__Rs
z%_GeneratorContextManagerBase.__init__N)r%r&r'r;rrrrr5Osr5c@s$eZdZdd�Zdd�Zdd�ZdS)�_GeneratorContextManagercCs|�|j|j|j�Sr)�	__class__r2r/r0rrrrr-fsz%_GeneratorContextManager._recreate_cmcCs<|`|`|`zt|j�WStk
r6td�d�YnXdS�Nzgenerator didn't yield)r/r0r2�nextr7�
StopIteration�RuntimeErrorrrrrrls
z"_GeneratorContextManager.__enter__c
Cs|dkr8zt|j�Wntk
r,YdSXtd��n�|dkrF|�}z|j�|||�Wn�tk
r�}z||k	WY�Sd}~XYnttk
r�}z4||kr�WY�&dS|tkr�|j|kr�WY�
dS�W5d}~XYn$t��d|kr�YdS�YnXtd��dS)NF�generator didn't stop�z#generator didn't stop after throw())r?r7r@rA�throw�	__cause__�sys�exc_info)rr9�valuer�excrrrrus.


z!_GeneratorContextManager.__exit__N)r%r&r'r-rrrrrrr<as	r<c@seZdZdd�Zdd�ZdS)�_AsyncGeneratorContextManagerc�s6z|j��IdHWStk
r0td�d�YnXdSr>)r7�	__anext__�StopAsyncIterationrArrrrr+�sz(_AsyncGeneratorContextManager.__aenter__c
�s&|dkr>z|j��IdHWntk
r2YdSXtd��n�|dkrL|�}z"|j�|||�IdHtd��Wn�tk
r�}z||k	WY�Sd}~XYn�tk
r�}z:||kr�WY�,dSt|ttf�r�|j|kr�WY�
dS�W5d}~XYn0tk
�r }z||k	�r�W5d}~XYnXdS)NrBz$generator didn't stop after athrow()F)	r7rKrLrA�athrow�
isinstancer@rE�
BaseException)r�typrHrrIrrrr,�s.




z'_AsyncGeneratorContextManager.__aexit__N)r%r&r'r+r,rrrrrJ�srJcst���fdd��}|S)Ncst�||�Sr)r<r.�r2rr�helper�szcontextmanager.<locals>.helperr�r2rRrrQrr�scst���fdd��}|S)Ncst�||�Sr)rJr.rQrrrRsz#asynccontextmanager.<locals>.helperrrSrrQrr�sc@s$eZdZdd�Zdd�Zdd�ZdS)r	cCs
||_dSr��thing)rrUrrrr;&szclosing.__init__cCs|jSrrTrrrrr(szclosing.__enter__cGs|j��dSr)rU�close)rrGrrrr*szclosing.__exit__N�r%r&r'r;rrrrrrr	sc@s(eZdZdZdd�Zdd�Zdd�ZdS)�_RedirectStreamNcCs||_g|_dSr)�_new_target�_old_targets)r�
new_targetrrrr;2sz_RedirectStream.__init__cCs*|j�tt|j��tt|j|j�|jSr)rZ�appendr8rF�_stream�setattrrYrrrrr7sz_RedirectStream.__enter__cCstt|j|j���dSr)r^rFr]rZ�pop�r�exctype�excinst�exctbrrrr<sz_RedirectStream.__exit__)r%r&r'r]r;rrrrrrrX.srXc@seZdZdZdS)r�stdoutN�r%r&r'r]rrrrr@s
c@seZdZdZdS)r�stderrNrerrrrrPsc@s$eZdZdd�Zdd�Zdd�ZdS)rcGs
||_dSr)�_exceptions)r�
exceptionsrrrr;aszsuppress.__init__cCsdSrrrrrrrdszsuppress.__enter__cCs|dk	ot||j�Sr)�
issubclassrgr`rrrrgs
zsuppress.__exit__NrWrrrrrVsc@sdeZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
de
_dd�Zddd�Z
dS)�_BaseExitStackcCs
t||�Srr��cm�cm_exitrrr�_create_exit_wrapperwsz#_BaseExitStack._create_exit_wrappercs���fdd�}|S)Ncs����dSrr�rrI�tb�r/�callbackr0rr�
_exit_wrapper}sz8_BaseExitStack._create_cb_wrapper.<locals>._exit_wrapperr�rrr/r0rsrrqr�_create_cb_wrapper{sz!_BaseExitStack._create_cb_wrappercCst�|_dSr)r�_exit_callbacksrrrrr;�sz_BaseExitStack.__init__cCst|��}|j|_t�|_|Sr)r9rvr)r�	new_stackrrr�pop_all�s
z_BaseExitStack.pop_allcCsBt|�}z
|j}Wntk
r0|�|�YnX|�||�|Sr)r9r�AttributeError�_push_exit_callback�
_push_cm_exit�r�exit�_cb_type�exit_methodrrr�push�s	
z_BaseExitStack.pushcCs(t|�}|j}|�|�}|�||�|Sr)r9rrr{�rrl�_cm_type�_exit�resultrrr�
enter_context�s

z_BaseExitStack.enter_contextcOs�t|�dkr|^}}}nV|s&td��nHd|krZ|�d�}|^}}ddl}|jdtdd�ntdt|�d��|j|f|�|�}||_|�|�|S)	N�zBdescriptor 'callback' of '_BaseExitStack' object needs an argumentrrr�4Passing 'callback' as keyword argument is deprecated��
stacklevelz8callback expected at least 1 positional argument, got %drC)	�len�	TypeErrorr_�warnings�warn�DeprecationWarningru�__wrapped__rz�r/r0rrrr�rsrrrrr�s&

�
�
z_BaseExitStack.callback�#($self, callback, /, *args, **kwds)cCs|�||�}|�|d�dS)NT)rnrz�rrlrmrsrrrr{�sz_BaseExitStack._push_cm_exitTcCs|j�||f�dSr)rvr\)rrr�is_syncrrrrz�sz"_BaseExitStack._push_exit_callbackN)T)r%r&r'�staticmethodrnrur;rxr�r�rr�__text_signature__r{rzrrrrrjts

rjc@s$eZdZdd�Zdd�Zdd�ZdS)rcCs|Srrrrrrr�szExitStack.__enter__c
s�|ddk	}t��d��fdd�}d}d}|jr�|j��\}}z||�rVd}d}d}Wq,t��}||d|d�d}|}Yq,Xq,|r�z|dj}	|d�Wn tk
r�|	|d_�YnX|o�|S)NrrCcs4|j}||krdS|dks*|�kr$q*|}q||_dSr��__context__��new_exc�old_exc�exc_context��	frame_excrr�_fix_exception_context�sz2ExitStack.__exit__.<locals>._fix_exception_contextFT�NNN�rFrGrvr_r�rO)
r�exc_details�received_excr��suppressed_exc�
pending_raiser��cb�new_exc_details�	fixed_ctxrr�rr�s2

zExitStack.__exit__cCs|�ddd�dSr)rrrrrrVszExitStack.closeN)r%r&r'rrrVrrrrr�s1c@sbeZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zde_	dd
�Z
dd�Zdd�Zdd�Z
dS)r
cCs
t||�Srrrkrrr�_create_async_exit_wrapper&sz)AsyncExitStack._create_async_exit_wrappercs���fdd�}|S)Nc�s����IdHdSrrrorqrrrs,sz>AsyncExitStack._create_async_cb_wrapper.<locals>._exit_wrapperrrtrrqr�_create_async_cb_wrapper*sz'AsyncExitStack._create_async_cb_wrapperc�s.t|�}|j}|�|�IdH}|�||�|Sr)r9r,r+�_push_async_cm_exitr�rrr�enter_async_context0s
z"AsyncExitStack.enter_async_contextcCsDt|�}z
|j}Wn tk
r2|�|d�YnX|�||�|S�NF)r9r,ryrzr�r|rrr�push_async_exit<s
zAsyncExitStack.push_async_exitcOs�t|�dkr|^}}}nV|s&td��nHd|krZ|�d�}|^}}ddl}|jdtdd�ntdt|�d��|j|f|�|�}||_|�|d	�|S)
Nr�zMdescriptor 'push_async_callback' of 'AsyncExitStack' object needs an argumentrrrr�r�zCpush_async_callback expected at least 1 positional argument, got %drCF)	r�r�r_r�r�r�r�r�rzr�rrr�push_async_callbackNs&

�
�z"AsyncExitStack.push_async_callbackr�c�s|�ddd�IdHdSr)r,rrrr�aclosekszAsyncExitStack.aclosecCs|�||�}|�|d�dSr�)r�rzr�rrrr�osz"AsyncExitStack._push_async_cm_exitc�s|Srrrrrrr+uszAsyncExitStack.__aenter__c�s�|ddk	}t��d��fdd�}d}d}|jr�|j��\}}z0|rP||�}n||�IdH}|rnd}d}d}Wq,t��}	||	d|d�d}|	}Yq,Xq,|r�z|dj}
|d�Wn tk
r�|
|d_�YnX|o�|S)NrrCcs4|j}||krdS|dks*|�kr$q*|}q||_dSrr�r�r�rrr�~sz8AsyncExitStack.__aexit__.<locals>._fix_exception_contextFTr�r�)rr�r�r�r�r�r�r��cb_suppressr�r�rr�rr,xs8


zAsyncExitStack.__aexit__N)r%r&r'r�r�r�r�r�r�r�r�r�r+r,rrrrr
s


c@s&eZdZddd�Zdd�Zdd�ZdS)	r
NcCs
||_dSr��enter_result)rr�rrrr;�sznullcontext.__init__cCs|jSrr�rrrrr�sznullcontext.__enter__cGsdSrr)r�excinforrrr�sznullcontext.__exit__)NrWrrrrr
�s
)r(rFr�collectionsr�	functoolsr�typesr�__all__�ABCrr�objectrr5r<rJrrr	rXrrrrjrr
r
rrrr�<module>sL��D�.!!`E

?>