Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyc

ó
“tÆ_c	@s>dZddlZddlZddlZddlmZddlmZddddd	d
ddd
g	Zedg7Zej	d d+kr—ej
Znejde
fid,d6ƒZd„Zd„Zdefd„ƒYZd	e
fd„ƒYZdefd„ƒYZd„Zde
fd„ƒYZde
fd„ƒYZdefd„ƒYZdefd„ƒYZd
e
fd „ƒYZej	d!dkZer¯d"„Zd#„Znd$„Zd%„Zydd&lmZWnek
rîeZ n
Xd'„Z d
e
fd(„ƒYZ!de!fd)„ƒYZ"defd*„ƒYZ#dS(-sAcontextlib2 - backports and enhancements to the contextlib moduleiÿÿÿÿN(tdeque(twrapstcontextmanagertclosingtnullcontexttAbstractContextManagertContextDecoratort	ExitStacktredirect_stdouttredirect_stderrtsuppresstContextStackiiitABCt	__slots__cCsB||krdS|j|ƒx|jD]}t||ƒq'W|S(N(tappendt	__bases__t_classic_mro(tCtresulttB((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRs
cGsŠy
|j}Wn&tk
r5tt|gƒƒ}nXxM|D]E}x<|D]0}||jkrJ|j|dkrvtSPqJqJWtSq=WtS(N(t__mro__tAttributeErrorttupleRt__dict__tNonetNotImplementedtTrue(RtmethodstmrotmethodR((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt_check_methods$s



cBs8eZdZd„Zejd„ƒZed„ƒZRS(s,An abstract base class for context managers.cCs|S(s0Return `self` upon entering the runtime context.((tself((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt	__enter__8scCsdS(s9Raise any exception triggered within the runtime context.N(R(Rtexc_typet	exc_valuet	traceback((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt__exit__<scCs |tkrt|ddƒStS(s<Check whether subclass is considered a subclass of this ABC.R R$(RRR(tclsR((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt__subclasshook__As(	t__name__t
__module__t__doc__R tabctabstractmethodR$tclassmethodR&(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR5s	cBs)eZdZd„Zd„Zd„ZRS(sJA base class or mixin that enables context managers to work as decorators.cCstjdtƒ|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
        s2refresh_cm was never added to the standard library(twarningstwarntDeprecationWarningt_recreate_cm(R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt
refresh_cmLs
	cCs|S(s6Return 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((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR0]s
cs"tˆƒ‡‡fd†ƒ}|S(Ncs$ˆjƒˆ||ŽSWdQXdS(N(R0(targstkwds(tfuncR(sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pytinnerjs
(R(RR4R5((R4RsH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt__call__is(R'R(R)R1R0R6(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRIs		t_GeneratorContextManagercBs2eZdZd„Zd„Zd„Zd„ZRS(s%Helper for @contextmanager decorator.cCsl|||Ž|_||||_|_|_t|ddƒ}|dkr_t|ƒj}n||_dS(NR)(tgenR4R2R3tgetattrRttypeR)(RR4R2R3tdoc((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt__init__tscCs|j|j|j|jƒS(N(t	__class__R4R2R3(R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR0‚scCs5yt|jƒSWntk
r0tdƒ‚nXdS(Nsgenerator didn't yield(tnextR8t
StopIterationtRuntimeError(R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR ˆs
cCs|dkrAyt|jƒWntk
r1dSXtdƒ‚n»|dkrY|ƒ}ny&|jj|||ƒtdƒ‚Wnztk
r›}||k	Stk
rÙ}||krºtStrÓ|j|krÓtS‚n#t	j
ƒd|k	rü‚qünXdS(Nsgenerator didn't stops#generator didn't stop after throw()i(RR>R8R?R@tthrowtFalset_HAVE_EXCEPTION_CHAININGt	__cause__tsystexc_info(RR:tvalueR#texc((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR$Žs,

(R'R(R)R<R0R R$(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR7qs
			cstˆƒ‡fd†ƒ}|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>

    cstˆ||ƒS(N(R7(R2R3(R4(sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pythelperÕs(R(R4RI((R4sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR¹scBs)eZdZd„Zd„Zd„ZRS(s2Context 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(tthing(RRJ((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR<ìscCs|jS(N(RJ(R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR ïscGs|jjƒdS(N(RJtclose(RRF((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR$òs(R'R(R)R<R R$(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRÛs		t_RedirectStreamcBs)eZdZd„Zd„Zd„ZRS(cCs||_g|_dS(N(t_new_targett_old_targets(Rt
new_target((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR<ús	cCs9|jjtt|jƒƒtt|j|jƒ|jS(N(RNRR9REt_streamtsetattrRM(R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR ÿscCs tt|j|jjƒƒdS(N(RQRERPRNtpop(Rtexctypetexcinsttexctb((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR$sN(R'R(RRPR<R R$(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRLös		cBseZdZdZRS(sAContext 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)
    tstdout(R'R(R)RP(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRscBseZdZdZRS(sCContext manager for temporarily redirecting stderr to another file.tstderr(R'R(R)RP(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR	scBs)eZdZd„Zd„Zd„ZRS(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
    cGs
||_dS(N(t_exceptions(Rt
exceptions((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR<)scCsdS(N((R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR ,scCs|dk	ot||jƒS(N(Rt
issubclassRX(RRSRTRU((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR$/s
(R'R(R)R<R R$(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR
s			ics‡fd†}|S(NcsNx>|j}||krdS|dks4|ˆkr8Pn|}q||_dS(N(t__context__R(tnew_exctold_exctexc_context(t	frame_exc(sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt_fix_exception_context@s		((R_R`((R_sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt_make_context_fixer?s
cCsCy|dj}|d‚Wn!tk
r>||d_‚nXdS(Ni(R[t
BaseException(texc_detailst	fixed_ctx((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt_reraise_with_existing_contextOs


cCsd„S(NcSsdS(N(R(R\R]((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt<lambda>[s((R_((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRaZscBs|\}}}ddUdS(Ns!raise exc_type, exc_value, exc_tb((RcR!R"texc_tb((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRe_s(tInstanceTypecCs#t|ƒ}|tkr|jS|S(N(R:RhR=(tobjtobj_type((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt	_get_typekscBs_eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„ZRS(
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

    cCstƒ|_dS(N(Rt_exit_callbacks(R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR<scCs+t|ƒƒ}|j|_tƒ|_|S(s?Preserve the context stack by transferring it to a new instance(R:RlR(Rt	new_stack((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pytpop_all‚scs,‡‡fd†}ˆ|_|j|ƒdS(s:Helper to correctly register callbacks to __exit__ methodscs
ˆˆ|ŒS(N((Rc(tcmtcm_exit(sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt
_exit_wrapper‹sN(t__self__tpush(RRoRpRq((RoRpsH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt
_push_cm_exit‰s	cCsQt|ƒ}y
|j}Wn!tk
r<|jj|ƒnX|j||ƒ|S(sRegisters 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)
        (RkR$RRlRRt(Rtexitt_cb_typetexit_method((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRss


cs/‡‡‡fd†}ˆ|_|j|ƒˆS(s\Registers an arbitrary callback and arguments.

        Cannot suppress exceptions.
        csˆˆˆŽdS(N((R!RHttb(R2tcallbackR3(sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRq©s(t__wrapped__Rs(RRyR2R3Rq((R2RyR3sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRy¤s	
cCs8t|ƒ}|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.
        (RkR$R Rt(RRot_cm_typet_exitR((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt
enter_context±s
	cCs|jdddƒdS(s$Immediately unwind the context stackN(R$R(R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRK¾scCs|S(N((R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR Âsc	GsÐ|ddk	}tjƒd}t|ƒ}t}t}xx|jr²|jjƒ}y%||Œrwt}t}d}nWq;tjƒ}||d|dƒt}|}q;Xq;W|rÆt|ƒn|oÏ|S(Nii(NNN(	RRERFRaRBRlRRRRe(	RRctreceived_excR_R`tsuppressed_exct
pending_raisetcbtnew_exc_details((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR$Ås(

(R'R(R)R<RnRtRsRyR}RKR R$(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRss					
	
		cBs2eZdZd„Zd„Zd„Zd„ZRS(s+Backwards compatibility alias for ExitStackcCs'tjdtƒtt|ƒjƒdS(Ns*ContextStack has been renamed to ExitStack(R-R.R/tsuperRR<(R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR<çs	cCs
|j|ƒS(N(Rs(RRy((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt
register_exitìscOs|j|||ŽS(N(Ry(RRyR2R3((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pytregisterïscCs
|jƒS(N(Rn(R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pytpreserveòs(R'R(R)R<R„R…R†(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRäs
			cBs,eZdZdd„Zd„Zd„ZRS(sMContext 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
    cCs
||_dS(N(tenter_result(RR‡((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR<ÿscCs|jS(N(R‡(R((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR scGsdS(N((Rtexcinfo((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyR$sN(R'R(R)RR<R R$(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyRös	(ii(($R)R*RER-tcollectionsRt	functoolsRt__all__tversion_infoRt_abc_ABCtABCMetatobjectRRRRR7RRRLRR	R
RCRaRettypesRhtImportErrorR:RkRRR(((sH/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/contextlib2.pyt<module>sL	
	
	(H	"			

	q
Back to Directory File Manager