Your IP : 18.119.135.231


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/contextlib.cpython-39.opt-2.pyc

a

R�f0`�@sVddlZddlZddlZddlmZddlmZddlmZm	Z	gd�Z
Gdd�dej�ZGdd	�d	ej�Z
Gd
d�de�ZGdd
�d
�ZGdd�deee�ZGdd�dee
�Zdd�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd d!�d!�ZGd"d#�d#ee�ZGd$d%�d%ee
�ZGd&d'�d'e�ZdS)(�N)�deque��wraps)�
MethodType�GenericAlias)�asynccontextmanager�contextmanager�closing�nullcontext�AbstractContextManager�AbstractAsyncContextManager�AsyncExitStack�ContextDecorator�	ExitStack�redirect_stdout�redirect_stderr�suppressc@s6eZdZee�Zdd�Zejdd��Z	edd��Z
dS)rcCs|S�N���selfrr�//opt/alt/python39/lib64/python3.9/contextlib.py�	__enter__sz AbstractContextManager.__enter__cCsdSrr�r�exc_type�	exc_value�	tracebackrrr�__exit__szAbstractContextManager.__exit__cCs|turt�|dd�StS)Nrr)r�_collections_abc�_check_methods�NotImplemented��cls�Crrr�__subclasshook__sz'AbstractContextManager.__subclasshook__N)�__name__�
__module__�__qualname__�classmethodr�__class_getitem__r�abc�abstractmethodrr$rrrrrs
rc@s6eZdZee�Zdd�Zejdd��Z	edd��Z
dS)rc�s|Srrrrrr�
__aenter__+sz&AbstractAsyncContextManager.__aenter__c�sdSrrrrrr�	__aexit__/sz%AbstractAsyncContextManager.__aexit__cCs|turt�|dd�StS)Nr,r-)rrrr r!rrrr$4s
�z,AbstractAsyncContextManager.__subclasshook__N)r%r&r'r(rr)r,r*r+r-r$rrrrr%s
rc@seZdZdd�Zdd�ZdS)rcCs|Srrrrrr�_recreate_cm?s
zContextDecorator._recreate_cmcst����fdd��}|S)Ncs:�����|i|��Wd�S1s,0YdSr)r.��args�kwds��funcrrr�innerLs
z(ContextDecorator.__call__.<locals>.innerr)rr3r4rr2r�__call__KszContextDecorator.__call__N)r%r&r'r.r5rrrrr<src@seZdZdd�Zdd�ZdS)�_GeneratorContextManagerBasecCsN||i|��|_||||_|_|_t|dd�}|durDt|�j}||_dS)N�__doc__)�genr3r0r1�getattr�typer7)rr3r0r1�docrrr�__init__Vs
z%_GeneratorContextManagerBase.__init__cCs|�|j|j|j�Sr)�	__class__r3r0r1rrrrr.dsz)_GeneratorContextManagerBase._recreate_cmN)r%r&r'r<r.rrrrr6Ssr6c@seZdZdd�Zdd�ZdS)�_GeneratorContextManagercCs:|`|`|`zt|j�WSty4td�d�Yn0dS�Nzgenerator didn't yield)r0r1r3�nextr8�
StopIteration�RuntimeErrorrrrrrrs
z"_GeneratorContextManager.__enter__c
Cs |dur6zt|j�Wnty*YdS0td��n�|durD|�}z|j�|||�Wn�ty�}z||uWYd}~Sd}~0ty�}zF||ur�WYd}~dSt|t�r�|j|ur�WYd}~dS�WYd}~n<d}~0t�y}z||u�r��WYd}~dSd}~00td��dS)NF�generator didn't stopz#generator didn't stop after throw())r@r8rArB�throw�
isinstance�	__cause__�
BaseException�r�typ�valuer�excrrrr{s4
��
z!_GeneratorContextManager.__exit__N)r%r&r'rrrrrrr>ks	r>c@seZdZdd�Zdd�ZdS)�_AsyncGeneratorContextManagerc�s@|`|`|`z|j��IdHWSty:td�d�Yn0dSr?)r0r1r3r8�	__anext__�StopAsyncIterationrBrrrrr,�s
z(_AsyncGeneratorContextManager.__aenter__c
�s4|dur>z|j��IdHWnty0YdS0td���n�|durL|�}z|j�|||�IdHWn�ty�}z||uWYd}~Sd}~0t�y�}zJ||ur�WYd}~dSt|ttf�r�|j|ur�WYd}~dS�WYd}~n<d}~0t�y&}z||u�r�WYd}~dSd}~00td��dS)NFrCz$generator didn't stop after athrow())	r8rMrNrB�athrowrErArFrGrHrrrr-�s4��
z'_AsyncGeneratorContextManager.__aexit__N)r%r&r'r,r-rrrrrL�s	rLcst���fdd��}|S)Ncst�||�Sr)r>r/�r3rr�helperszcontextmanager.<locals>.helperr�r3rQrrPrr�srcst���fdd��}|S)Ncst�||�Sr)rLr/rPrrrQ&sz#asynccontextmanager.<locals>.helperrrRrrPrrsrc@s$eZdZdd�Zdd�Zdd�ZdS)r	cCs
||_dSr��thing)rrTrrrr<=szclosing.__init__cCs|jSrrSrrrrr?szclosing.__enter__cGs|j��dSr)rT�close)r�exc_inforrrrAszclosing.__exit__N�r%r&r'r<rrrrrrr	,sr	c@s(eZdZdZdd�Zdd�Zdd�ZdS)�_RedirectStreamNcCs||_g|_dSr)�_new_target�_old_targets)r�
new_targetrrrr<Isz_RedirectStream.__init__cCs*|j�tt|j��tt|j|j�|jSr)rZ�appendr9�sys�_stream�setattrrYrrrrrNsz_RedirectStream.__enter__cCstt|j|j���dSr)r_r]r^rZ�pop�r�exctype�excinst�exctbrrrrSsz_RedirectStream.__exit__)r%r&r'r^r<rrrrrrrXEsrXc@seZdZdZdS)r�stdoutN�r%r&r'r^rrrrrWs
rc@seZdZdZdS)r�stderrNrfrrrrrgsrc@s$eZdZdd�Zdd�Zdd�ZdS)rcGs
||_dSr)�_exceptions)r�
exceptionsrrrr<xszsuppress.__init__cCsdSrrrrrrr{szsuppress.__enter__cCs|duot||j�Sr)�
issubclassrhrarrrr~s
zsuppress.__exit__NrWrrrrrmsrc@s^eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zddd�ZdS)�_BaseExitStackcCs
t||�Sr�r��cm�cm_exitrrr�_create_exit_wrapper�sz#_BaseExitStack._create_exit_wrappercs���fdd�}|S)Ncs��i���dSrr�rrK�tb�r0�callbackr1rr�
_exit_wrapper�sz8_BaseExitStack._create_cb_wrapper.<locals>._exit_wrapperr�rtr0r1rurrsr�_create_cb_wrapper�sz!_BaseExitStack._create_cb_wrappercCst�|_dSr)r�_exit_callbacksrrrrr<�sz_BaseExitStack.__init__cCst|��}|j|_t�|_|Sr)r:rxr)r�	new_stackrrr�pop_all�s
z_BaseExitStack.pop_allcCs@t|�}z
|j}Wnty.|�|�Yn0|�||�|Sr)r:r�AttributeError�_push_exit_callback�
_push_cm_exit�r�exit�_cb_type�exit_methodrrr�push�s	
z_BaseExitStack.pushcCs(t|�}|j}|�|�}|�||�|Sr)r:rrr}�rrn�_cm_type�_exit�resultrrr�
enter_context�s

