python (3.12.0)

(root)/
lib/
python3.12/
__pycache__/
contextlib.cpython-312.pyc

ˑej"dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZgdZGddejZGd	d
ejZGddeZGd
deZGddZGddeeeZGddeeeZdZdZGddeZGddeZGddeZGddeZGdd eZGd!d"eZGd#d$ZGd%d&eeZGd'd(eeZ Gd)d*eeZ!Gd+d,eZ"y)-z4Utilities for with-statement contexts.  See PEP 343.N)dequewraps)
MethodTypeGenericAlias)asynccontextmanagercontextmanagerclosingnullcontextAbstractContextManagerAbstractAsyncContextManagerAsyncExitStackContextDecorator	ExitStackredirect_stdoutredirect_stderrsuppressaclosingchdircZeZdZdZeeZdZejdZ
edZy)rz,An abstract base class for context managers.c|Sz0Return `self` upon entering the runtime context.selfs >/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/contextlib.py	__enter__z AbstractContextManager.__enter__scyz9Raise any exception triggered within the runtime context.Nrrexc_type	exc_value	tracebacks    r__exit__zAbstractContextManager.__exit__srcL|turtj|ddStS)Nrr%)r_collections_abc_check_methodsNotImplementedclsCs  r__subclasshook__z'AbstractContextManager.__subclasshook__ s&((#221k:NNrN)__name__
__module____qualname____doc__classmethodr__class_getitem__rabcabstractmethodr%r-rrrrrsC6#L1	rrcZeZdZdZeeZdZejdZ
edZy)r
z9An abstract base class for asynchronous context managers.cK|Swrrrs r
__aenter__z&AbstractAsyncContextManager.__aenter__-scKywr rr!s    r	__aexit__z%AbstractAsyncContextManager.__aexit__1scL|turtj|ddStS)Nr8r;)r
r'r(r)r*s  rr-z,AbstractAsyncContextManager.__subclasshook__6s---#221l3>@
@rN)r.r/r0r1r2rr3r8r4r5r;r-rrrr
r
'sCC#L1	rr
ceZdZdZdZdZy)rzJA base class or mixin that enables context managers to work as decorators.c|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.
        rrs r_recreate_cmzContextDecorator._recreate_cmAs	rc2tfd}|S)Nc`j5|i|cdddS#1swYyxYwNr@argskwdsfuncrs  rinnerz(ContextDecorator.__call__.<locals>.innerNs1""$
+T*T*
+
+
+s$-rrrHrIs`` r__call__zContextDecorator.__call__Ms 	t	+
	+rNr.r/r0r1r@rKrrrrr>sP
rrceZdZdZdZdZy)AsyncContextDecoratorzPA base class or mixin that enables async context managers to work as decorators.c|S)z-Return a recreated instance of self.
        rrs rr@z"AsyncContextDecorator._recreate_cmXs	rc2tfd}|S)NcKj4d{|i|d{cdddd{S7%77	#1d{7swYyxYwwrCrDrEs  rrIz-AsyncContextDecorator.__call__.<locals>.inner^sV((*
1
1!40400
1
1
10
1
1
1
1sPA>AAAAAAAAAA
A
AArrJs`` rrKzAsyncContextDecorator.__call__]s 	t	1
	1rNrLrrrrNrNUsV
rrNceZdZdZdZdZy)_GeneratorContextManagerBasezBShared functionality for @contextmanager and @asynccontextmanager.c||i||_|||c|_|_|_t	|dd}|t|j}||_y)Nr1)genrHrFrGgetattrtyper1)rrHrFrGdocs     r__init__z%_GeneratorContextManagerBase.__init__hsR&&*.d'	49didIt,;t*$$Crcd|j|j|j|jSrC)	__class__rHrFrGrs rr@z)_GeneratorContextManagerBase._recreate_cmvs#~~diiDII>>rN)r.r/r0r1rYr@rrrrSrSesL?rrSceZdZdZdZdZy)_GeneratorContextManagerz%Helper for @contextmanager decorator.cl|`|`|`	t|jS#t
$r
t
ddwxYwNzgenerator didn't yield)rFrGrHnextrU
StopIterationRuntimeErrorrs rrz"_GeneratorContextManager.__enter__sD
Ity$)	C>!	C78dB	Cs3c|!	t|jtd||}	|jj	|td#t$rYywxYw#t$r}||ucYd}~Sd}~wt$r@}||ur||_Yd}~yt
|tr|j|ur||_Yd}~yd}~wt$r}||ur||_Yd}~yd}~wwxYw)Ngenerator didn't stopFz#generator didn't stop after throw())	r`rUrbrathrow
__traceback__
isinstance	__cause__
BaseExceptionrtypvaluer$excs     rr%z!_GeneratorContextManager.__exit__s;
<TXX##:;;}#
u%FDEE[!

!
(%''
%<(1C% um4

.*3E'  

e#$-!

sRAA#	A A #	C,A5/C5CB<%B<;B<<CCCN)r.r/r0r1rr%rrrr]r]}s
0C1Frr]ceZdZdZdZdZy)_AsyncGeneratorContextManagerz*Helper for @asynccontextmanager decorator.cK|`|`|`	t|jd{S7#t
$r
t
ddwxYwwr_)rFrGrHanextrUStopAsyncIterationrbrs rr8z(_AsyncGeneratorContextManager.__aenter__sM
Ity$)	Ctxx(((!	C78dB	Cs#A)')A)?AcK|)	t|jd{td||}	|jj	|d{td7G#t$rYywxYw7 #t$r}||ucYd}~Sd}~wt$rF}||ur||_Yd}~yt
|ttfr|j|ur||_Yd}~yd}~wt$r}||ur||_Yd}~yd}~wwxYww)NrdFz$generator didn't stop after athrow())
rqrUrbrrathrowrfrgrarhrirjs     rr;z'_AsyncGeneratorContextManager.__aexit__s;
<DHHo%%##:;;}#
hhooe,,,FEFF]&%

