"Te ddlmZmZmZmZmZmZerddlmZddl m Z ddl m Z ddl mZerddlmZdZGdd ZGd d Zd ee d efdZd ee ded dfdZdeded dfdZy)) TYPE_CHECKINGAnyDictIterableListSequence)ConsoleRenderable) get_console)Segment)DEFAULT_TERMINAL_THEMEz
{code}
c ReZdZdZdededdfdZdeedeed edeeeffd Z y) JupyterRenderablez)A shim to write html to Jupyter notebook.htmltextreturnNc ||_||_y)N)rr)selfrrs ./usr/lib/python3/dist-packages/rich/jupyter.py__init__zJupyterRenderable.__init__s  includeexcludekwargsc |j|jd}|r(|jDcic] \}}||vs ||}}}|r(|jDcic] \}}||vs ||}}}|Scc}}wcc}}wN)z text/plainz text/html)rritems)rrrrdatakvs r_repr_mimebundle_z#JupyterRenderable._repr_mimebundle_sy#iidii@ '+zz|DVaqG|AqDDDD '+zz|HVaq7GAqDHDH EHs A0A0 A6&A6) __name__ __module__ __qualname____doc__strrrrrr!rrrrsT3S}/7}HK c3hrrc FeZdZdZdZdddeedeededeeeff d Z y ) JupyterMixinz@Add to an Rich renderable to make it render in Jupyter notebook.r'rr rrrrc ft}t|j||j}t |}|j |}||d}|r(|j D cic] \} } | |vs | | }} } |r(|j D cic] \} } | |vs | | }} } |Scc} } wcc} } wr)r listrenderoptions_render_segments_render_bufferr) rrrrconsolesegmentsrrrrr s rr!zJupyterMixin._repr_mimebundle_)s -tW__=>)%%h/"6 '+zz|DVaqG|AqDDDD '+zz|HVaq7GAqDHDH EHs& B'3B' B-B-N) r"r#r$r% __slots__rr&rrr!r'rrr)r)$sMJI!##  c3h rr)r1rc|dtdtfd}g}|j}t}tj|D]X\}}}|r ||}|r=|j |}|r d|d|dn|}|j rd|j d|d }||Zd j|} tj| } | S) Nrrcf|jddjddjddS)z Escape html.&z&z>)replace)rs rescapez _render_segments..escape<s-||C)11#v>FFsFSSrz zz z)code) r&appendr r simplifyget_html_stylelinkjoinJUPYTER_HTML_FORMATformat) r1r9 fragmentsappend_fragmentthemerstylecontrolruler;rs rr.r.;sTSTSTI&&O "E ' 0 0 : eW  d| ''.D<@]4&4&8dDzz"5::,.@dK  779 D  % %4 % 0D KrrNcnt|}t||} ddlm}||y#t$rYywxYw)zRender segments to Jupyter.r)displayN)r.rIPython.displayrJModuleNotFoundError)r1rrjupyter_renderableipython_displays rrJrJTs> H %D*46 >*+    s ( 44argsrc:t}|j|i|S)zProxy for Console print.)r print)rOrr0s rrQrQbsmG 7==$ )& ))r)typingrrrrrr rich.consoler r:r segmentr terminal_themer rArr)r&r.rJrQr'rrrVsEE.2. $.x0S2  hw'  s  t  ****r