wL iXdZddlZddlmZGddZGddZGdd Zy) zIO capturing utilities.N)StringIOcReZdZd dZdZdZddZdZdZdZ d Z d Z d Z d Z y) RichOutputNcT|xsi|_|xsi|_|xsi|_||_yNdatametadata transientupdate)selfr r r r s [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/IPython/utils/capture.py__init__zRichOutput.__init__s*JB  B "b cxddlm}||j|j|j|j y)Nr)publish_display_datar)IPython.displayrr r r r )r rs rdisplayzRichOutput.displays'8$))dmm'+~~dkk Krc||jvry|j|}||jvr||j|fS|Srr r )r mimer s r _repr_mime_zRichOutput._repr_mime_sC tyy yy 4== t,, ,Krc2|j|jfSrr)r includeexcludes r_repr_mimebundle_zRichOutput._repr_mimebundle_%syy$--''rc$|jdS)Nz text/htmlrr s r _repr_html_zRichOutput._repr_html_( ,,rc$|jdS)Nz text/latexrrs r _repr_latex_zRichOutput._repr_latex_+ --rc$|jdS)Nzapplication/jsonrrs r _repr_json_zRichOutput._repr_json_.s 233rc$|jdS)Nzapplication/javascriptrrs r_repr_javascript_zRichOutput._repr_javascript_1s 899rc$|jdS)Nz image/pngrrs r _repr_png_zRichOutput._repr_png_4r!rc$|jdS)Nz image/jpegrrs r _repr_jpeg_zRichOutput._repr_jpeg_7r$rc$|jdS)Nz image/svg+xmlrrs r _repr_svg_zRichOutput._repr_svg_:s00r)NNNF)NN)__name__ __module__ __qualname__rrrrr r#r&r(r*r,r.rrrrs: K (-.4:-.1rrcXeZdZdZd dZdZedZedZedZ dZ e Z y) CapturedIOaSimple object for containing captured stdout/err and rich display StringIO objects Each instance `c` has three attributes: - ``c.stdout`` : standard output as a string - ``c.stderr`` : standard error as a string - ``c.outputs``: a list of rich display outputs Additionally, there's a ``c.show()`` method which will print all of the above in the same order, and can be invoked simply via ``c()``. Nc6||_||_|g}||_yr)_stdout_stderr_outputs)r stdoutstderroutputss rrzCapturedIO.__init__Ks!  ?G rc|jSr)r9rs r__str__zCapturedIO.__str__Rs {{rcP|jsy|jjS)zCaptured standard output)r6getvaluers rr9zCapturedIO.stdoutU!||||$$&&rcP|jsy|jjS)zCaptured standard errorr?)r7r@rs rr:zCapturedIO.stderr\rArcR|jDcgc] }tdi|c}Scc}w)a A list of the captured rich display outputs, if any. If you have a CapturedIO object ``c``, these can be displayed in IPython using:: from IPython.display import display for o in c.outputs: display(o) r2)r8rr kargss rr;zCapturedIO.outputscs$37--A$e$AAAs$cttjj|jtjj|jtjj tjj |j D]}t di|jy)z0write my output to sys.stdout/err as appropriateNr2)sysr9writer:flushr8rrrDs rshowzCapturedIO.showpsu % %  ]] *E    ' ' ) *rr) r/r0r1__doc__rr=propertyr9r:r;rJ__call__r2rrr4r4>s[  '' ''  B B*Hrr4c0eZdZdZdZdZdZddZdZdZ y)capture_outputz(context manager for capturing stdout/errTc<||_||_||_d|_yr)r9r:rshell)r r9r:rs rrzcapture_output.__init__s    rcddlm}ddlm}ddlm}t j|_t j|_ |jr&||_ |jd|_ d|_ dx}x}}|jrtx}t _|jrtx}t _ |jr|jj|_ ||j_|jjj }t j"|_||j|t _t'|||S)Nr) get_ipython)CapturingDisplayPublisher)CapturingDisplayHookF)rQr;)IPython.core.getipythonrSIPython.core.displaypubrTIPython.core.displayhookrUrGr9 sys_stdoutr: sys_stderrrrQsave_display_pubr display_pubr; displayhooksave_display_hookr4)r rSrTrUr9r:r;s r __enter__zcapture_output.__enter__s7EA**** <<$DJzz!(,%$ $(((' ;;"** ,FSZ ;;"** ,FSZ <<$(JJ$:$:D !%>%@DJJ "jj,,44G%(__D "2;BDCO&&'22rc|jt_|jt_|j r>|j r1|j|j _|jt_ yyyr) rYrGr9rZr:rrQr[r\r^r])r exc_type exc_value tracebacks r__exit__zcapture_output.__exit__sK__ __ <rfs0  +1+1\;;|.5.5r