-%
(%''
%<(1C% u}6H&IJ

.*3E'  

e#$-!

sC=A(A&A(C=A9A7A9C=&A((	A41C=3A44C=7A99	C:BC:C=C:C"C='+CC=CC:$C50C=5C::C=N)r.r/r0r1r8r;rrrroros
5C1Grroc.tfd}|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>
    ct||SrC)r]rFrGrHs  rhelperzcontextmanager.<locals>.helpers'dD99rrrHrxs` rr	r	s 64[::Mrc.tfd}|S)a@asynccontextmanager decorator.

    Typical usage:

        @asynccontextmanager
        async def some_async_generator(<arguments>):
            <setup>
            try:
                yield <value>
            finally:
                <cleanup>

    This makes this:

        async with some_async_generator(<arguments>) as <variable>:
            <body>

    equivalent to this:

        <setup>
        try:
            <variable> = <value>
            <body>
        finally:
            <cleanup>
    ct||SrC)rorws  rrxz#asynccontextmanager.<locals>.helper@s,T4>>rrrys` rrr%s 64[??Mrc"eZdZdZdZdZdZy)r
a2Context 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||_yrCthingrrs  rrYzclosing.__init__W	
rc|jSrCr~rs rrzclosing.__enter__Yszzrc8|jjyrC)rcloserexc_infos  rr%zclosing.__exit__[s

rNr.r/r0r1rYrr%rrrr
r
Fs rr
c"eZdZdZdZdZdZy)raAsync context manager for safely finalizing an asynchronously cleaned-up
    resource such as an async generator, calling its ``aclose()`` method.

    Code like this:

        async with aclosing(<module>.fetch(<arguments>)) as agen:
            <block>

    is equivalent to this:

        agen = <module>.fetch(<arguments>)
        try:
            <block>
        finally:
            await agen.aclose()

    c||_yrCr~rs  rrYzaclosing.__init__qrrc"K|jSwrCr~rs rr8zaclosing.__aenter__sszz
cTK|jjd{y7wrC)raclosers  rr;zaclosing.__aexit__usjj!!!s(&(N)r.r/r0r1rYr8r;rrrrr_s""rrc"eZdZdZdZdZdZy)_RedirectStreamNc ||_g|_yrC)_new_target_old_targets)r
new_targets  rrYz_RedirectStream.__init__}s%rc|jjtt|jtt|j|j|jSrC)rappendrVsys_streamsetattrrrs rrz_RedirectStream.__enter__sC  dll!;<T\\4#3#34rcjtt|j|jj	yrC)rrrrpop)rexctypeexcinstexctbs    rr%z_RedirectStream.__exit__s!T\\4#4#4#8#8#:;r)r.r/r0rrYrr%rrrrrysG
 
<rrceZdZdZdZy)raAContext 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)
    stdoutNr.r/r0r1rrrrrrs
GrrceZdZdZdZy)rzCContext manager for temporarily redirecting stderr to another file.stderrNrrrrrrs
MGrrc"eZdZdZdZdZdZy)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
    c||_yrC)_exceptions)r
