����JFIF���������
1#@!#!123s
D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
python27
/
lib
/
python2.7
/
site-packages
/
Filename :
contextlib2.pyc
back
Copy
� �s�Wc�����������@���s���d��Z��d�d�l�Z�d�d�l�Z�d�d�l�m�Z�d�d�l�m�Z�d�d�d�d�d �d �d�g�Z�e�d�g�7Z�d�e�f�d �������YZ �d�e �f�d�������YZ �d����Z�d�e�f�d�������YZ�d�e�f�d�������YZ �d �e �f�d�������YZ�d �e �f�d�������YZ�d�e�f�d�������YZ�e�j�d�d�k�Z�e�r7d����Z�d����Z�n�d����Z�d����Z�y�d�d�l�m�Z�Wn�e�k �rve�Z�n �Xd����Z�d�e�f�d�������YZ�d�e�f�d �������YZ�d�S(!���sA���contextlib2 - backports and enhancements to the contextlib modulei����N(���t���deque(���t���wrapst���contextmanagert���closingt���ContextDecoratort ���ExitStackt���redirect_stdoutt���redirect_stderrt���suppresst���ContextStackc�����������B���s)���e��Z�d��Z�d����Z�d����Z�d����Z�RS(���sJ���A base class or mixin that enables context managers to work as decorators.c���������C���s���t��j�d�t���|��j����S(���s���Returns the context manager used to actually wrap the call to the decorated function. The default implementation just returns *self*. Overriding this method allows otherwise one-shot context managers like _GeneratorContextManager to support use as decorators via implicit recreation. DEPRECATED: refresh_cm was never added to the standard library's ContextDecorator API s2���refresh_cm was never added to the standard library(���t���warningst���warnt���DeprecationWarningt���_recreate_cm(���t���self(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt ���refresh_cm���s���� c���������C���s���|��S(���s6��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���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR ���"���s���� c������������s"���t������������f�d������}�|�S(���Nc�������������s$�����j����������|��|����SWd��QXd��S(���N(���R ���(���t���argst���kwds(���t���funcR���(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���inner/���s���� (���R���(���R���R���R���(����(���R���R���s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���__call__.���s����(���t���__name__t ���__module__t���__doc__R���R ���R���(����(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR������s��� t���_GeneratorContextManagerc�����������B���s2���e��Z�d��Z�d����Z�d����Z�d����Z�d����Z�RS(���s%���Helper for @contextmanager decorator.c���������C���sl���|�|�|����|��_��|�|�|�|��_�|��_�|��_�t�|�d�d����}�|�d��k�r_�t�|����j�}�n��|�|��_�d��S(���NR���(���t���genR���R���R���t���getattrt���Nonet���typeR���(���R���R���R���R���t���doc(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���__init__9���s����c���������C���s���|��j��|��j�|��j�|��j���S(���N(���t ���__class__R���R���R���(���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR ���G���s����c���������C���s5���y�t��|��j���SWn�t�k �r0�t�d�����n�Xd��S(���Ns���generator didn't yield(���t���nextR���t ���StopIterationt���RuntimeError(���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt ���__enter__M���s���� c���������C���s���|�d��k�rA�y�t�|��j���Wn�t�k �r1�d��SXt�d�����n��|�d��k�rY�|����}�n��y&�|��j�j�|�|�|���t�d�����Wnz�t�k �r��}�|�|�k �St�k �r��}�|�|�k�r��t�St�r��|�j�|�k�r��t�S���n#�t �j ����d�|�k �r�����q��n�Xd��S(���Ns���generator didn't stops#���generator didn't stop after throw()i���(���R���R ���R���R!���R"���t���throwt���Falset���_HAVE_EXCEPTION_CHAININGt ���__cause__t���syst���exc_info(���R���R���t���valuet ���tracebackt���exc(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���__exit__S���s,���� (���R���R���R���R���R ���R#���R-���(����(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR���6���s ��� c������������s���t����������f�d������}�|�S(���s���@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���(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���helper����s����(���R���(���R���R.���(����(���R���s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR���~���s����c�����������B���s)���e��Z�d��Z�d����Z�d����Z�d����Z�RS(���s2��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(���t���thing(���R���R/���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR�������s����c���������C���s���|��j��S(���N(���R/���(���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR#�������s����c���������G���s���|��j��j����d��S(���N(���R/���t���close(���R���R)���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR-�������s����(���R���R���R���R���R#���R-���(����(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR�������s��� t���_RedirectStreamc�����������B���s)���e��Z�d�Z�d�����Z�d����Z�d����Z�RS(���c���������C���s���|�|��_��g��|��_�d��S(���N(���t���_new_targett���_old_targets(���R���t ���new_target(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR�������s���� c���������C���s9���|��j��j�t�t�|��j�����t�t�|��j�|��j���|��j�S(���N(���R3���t���appendR���R(���t���_streamt���setattrR2���(���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR#�������s����c���������C���s ���t��t�|��j�|��j�j������d��S(���N(���R7���R(���R6���R3���t���pop(���R���t���exctypet���excinstt���exctb(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR-�������s����N(���R���R���R���R6���R���R#���R-���(����(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR1�������s��� c�����������B���s���e��Z�d��Z�d�Z�RS(���sA��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) t���stdout(���R���R���R���R6���(����(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR�������s���c�����������B���s���e��Z�d��Z�d�Z�RS(���sC���Context manager for temporarily redirecting stderr to another file.t���stderr(���R���R���R���R6���(����(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR�������s���c�����������B���s)���e��Z�d��Z�d����Z�d����Z�d����Z�RS(���s?��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(���t���_exceptions(���R���t ���exceptions(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR�������s����c���������C���s���d��S(���N(����(���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR#�������s����c���������C���s���|�d��k �o�t�|�|��j���S(���N(���R���t ���issubclassR>���(���R���R9���R:���R;���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR-�������s���� (���R���R���R���R���R#���R-���(����(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR�������s��� i����i���c������������s������f�d����}�|�S(���Nc������������sO���x?�|��j��}�|�|�k�r�d��S|�d��k�s4�|����k�r8�Pn��|�}��q�W|�|��_��d��S(���N(���t���__context__R���(���t���new_exct���old_exct���exc_context(���t ���frame_exc(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���_fix_exception_context��s���� (����(���RE���RF���(����(���RE���s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���_make_context_fixer��s���� c���������C���sC���y�|��d�j��}�|��d���Wn!�t�k �r>�|�|��d�_�����n�Xd��S(���Ni���(���RA���t ���BaseException(���t���exc_detailst ���fixed_ctx(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���_reraise_with_existing_context��s���� c���������C���s���d����S(���Nc���������S���s���d��S(���N(���R���(���RB���RC���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���<lambda>��t����(����(���RE���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyRG�����s����c���������B���s���|��\�}�}�}�d�d��Ud��S(���Ns!���raise exc_type, exc_value, exc_tb(����(���RI���t���exc_typet ���exc_valuet���exc_tb(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyRK���"��s����(���t���InstanceTypec���������C���s#���t��|����}�|�t�k�r�|��j�S|�S(���N(���R���RQ���R���(���t���objt���obj_type(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt ���_get_type.��s����c�����������B���s_���e��Z�d��Z�d����Z�d����Z�d����Z�d����Z�d����Z�d����Z�d����Z �d����Z �d ����Z�RS( ���s���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����t���_exit_callbacks(���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR���A��s����c���������C���s+���t��|�������}�|��j�|�_�t����|��_�|�S(���s?���Preserve the context stack by transferring it to a new instance(���R���RU���R����(���R���t ���new_stack(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���pop_allD��s����c������������s,��������f�d����}����|�_��|��j�|���d�S(���s:���Helper to correctly register callbacks to __exit__ methodsc�������������s ��������|����S(���N(����(���RI���(���t���cmt���cm_exit(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt ���_exit_wrapperM��s����N(���t���__self__t���push(���R���RX���RY���RZ���(����(���RX���RY���s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt ���_push_cm_exitK��s���� c���������C���sQ���t��|���}�y �|�j�}�Wn!�t�k �r<�|��j�j�|���n�X|��j�|�|���|�S(���s��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) (���RT���R-���t���AttributeErrorRU���R5���R]���(���R���t���exitt���_cb_typet���exit_method(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR\���R��s���� c������������s/����������f�d����}���|�_��|��j�|�����S(���s\���Registers an arbitrary callback and arguments. Cannot suppress exceptions. c������������s�������������d��S(���N(����(���RN���R,���t���tb(���R���t���callbackR���(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyRZ���k��s����(���t���__wrapped__R\���(���R���Rc���R���R���RZ���(����(���R���Rc���R���s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyRc���f��s���� c���������C���s8���t��|���}�|�j�}�|�j�|���}�|��j�|�|���|�S(���s����Enters the supplied context manager If successful, also pushes its __exit__ method as a callback and returns the result of the __enter__ method. (���RT���R-���R#���R]���(���R���RX���t���_cm_typet���_exitt���result(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt ���enter_contexts��s ���� c���������C���s���|��j��d�d�d���d�S(���s$���Immediately unwind the context stackN(���R-���R���(���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR0������s����c���������C���s���|��S(���N(����(���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR#������s����c��� ������G���s����|�d�d��k �}�t�j����d�}�t�|���}�t�}�t�}�xx�|��j�r��|��j�j����}�y%�|�|����rw�t�}�t�}�d�}�n��Wq;�t�j����}�|�|�d�|�d���t�}�|�}�q;�Xq;�W|�r��t�|���n��|�o��|�S(���Ni����i���(���NNN( ���R���R(���R)���RG���R%���RU���R8���t���TrueRK���( ���R���RI���t���received_excRE���RF���t���suppressed_exct ���pending_raiset���cbt���new_exc_details(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR-������s(���� (���R���R���R���R���RW���R]���R\���Rc���Rh���R0���R#���R-���(����(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR���5��s��� c�����������B���s2���e��Z�d��Z�d����Z�d����Z�d����Z�d����Z�RS(���s+���Backwards compatibility alias for ExitStackc���������C���s'���t��j�d�t���t�t�|����j����d��S(���Ns*���ContextStack has been renamed to ExitStack(���R ���R���R���t���superR ���R���(���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR������s���� c���������C���s ���|��j��|���S(���N(���R\���(���R���Rc���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt ���register_exit���s����c���������O���s���|��j��|�|�|���S(���N(���Rc���(���R���Rc���R���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���register���s����c���������C���s ���|��j�����S(���N(���RW���(���R���(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���preserve���s����(���R���R���R���R���Rp���Rq���Rr���(����(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyR ������s ��� (���R���R(���R ���t���collectionsR����t ���functoolsR���t���__all__t���objectR���R���R���R���R1���R���R���R���t���version_infoR&���RG���RK���t���typesRQ���t���ImportErrorR���RT���R���R ���(����(����(����s<���/opt/alt/python27/lib/python2.7/site-packages/contextlib2.pyt���<module>���s8��� (H " p