Critics have remarked that those four worthies were truly peerless throughout the ages; yet the present falls short of the pastβ€”the ancients favored unadorned simplicity, whereas the moderns prefer refined elegance. Styles of substance and ornament rise and fall in succession, shifting with the changing mores of the times; such evolution is simply the natural order of things. The ideal lies in honoring antiquity without clashing with the present, and embracing modernity without succumbing to its flawsβ€”embodying that perfect balance of substance and refinement that defines the true gentleman. There is surely no need to abandon a carved palace in favor of a cave dwelling, or to trade a jade carriage for a primitive cart with solid wooden wheels.🌌 SpectraShell

🌌 SpectraShell

Current path: lib64/python3.6/__pycache__/



⬆️ Go up: /lib64/python3.6

πŸ“„ Viewing: contextlib.cpython-36.pyc

3


 \j3οΏ½@sοΏ½dZddlZddlZddlZddlmZddlmZddddd	d
ddgZGd
dοΏ½dej	οΏ½Z
GddοΏ½deοΏ½ZGddοΏ½dee
οΏ½Z
ddοΏ½ZGddοΏ½de
οΏ½ZGddοΏ½de
οΏ½ZGdd
οΏ½d
eοΏ½ZGddοΏ½deοΏ½ZGddοΏ½de
οΏ½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.οΏ½)οΏ½selfrrοΏ½"/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οΏ½	tracebackrrrοΏ½__exit__szAbstractContextManager.__exit__cCs|tkrtj|ddοΏ½StS)Nrr)rοΏ½_collections_abcοΏ½_check_methodsοΏ½NotImplemented)οΏ½clsοΏ½CrrrοΏ½__subclasshook__sz'AbstractContextManager.__subclasshook__N)
οΏ½__name__οΏ½
__module__οΏ½__qualname__οΏ½__doc__rοΏ½abcοΏ½abstractmethodrοΏ½classmethodrrrrrr
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
rrrοΏ½_recreate_cm$s
zContextDecorator._recreate_cmcstοΏ½οΏ½οΏ½οΏ½fddοΏ½οΏ½}|S)Nc
sοΏ½jοΏ½οΏ½οΏ½||οΏ½SQRXdS)N)r!)οΏ½argsοΏ½kwds)οΏ½funcr
rrοΏ½inner1s
z(ContextDecorator.__call__.<locals>.inner)r)r
r$r%r)r$r
rοΏ½__call__0szContextDecorator.__call__N)rrrrr!r&rrrrr!sc@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#οΏ½docrrrοΏ½__init__;s
z!_GeneratorContextManager.__init__cCs|j|j|j|jοΏ½S)N)οΏ½	__class__r$r"r#)r
rrrr!Isz%_GeneratorContextManager._recreate_cmcCs.y
t|jοΏ½Stk
r(tdοΏ½dοΏ½YnXdS)Nzgenerator didn't yield)οΏ½nextr(οΏ½
StopIterationοΏ½RuntimeError)r
rrrrOs
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οΏ½excrrrrUs.
z!_GeneratorContextManager.__exit__N)rrrrr,r!rrrrrrr'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>

    cstοΏ½||οΏ½S)N)r')r"r#)r$rrοΏ½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
r9rrrr,οΏ½szclosing.__init__cCs|jS)N)r9)r
rrrrοΏ½szclosing.__enter__cGs|jjοΏ½dS)N)r9οΏ½close)r
r5rrrrοΏ½szclosing.__exit__N)rrrrr,rrrrrrrοΏ½sc@s(eZdZdZddοΏ½ZddοΏ½ZddοΏ½ZdS)οΏ½_RedirectStreamNcCs||_g|_dS)N)οΏ½_new_targetοΏ½_old_targets)r
οΏ½
new_targetrrrr,οΏ½sz_RedirectStream.__init__cCs*|jjtt|jοΏ½οΏ½tt|j|jοΏ½|jS)N)r=οΏ½appendr)r4οΏ½_streamοΏ½setattrr<)r
rrrrοΏ½sz_RedirectStream.__enter__cCstt|j|jjοΏ½οΏ½dS)N)rAr4r@r=οΏ½pop)r
οΏ½exctypeοΏ½excinstοΏ½exctbrrrrοΏ½sz_RedirectStream.__exit__)rrrr@r,rrrrrrr;οΏ½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@rrrrr	οΏ½sc@seZdZdZdZdS)r
zCContext manager for temporarily redirecting stderr to another file.οΏ½stderrN)rrrrr@rrrrr
οΏ½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
οΏ½
exceptionsrrrr,οΏ½szsuppress.__init__cCsdS)Nr)r
rrrrοΏ½szsuppress.__enter__cCs|dk	ot||jοΏ½S)N)οΏ½
issubclassrH)r
rCrDrErrrrοΏ½s
zsuppress.__exit__N)rrrrr,rrrrrrrοΏ½s	c@sPeZdZdZddοΏ½ZddοΏ½ZddοΏ½Zdd	οΏ½Zd
dοΏ½Zdd
οΏ½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

    cCstοΏ½|_dS)N)rοΏ½_exit_callbacks)r
rrrr,szExitStack.__init__cCst|οΏ½οΏ½}|j|_tοΏ½|_|S)z?Preserve the context stack by transferring it to a new instance)r*rKr)r
οΏ½	new_stackrrrοΏ½pop_alls
zExitStack.pop_allcs"οΏ½οΏ½fddοΏ½}οΏ½|_|j|οΏ½dS)z:Helper to correctly register callbacks to __exit__ methodscsοΏ½οΏ½f|οΏ½οΏ½S)Nr)οΏ½exc_details)οΏ½cmοΏ½cm_exitrrοΏ½
_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_methodrrrrS s

zExitStack.pushcs$οΏ½οΏ½οΏ½fddοΏ½}οΏ½|_|j|οΏ½οΏ½S)z\Registers an arbitrary callback and arguments.

        Cannot suppress exceptions.
        csοΏ½οΏ½οΏ½οΏ½dS)Nr)rr7οΏ½tb)r"οΏ½callbackr#rrrQ9sz)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οΏ½resultrrrοΏ½
enter_contextAs

zExitStack.enter_contextcCs|jdddοΏ½dS)z$Immediately unwind the context stackN)r)r
rrrr: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_excrrοΏ½_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:rrrrrrs

)rrr4rοΏ½collectionsrοΏ½	functoolsrοΏ½__all__οΏ½ABCrοΏ½objectrr'rrr;r	r
rrrrrrοΏ½<module>s$I"


πŸ“