z_BaseExitStack.enter_contextcOs,|j|g|�Ri|��}||_|�|�|Sr)rw�__wrapped__r|�rrtr0r1rurrrrt�s
z_BaseExitStack.callbackcCs|�||�}|�|d�dS)NT)rpr|�rrnrorurrrr}�sz_BaseExitStack._push_cm_exitTcCs|j�||f�dSr)rxr\)rrt�is_syncrrrr|�sz"_BaseExitStack._push_exit_callbackN)T)
r%r&r'�staticmethodrprwr<rzr�r�rtr}r|rrrrrk�s


rkc@s$eZdZdd�Zdd�Zdd�ZdS)rcCs|Srrrrrrr�szExitStack.__enter__c
s�|ddu}t��d��fdd�}d}d}|jr�|j��\}}z||�rVd}d}d}Wq,t��}||d|d�d}|}Yq,0q,|r�z|dj}	|d�Wnty�|	|d_�Yn0|o�|S)Nr�cs4|j}|dus||urdS|�ur$q*|}q||_dSr��__context__��new_exc�old_exc�exc_context��	frame_excrr�_fix_exception_context�sz2ExitStack.__exit__.<locals>._fix_exception_contextFT�NNN�r]rVrxr`r�rG)
r�exc_details�received_excr��suppressed_exc�
pending_raiser��cb�new_exc_details�	fixed_ctxrr�rr�s2

zExitStack.__exit__cCs|�ddd�dSr)rrrrrrUszExitStack.closeN)r%r&r'rrrUrrrrr�s1rc@s\eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)r
cCs
t||�Srrlrmrrr�_create_async_exit_wrapper-sz)AsyncExitStack._create_async_exit_wrappercs���fdd�}|S)Nc�s��i���IdHdSrrrqrsrrru3sz>AsyncExitStack._create_async_cb_wrapper.<locals>._exit_wrapperrrvrrsr�_create_async_cb_wrapper1sz'AsyncExitStack._create_async_cb_wrapperc�s.t|�}|j}|�|�IdH}|�||�|Sr)r:r-r,�_push_async_cm_exitr�rrr�enter_async_context7s
z"AsyncExitStack.enter_async_contextcCsBt|�}z
|j}Wnty0|�|d�Yn0|�||�|S�NF)r:r-r{r|r�r~rrr�push_async_exitCs
zAsyncExitStack.push_async_exitcOs.|j|g|�Ri|��}||_|�|d�|Sr�)r�r�r|r�rrr�push_async_callbackUsz"AsyncExitStack.push_async_callbackc�s|�ddd�IdHdSr)r-rrrr�aclosebszAsyncExitStack.aclosecCs|�||�}|�|d�dSr�)r�r|r�rrrr�fsz"AsyncExitStack._push_async_cm_exitc�s|Srrrrrrr,lszAsyncExitStack.__aenter__c�s�|ddu}t��d��fdd�}d}d}|jr�|j��\}}z0|rP||�}n||�IdH}|rnd}d}d}Wq,t��}	||	d|d�d}|	}Yq,0q,|r�z|dj}
|d�Wnty�|
|d_�Yn0|o�|S)Nrr�cs4|j}|dus||urdS|�ur$q*|}q||_dSrr�r�r�rrr�usz8AsyncExitStack.__aexit__.<locals>._fix_exception_contextFTr�r�)rr�r�r�r�r�r�r��cb_suppressr�r�rr�rr-os8


zAsyncExitStack.__aexit__N)
r%r&r'r�r�r�r�r�r�r�r�r,r-rrrrr
 s



r
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
)r*r]r�collectionsr�	functoolsr�typesrr�__all__�ABCrr�objectrr6r>rLrrr	rXrrrrkrr
r
rrrr�<module>s<
�A�>!!PE

?>