uawdijnntqw1x1x1
IP : 3.138.179.94
Hostname : ns1.eurodns.top
Kernel : Linux ns1.eurodns.top 4.18.0-553.5.1.lve.1.el7h.x86_64 #1 SMP Fri Jun 14 14:24:52 UTC 2024 x86_64
Disable Function : mail,sendmail,exec,passthru,shell_exec,system,popen,curl_multi_exec,show_source,eval,open_base
OS : Linux
PATH:
/
home
/
..
/
var
/
spool
/
..
/
..
/
lib64
/
python3.6
/
__pycache__
/
contextlib.cpython-36.pyc
/
/
3 \j3�@s�dZddlZddlZddlZddlmZddlmZddddd d ddgZGd d�dej �Z Gdd�de�ZGdd�dee �Z dd�ZGdd�de �ZGdd�de �ZGdd �d e�ZGdd�de�ZGdd�de �ZGdd �d e �ZdS)z4Utilities for with-statement contexts. See PEP 343.�N)�deque)�wraps�contextmanager�closing�AbstractContextManager�ContextDecorator� ExitStack�redirect_stdout�redirect_stderr�suppressc@s2eZdZdZdd�Zejdd��Zedd��Z dS) rz,An abstract base class for context managers.cCs|S)z0Return `self` upon entering the runtime context.�)�selfrr�"/usr/lib64/python3.6/contextlib.py� __enter__sz AbstractContextManager.__enter__cCsdS)z9Raise any exception triggered within the runtime context.Nr)r �exc_type� exc_value� tracebackrrr�__exit__szAbstractContextManager.__exit__cCs|tkrtj|dd�StS)Nrr)r�_collections_abc�_check_methods�NotImplemented)�cls�Crrr�__subclasshook__sz'AbstractContextManager.__subclasshook__N) �__name__� __module__�__qualname__�__doc__r�abc�abstractmethodr�classmethodrrrrrr sc@s eZdZdZdd�Zdd�ZdS)rzJA base class or mixin that enables context managers to work as decorators.cCs|S)a6Return a recreated instance of self. Allows an otherwise one-shot context manager like _GeneratorContextManager to support use as a decorator via implicit recreation. This is a private interface just for _GeneratorContextManager. See issue #11647 for details. r)r rrr�_recreate_cm$s zContextDecorator._recreate_cmcst����fdd��}|S)Nc s�j���||�SQRXdS)N)r!)�args�kwds)�funcr rr�inner1s z(ContextDecorator.__call__.<locals>.inner)r)r r$r%r)r$r r�__call__0szContextDecorator.__call__N)rrrrr!r&rrrrr!sc@s0eZdZdZdd�Zdd�Zdd�Zdd �Zd S)�_GeneratorContextManagerz%Helper for @contextmanager decorator.cCsJ|||�|_||||_|_|_t|dd�}|dkr@t|�j}||_dS)Nr)�genr$r"r#�getattr�typer)r r$r"r#�docrrr�__init__;s z!_GeneratorContextManager.__init__cCs|j|j|j|j�S)N)� __class__r$r"r#)r rrrr!Isz%_GeneratorContextManager._recreate_cmcCs.y t|j�Stk r(td�d�YnXdS)Nzgenerator didn't yield)�nextr(� StopIteration�RuntimeError)r rrrrOs z"_GeneratorContextManager.__enter__cCs�|dkr6yt|j�Wntk r*dSXtd��n�|dkrD|�}y|jj|||�Wn�tk r|}z||k Sd}~Xnftk r�}z*||kr�dS|tkr�|j|kr�dS�WYdd}~Xn"tj�d|kr�dS�YnXtd��dS)NFzgenerator didn't stop�z#generator didn't stop after throw())r.r(r/r0�throw� __cause__�sys�exc_info)r r*�valuer�excrrrrUs. z!_GeneratorContextManager.__exit__N)rrrrr,r!rrrrrrr'8s r'cst���fdd��}|S)a�@contextmanager decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<arguments>) as <variable>: <body> equivalent to this: <setup> try: <variable> = <value> <body> finally: <cleanup> cst�||�S)N)r')r"r#)r$rr�helper�szcontextmanager.<locals>.helper)r)r$r8r)r$rr�sc@s(eZdZdZdd�Zdd�Zdd�ZdS) ra2Context to automatically close something at the end of a block. Code like this: with closing(<module>.open(<arguments>)) as f: <block> is equivalent to this: f = <module>.open(<arguments>) try: <block> finally: f.close() cCs ||_dS)N)�thing)r r9rrrr,�szclosing.__init__cCs|jS)N)r9)r rrrr�szclosing.__enter__cGs|jj�dS)N)r9�close)r r5rrrr�szclosing.__exit__N)rrrrr,rrrrrrr�sc@s(eZdZdZdd�Zdd�Zdd�ZdS)�_RedirectStreamNcCs||_g|_dS)N)�_new_target�_old_targets)r � new_targetrrrr,�sz_RedirectStream.__init__cCs*|jjtt|j��tt|j|j�|jS)N)r=�appendr)r4�_stream�setattrr<)r rrrr�sz_RedirectStream.__enter__cCstt|j|jj��dS)N)rAr4r@r=�pop)r �exctype�excinst�exctbrrrr�sz_RedirectStream.__exit__)rrrr@r,rrrrrrr;�sr;c@seZdZdZdZdS)r aAContext manager for temporarily redirecting stdout to another file. # How to send help() to stderr with redirect_stdout(sys.stderr): help(dir) # How to write help() to a file with open('help.txt', 'w') as f: with redirect_stdout(f): help(pow) �stdoutN)rrrrr@rrrrr �sc@seZdZdZdZdS)r zCContext manager for temporarily redirecting stderr to another file.�stderrN)rrrrr@rrrrr �sc@s(eZdZdZdd�Zdd�Zdd�ZdS) ra?Context manager to suppress specified exceptions After the exception is suppressed, execution proceeds with the next statement following the with statement. with suppress(FileNotFoundError): os.remove(somefile) # Execution still resumes here if the file was already removed cGs ||_dS)N)�_exceptions)r � exceptionsrrrr,�szsuppress.__init__cCsdS)Nr)r rrrr�szsuppress.__enter__cCs|dk ot||j�S)N)� issubclassrH)r rCrDrErrrr�s zsuppress.__exit__N)rrrrr,rrrrrrr�s c@sPeZdZdZdd�Zdd�Zdd�Zdd �Zd d�Zdd �Z dd�Z dd�ZdS)ra�Context manager for dynamic management of a stack of exit callbacks For example: with ExitStack() as stack: files = [stack.enter_context(open(fname)) for fname in filenames] # All opened files will automatically be closed at the end of # the with statement, even if attempts to open files later # in the list raise an exception cCst�|_dS)N)r�_exit_callbacks)r rrrr,szExitStack.__init__cCst|��}|j|_t�|_|S)z?Preserve the context stack by transferring it to a new instance)r*rKr)r � new_stackrrr�pop_alls zExitStack.pop_allcs"��fdd�}�|_|j|�dS)z:Helper to correctly register callbacks to __exit__ methodscs��f|��S)Nr)�exc_details)�cm�cm_exitrr� _exit_wrappersz.ExitStack._push_cm_exit.<locals>._exit_wrapperN)�__self__�push)r rOrPrQr)rOrPr� _push_cm_exitszExitStack._push_cm_exitcCsDt|�}y |j}Wn tk r2|jj|�YnX|j||�|S)aRegisters a callback with the standard __exit__ method signature Can suppress exceptions the same way __exit__ methods can. Also accepts any object with an __exit__ method (registering a call to the method instead of the object itself) )r*r�AttributeErrorrKr?rT)r �exit�_cb_type�exit_methodrrrrS s zExitStack.pushcs$���fdd�}�|_|j|��S)z\Registers an arbitrary callback and arguments. Cannot suppress exceptions. cs����dS)Nr)rr7�tb)r"�callbackr#rrrQ9sz)ExitStack.callback.<locals>._exit_wrapper)�__wrapped__rS)r rZr"r#rQr)r"rZr#rrZ4s zExitStack.callbackcCs(t|�}|j}|j|�}|j||�|S)z�Enters the supplied context manager If successful, also pushes its __exit__ method as a callback and returns the result of the __enter__ method. )r*rrrT)r rO�_cm_type�_exit�resultrrr� enter_contextAs zExitStack.enter_contextcCs|jddd�dS)z$Immediately unwind the context stackN)r)r rrrr:NszExitStack.closec s�|ddk }tj�d��fdd�}d}d}x\|jr�|jj�}y||�rTd}d}d}Wq.tj�}||d|d�d}|}Yq.Xq.W|r�y|dj}|d�Wn tk r�||d_�YnX|o�|S)Nrr1cs8x,|j}||krdS|dks$|�kr&P|}qW||_dS)N)�__context__)�new_exc�old_exc�exc_context)� frame_excrr�_fix_exception_contextXsz2ExitStack.__exit__.<locals>._fix_exception_contextFT)NNN)r4r5rKrBr`� BaseException) r rN�received_excre�suppressed_exc� pending_raise�cb�new_exc_details� fixed_ctxr)rdrrRs2 zExitStack.__exit__N)rrrrr,rMrTrSrZr_r:rrrrrrs )rrr4r�collectionsr� functoolsr�__all__�ABCr�objectrr'rrr;r r rrrrrr�<module>s$I"
/home/../var/spool/../../lib64/python3.6/__pycache__/contextlib.cpython-36.pyc