exceptionss  rrYzsuppress.__init__s
%rcyrCrrs rrzsuppress.__enter__rc|yt||jryt|tr#|j|j\}}|y|y)NTF)
issubclassrExceptionGroupsplit)rrrrmatchrests      rr%zsuppress.__exit__sQ?gt//0g~.!--(8(89KE4|JrNrrrrrrs&
rrc\eZdZdZedZedZdZdZdZ	dZ
dZd	Zdd
Z
y)
_BaseExitStackz.A base class for ExitStack and AsyncExitStack.ct||SrCrcmcm_exits  r_create_exit_wrapperz#_BaseExitStack._create_exit_wrapper'2&&rcfd}|S)NciyrCrr"rmtbrFcallbackrGs   r
_exit_wrapperz8_BaseExitStack._create_cb_wrapper.<locals>._exit_wrappersd#d#rrrrFrGrs``` r_create_cb_wrapperz!_BaseExitStack._create_cb_wrappers	$rc"t|_yrC)r_exit_callbacksrs rrYz_BaseExitStack.__init__s$wrcft|}|j|_t|_|S)z@Preserve the context stack by transferring it to a new instance.)rWrr)r	new_stacks  rpop_allz_BaseExitStack.pop_alls-DJL	$($8$8	!$wrct|}	|j}|j|||S#t$r|j	|Y|SwxYw)aRegisters a callback with the standard __exit__ method signature.

        Can suppress exceptions the same way __exit__ method can.
        Also accepts any object with an __exit__ method (registering a call
        to the method instead of the object itself).
        )rWr%
_push_cm_exitAttributeError_push_exit_callbackrexit_cb_typeexit_methods    rpushz_BaseExitStack.pushsZ:	2"++K

t[1	+$$T*	+s-A
Act|}	|j}|j}||}|j|||S#t$r(t	d|j
d|jddwxYw)zEnters the supplied context manager.

        If successful, also pushes its __exit__ method as a callback and
        returns the result of the __enter__ method.
        '.z6' object does not support the context manager protocolN)rWrr%r	TypeErrorr/r0rrrr+_enter_exitresults      r
enter_contextz_BaseExitStack.enter_contexts2h	S]]FLLE2u%
	Sa/q1A1A0BCGHINR
S	SsA1A2cb|j|g|i|}||_|j||S)z\Registers an arbitrary callback and arguments.

        Cannot suppress exceptions.
        )r__wrapped__rrrrFrGrs     rrz_BaseExitStack.callbacks=
0//H4H4H
%-
!  /rcL|j||}|j|dy)z;Helper to correctly register callbacks to __exit__ methods.TN)rrrrrrs    rrz_BaseExitStack._push_cm_exits$11"g>
  5rc>|jj||fyrC)rr)rris_syncs   rrz"_BaseExitStack._push_exit_callbacks##Wh$78rN)T)r.r/r0r1staticmethodrrrYrrrrrrrrrrrsN8''
'(&6
9rrc"eZdZdZdZdZdZy)raContext 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|SrCrrs rrzExitStack.__enter__(src
|ddu}tjd

fd}d}d}|jr:|jj\}}|sJ	||rd}d}d}|jr:|r	|dj}	|d|xr|S#tj}||d|dd}|}YUxYw#t
$r	|d_wxYw)NrcL	|j}|||ury|ur		||_y|}#rC__context__new_excold_excexc_context	frame_excs   r_fix_exception_contextz2ExitStack.__exit__.<locals>._fix_exception_context1B%11&+*@)+#*G&rFTNNNrrrrrri)rexc_detailsreceived_excrsuppressed_exc
pending_raisercbnew_exc_details	fixed_ctxrs          @rr%zExitStack.__exit__+s"1~T1LLN1%		* 
""..224KGRN

.{#%)N$)M"4K""
(N66	!!n$..
."%,,.&q'9;q>J $
-!
-6A*
sB2B:)B7:Cc*|jdddyz%Immediately unwind the context stack.N)r%rs rrzExitStack.close\s

