Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
3 \j3ã@sèdZddlZddlZddlZddlmZddlmZddddd d d d gZGd d„dej ƒZ Gdd„de ƒZ Gdd„de e ƒZ dd„ZGdd„de ƒZGdd„de ƒZGdd „d eƒZGdd „d eƒ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__..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_cmc Cs.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(): try: yield finally: This makes this: with some_generator() as : equivalent to this: try: = finally: cs tˆ||ƒS)N)r')r"r#)r$r rÚhelper�szcontextmanager..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(.open()) as f: is equivalent to this: f = .open() try: 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 Îs c@seZdZdZdZdS)r zCContext manager for temporarily redirecting stderr to another file.ÚstderrN)rrrrr@r r r rr Þsc@s(eZdZdZdd„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 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„Z dS)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.._exit_wrapperN)Ú__self__Úpush)r rOrPrQr )rOrPrÚ _push_cm_exitszExitStack._push_cm_exitc CsDt|ƒ}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.._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__.._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 r rr r r rÚs$  I"