One Hat Cyber Team
Your IP :
18.191.122.218
Server IP :
103.133.214.160
Server :
Linux venus.ewebguru.net 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
Server Software :
Apache/2
PHP Version :
8.1.30
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib64
/
python3.6
/
__pycache__
/
View File Name :
contextlib.cpython-36.opt-1.pyc
3 � \j3������������������@���s����d�Z�ddlZddlZddlZddlmZ�ddlmZ�ddddd d ddgZG�d d��dej �Z G�dd��de�ZG�dd��dee �Z dd��ZG�dd��de �ZG�dd��de �ZG�dd ��d e�ZG�dd��de�ZG�dd��de �ZG�dd ��d e �ZdS�)z4Utilities for with-statement contexts. See PEP 343.�����N)�deque)�wraps�contextmanager�closing�AbstractContextManager�ContextDecorator� ExitStack�redirect_stdout�redirect_stderr�suppressc���������������@���s2���e�Zd�ZdZdd��Zejdd���Zedd���Z dS�) r���z,An abstract base class for context managers.c�������������C���s���|�S�)z0Return `self` upon entering the runtime context.��)�selfr���r����"/usr/lib64/python3.6/contextlib.py� __enter__���s����z AbstractContextManager.__enter__c�������������C���s���dS�)z9Raise any exception triggered within the runtime context.Nr���)r ����exc_type� exc_value� tracebackr���r���r����__exit__���s����zAbstractContextManager.__exit__c�������������C���s���|�t�krtj|dd�S�tS�)Nr���r���)r����_collections_abc�_check_methods�NotImplemented)�cls�Cr���r���r����__subclasshook__���s����z'AbstractContextManager.__subclasshook__N) �__name__� __module__�__qualname__�__doc__r����abc�abstractmethodr����classmethodr���r���r���r���r���r��� ���s���c���������������@���s ���e�Zd�ZdZdd��Zdd��ZdS�)r���zJA base class or mixin that enables context managers to work as decorators.c�������������C���s���|�S�)a6��Return 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 ���r���r���r����_recreate_cm$���s���� zContextDecorator._recreate_cmc����������������s���t�������fdd��}|S�)Nc����������� ������s����j�������|�|�S�Q�R�X�d�S�)N)r!���)�args�kwds)�funcr ���r���r����inner1���s���� z(ContextDecorator.__call__.<locals>.inner)r���)r ���r$���r%���r���)r$���r ���r����__call__0���s����zContextDecorator.__call__N)r���r���r���r���r!���r&���r���r���r���r���r���!���s���c���������������@���s0���e�Zd�ZdZdd��Zdd��Zdd��Zdd ��Zd S�)�_GeneratorContextManagerz%Helper for @contextmanager decorator.c�������������C���sJ���|||�|�_�|||��|�_|�_|�_t|dd��}|d�kr@t|��j}||�_d�S�)Nr���)�genr$���r"���r#����getattr�typer���)r ���r$���r"���r#����docr���r���r����__init__;���s���� z!_GeneratorContextManager.__init__c�������������C���s���|�j�|�j|�j|�j�S�)N)� __class__r$���r"���r#���)r ���r���r���r���r!���I���s����z%_GeneratorContextManager._recreate_cmc�������������C���s.���y t�|�j�S��tk r(���td�d��Y�nX�d�S�)Nzgenerator didn't yield)�nextr(���� StopIteration�RuntimeError)r ���r���r���r���r���O���s���� z"_GeneratorContextManager.__enter__c�������������C���s����|d�kr6yt�|�j��W�n�tk r*���dS�X�td��n�|d�krD|��}y|�jj|||��W�n��tk r|�}�z||k S�d�}~X�nf�tk r��}�z*||kr�dS�|tkr�|j|kr�dS���W�Y�d�d�}~X�n"���tj��d�|kr�dS���Y�nX�td��d�S�)NFzgenerator didn't stop����z#generator didn't stop after throw())r.���r(���r/���r0����throw� __cause__�sys�exc_info)r ���r*����valuer����excr���r���r���r���U���s.���� z!_GeneratorContextManager.__exit__N)r���r���r���r���r,���r!���r���r���r���r���r���r���r'���8���s ���r'���c����������������s���t������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> c�����������������s���t���|�|�S�)N)r'���)r"���r#���)r$���r���r����helper����s����zcontextmanager.<locals>.helper)r���)r$���r8���r���)r$���r���r�������s����c���������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) r���a2��Context 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() c�������������C���s ���||�_�d�S�)N)�thing)r ���r9���r���r���r���r,�������s����zclosing.__init__c�������������C���s���|�j�S�)N)r9���)r ���r���r���r���r�������s����zclosing.__enter__c�������������G���s���|�j�j���d�S�)N)r9����close)r ���r5���r���r���r���r�������s����zclosing.__exit__N)r���r���r���r���r,���r���r���r���r���r���r���r�������s���c���������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�)�_RedirectStreamNc�������������C���s���||�_�g�|�_d�S�)N)�_new_target�_old_targets)r ���� new_targetr���r���r���r,�������s����z_RedirectStream.__init__c�������������C���s*���|�j�jtt|�j���tt|�j|�j��|�jS�)N)r=����appendr)���r4����_stream�setattrr<���)r ���r���r���r���r�������s����z_RedirectStream.__enter__c�������������C���s���t�t|�j|�jj����d�S�)N)rA���r4���r@���r=����pop)r ����exctype�excinst�exctbr���r���r���r�������s����z_RedirectStream.__exit__)r���r���r���r@���r,���r���r���r���r���r���r���r;�������s���r;���c���������������@���s���e�Zd�ZdZdZdS�)r ���aA��Context 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)r���r���r���r���r@���r���r���r���r���r �������s���c���������������@���s���e�Zd�ZdZdZdS�)r ���zCContext manager for temporarily redirecting stderr to another file.�stderrN)r���r���r���r���r@���r���r���r���r���r �������s���c���������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) r���a?��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 c�������������G���s ���||�_�d�S�)N)�_exceptions)r ���� exceptionsr���r���r���r,�������s����zsuppress.__init__c�������������C���s���d�S�)Nr���)r ���r���r���r���r�������s����zsuppress.__enter__c�������������C���s���|d�k ot�||�j�S�)N)� issubclassrH���)r ���rC���rD���rE���r���r���r���r�������s���� zsuppress.__exit__N)r���r���r���r���r,���r���r���r���r���r���r���r�������s��� c���������������@���sP���e�Zd�ZdZdd��Zdd��Zdd��Zdd ��Zd d��Zdd ��Z dd��Z dd��ZdS�)r���a���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 c�������������C���s���t���|�_d�S�)N)r����_exit_callbacks)r ���r���r���r���r,�����s����zExitStack.__init__c�������������C���s���t�|����}|�j|_t��|�_|S�)z?Preserve the context stack by transferring it to a new instance)r*���rK���r���)r ���� new_stackr���r���r����pop_all��s���� zExitStack.pop_allc����������������s"������fdd�}��|_�|�j|��dS�)z:Helper to correctly register callbacks to __exit__ methodsc�����������������s������f|����S�)Nr���)�exc_details)�cm�cm_exitr���r���� _exit_wrapper��s����z.ExitStack._push_cm_exit.<locals>._exit_wrapperN)�__self__�push)r ���rO���rP���rQ���r���)rO���rP���r���� _push_cm_exit��s����zExitStack._push_cm_exitc�������������C���sD���t�|�}y |j}W�n �tk r2���|�jj|��Y�nX�|�j||��|S�)a��Registers 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����AttributeErrorrK���r?���rT���)r ����exit�_cb_type�exit_methodr���r���r���rS��� ��s���� zExitStack.pushc����������������s$�������fdd�}�|_�|�j|���S�)z\Registers an arbitrary callback and arguments. Cannot suppress exceptions. c����������������s���������d�S�)Nr���)r���r7����tb)r"����callbackr#���r���r���rQ���9��s����z)ExitStack.callback.<locals>._exit_wrapper)�__wrapped__rS���)r ���rZ���r"���r#���rQ���r���)r"���rZ���r#���r���rZ���4��s���� zExitStack.callbackc�������������C���s(���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*���r���r���rT���)r ���rO����_cm_type�_exit�resultr���r���r���� enter_contextA��s ���� zExitStack.enter_contextc�������������C���s���|�j�ddd��dS�)z$Immediately unwind the context stackN)r���)r ���r���r���r���r:���N��s����zExitStack.closec������� ���������s����|d�d�k }t�j��d�����fdd�}d}d}x\|�jr�|�jj��}y||��rTd}d}d}W�q.���t�j��}||d�|d���d}|}Y�q.X�q.W�|r�y|d�j}|d��W�n �tk r����||d�_��Y�nX�|o�|S�)Nr���r1���c����������������s8���x,|�j�}||krd�S�|d�ks$|��kr&P�|}�qW�||�_�d�S�)N)�__context__)�new_exc�old_exc�exc_context)� frame_excr���r����_fix_exception_contextX��s����z2ExitStack.__exit__.<locals>._fix_exception_contextFT)NNN)r4���r5���rK���rB���r`���� BaseException) r ���rN����received_excre����suppressed_exc� pending_raise�cb�new_exc_details� fixed_ctxr���)rd���r���r���R��s2���� zExitStack.__exit__N)r���r���r���r���r,���rM���rT���rS���rZ���r_���r:���r���r���r���r���r���r�����s��� )r���r���r4���r����collectionsr���� functoolsr����__all__�ABCr����objectr���r'���r���r���r;���r ���r ���r���r���r���r���r���r����<module>���s$���I"