dD$'rN)r.r/r0r1rr%rrrrrrs//b(rrcZeZdZdZedZedZdZdZdZ	dZ
dZd	Zd
Z
y)raAsync context manager for dynamic management of a stack of exit
    callbacks.

    For example:
        async with AsyncExitStack() as stack:
            connections = [await stack.enter_async_context(get_connection())
                for i in range(5)]
            # All opened connections will automatically be released at the
            # end of the async with statement, even if attempts to open a
            # connection later in the list raise an exception.
    ct||SrCrrs  r_create_async_exit_wrapperz)AsyncExitStack._create_async_exit_wrapperorrcfd}|S)Nc2Kid{y7wrCrrs   rrz>AsyncExitStack._create_async_cb_wrapper.<locals>._exit_wrapperusD)D)))srrs``` r_create_async_cb_wrapperz'AsyncExitStack._create_async_cb_wrapperss	*rcKt|}	|j}|j}||d{}|j|||S#t$r(t	d|j
d|jddwxYw7Lw)zEnters the supplied async context manager.

        If successful, also pushes its __aexit__ method as a callback and
        returns the result of the __aenter__ method.
        rrzC' object does not support the asynchronous context manager protocolN)rWr8r;rrr/r0_push_async_cm_exitrs      renter_async_contextz"AsyncExitStack.enter_async_contextys2h	'^^FMME
bz!  U+

	'a/q1A1A0BCTU"&
'	'"s%BABA?B1A<<Bct|}	|j}|j|||S#t$r|j	|dY|SwxYw)a#Registers a coroutine function with the standard __aexit__ method
        signature.

        Can suppress exceptions the same way __aexit__ method can.
        Also accepts any object with an __aexit__ method (registering a call
        to the method instead of the object itself).
        F)rWr;rrrrs    rpush_async_exitzAsyncExitStack.push_async_exits\:	8",,K

$$T;7	2$$T51	2s-AAcd|j|g|i|}||_|j|d|S)zfRegisters an arbitrary coroutine function and arguments.

        Cannot suppress exceptions.
        F)rrrrs     rpush_async_callbackz"AsyncExitStack.push_async_callbacks?
655hNNN
%-
!  6rcFK|jdddd{y7wr)r;rs rrzAsyncExitStack.aclosesnnT4...s!!cL|j||}|j|dy)zLHelper to correctly register coroutine function to __aexit__
        method.FN)rrrs    rrz"AsyncExitStack._push_async_cm_exits&77GD
  6rcK|SwrCrrs rr8zAsyncExitStack.__aenter__sr9cK|ddu}tjdfd}d}d}|jrH|jj\}}	|r||}n
||d{}|rd}d}d}|jrH|r	|dj}
|d|xr|S76#tj}	||	d|dd}|	}YWxYw#t
$r
|d_wxYww)NrrcL	|j}|||ury|ur		||_y|}#rCrrs   rrz8AsyncExitStack.__aexit__.<locals>._fix_exception_contextrrFTrr)rrrrrrrrcb_suppressrrrs           @rr;zAsyncExitStack.__aexit__s"1~T1LLN1%		* 
""..224KGR
."$k"2K(*K(8"8K%)N$)M"4K""$
(N66	!!n$..+#9
."%,,.&q'9;q>J $
-!
-6A*
sNAC$B%B&B2C$?C$CC$B)C	C$C!!C$N)r.r/r0r1rrrrrrrrr8r;rrrrrbsR
''
$$/73/rrc0eZdZdZddZdZdZdZdZy)	raOContext manager that does no additional processing.

    Used as a stand-in for a normal context manager, when a particular
    block of code is only sometimes used with a normal context manager:

    cm = optional_cm if condition else nullcontext()
    with cm:
        # Perform operation, using optional_cm if condition is True
    Nc||_yrCenter_result)rrs  rrYznullcontext.__init__s
(rc|jSrCr
rs rrznullcontext.__enter__s   rcyrCrrexcinfos  rr%znullcontext.__exit__rrc"K|jSwrCr
rs rr8znullcontext.__aenter__s   rcKywrCrrs  rr;znullcontext.__aexit__s	r<rC)	r.r/r0r1rYrr%r8r;rrrrrs )!
!
rrc"eZdZdZdZdZdZy)rzHNon thread-safe context manager to change the current working directory.c ||_g|_yrC)path_old_cwd)rrs  rrYzchdir.__init__s	
rc|jjtjtj|j
yrC)rrosgetcwdrrrs rrzchdir.__enter__s*

RYY[)
rc^tj|jjyrC)rrrrrs  rr%zchdir.__exit__s
""$%rNrrrrrrsR&rr)#r1r4rrr'collectionsr	functoolsrtypesrr__all__ABCrr
objectrrNrSr]ror	rr
rrrrrrrrrrrrr<module>r#s=:
	
*SWW,#''.v.
F
 ??0AF AFFAG AGHBB$2"*"4<,<$
o
 o$%$NQ9Q9jA( 6A(JH/^%@H/V
(*E
6&"&r