}BFjdZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z ddlmZdd lmZGd d Zdd ZddededefdZdS)z IO related utilities. N)Path)warn)undoc) CapturedIOcapture_output)StringIO)UnioncVeZdZdZddeeefdedefdZdZd Z d Z d Z d Z d S)TeezA class to duplicate an output stream to stdout/err. This works in a manner very similar to the Unix 'tee' command. When the object is closed or deleted, it closes the original file given to it for duplication. wstdout file_or_namemodechannelc<|dvrtd|zt|drt|dr||_nd|vrdnd}t||||_||_t t ||_tt ||d |_ dS) aNConstruct a new Tee object. Parameters ---------- file_or_name : filename or open filehandle (writable) File that will be duplicated mode : optional, valid mode for open(). If a filename was give, open with this mode. channel : str, one of ['stdout', 'stderr'] )rstderrzInvalid channel spec %swriteseekbNutf-8encodingF) ValueErrorhasattrfileopenrgetattrsysostreamsetattr_closed)selfrrrrs >C:\PYTHON\_runtimes\venv\Lib\site-packages\IPython/utils/io.py__init__z Tee.__init__#s . . .6@AA A < ) ) DglF.K.K D$DII"d{{ttH\4(CCCDI sG,, Wd### c|tt|j|j|jd|_dS)z'Close the file and restore the channel.TN)flushr!rrr rcloser"r#s r$r)z Tee.close;sB T\4<000  r&c|j||j||jdS)zWrite data to both channels.N)rrr r()r#datas r$rz Tee.writeBsF  4    r&cj|j|jdS)zFlush both channels.N)rr(r r*s r$r(z Tee.flushHs.  r&c@|js|dSdS)N)r"r)r*s r$__del__z Tee.__del__Ms'|  JJLLLLL  r&cdS)NFr*s r$isattyz Tee.isattyQsur&N)r r) __name__ __module__ __qualname____doc__r strr r%r)rr(r/r2r1r&r$r r sU3=%9SV0  r&r c|ddddd}d}||vr t|dz}|s|}nV#t$r|r|}t dYn7t $r+||vr|}t nYnwxYw||v||S)aAsks a question and returns a boolean (y/n) answer. If default is given (one of 'y','n'), it is used if the user input is empty. If interrupt is given (one of 'y','n'), it is used if the user presses Ctrl-C. Otherwise the question is repeated until an answer is given. An EOF is treated as the default answer. If there is no default, an exception is raised to prevent infinite loops. Valid answers are: y/yes/n/no (match is not case sensitive).TF)ynyesnoN  )keysinputlowerKeyboardInterruptprintEOFError)promptdefault interruptanswersanss r$ ask_yes_norJTsE%88G C W\\^^ # # s ##))++C       $KKKKK   ',,..((  W\\^^ # # 3<s(A B)1BB.pysrcextreturnctj|d}tt|dd5}|||dddn #1swxYwY|S)aMake a temporary python file, return filename and filehandle. Parameters ---------- src : string or list of strings (no need for ending newlines if list) Source code to be written to the file. ext : optional, string Extension for the generated file. Returns ------- (filename, open filehandle) It is the caller's responsibility to close the open file and unlink it. rr rrN)tempfilemkstemprrrr()rLrMfnamefs r$ temp_pyfilerTvs  S ! !! $E d5kk3 1 1 1Q     Ls*A00A47A4)NN)rK)r6atexitosrrPpathlibrwarningsrIPython.utils.decoratorsrcapturerrior typingr r rJr7rTr1r&r$r]s ******////////::::::::xDSsSr&