U cf @sddlmZmZmZmZmZmZer0ddlmZddl m Z ddl m Z ddl mZerdddlmZdZGdd d ZGd d d Zee ed d dZee eddddZeeddddZdS)) TYPE_CHECKINGAnyDictIterableListSequence)ConsoleRenderable) get_console)Segment)DEFAULT_TERMINAL_THEMEz
{code}
c@sFeZdZdZeeddddZeeeeeeeefdddZ dS) JupyterRenderablez)A shim to write html to Jupyter notebook.N)htmltextreturncCs||_||_dS)N)rr)selfrrrF/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/rich/jupyter.py__init__szJupyterRenderable.__init__)includeexcludekwargsrc sF|j|jd}r(fdd|D}rBfdd|D}|S)Nz text/plainz text/htmlcsi|]\}}|kr||qSrr.0kvrrr sz7JupyterRenderable._repr_mimebundle_..csi|]\}}|kr||qSrrrrrrr s)rritems)rrrrdatarrrr_repr_mimebundle_s z#JupyterRenderable._repr_mimebundle_) __name__ __module__ __qualname____doc__strrrrrr#rrrrr s r c@s:eZdZdZdZdeeeeeeeefdddZ dS) JupyterMixinz@Add to an Rich renderable to make it render in Jupyter notebook.rr)rrrrrc  slt}t|||j}t|}||}||d}rNfdd|D}rhfdd|D}|S)Nrcsi|]\}}|kr||qSrrrrrrr5sz2JupyterMixin._repr_mimebundle_..csi|]\}}|kr||qSrrrrrrr7s)r listrenderoptions_render_segments_render_bufferr ) rrrrconsolesegmentsrrr!rr"rr#)s  zJupyterMixin._repr_mimebundle_N) r$r%r&r' __slots__rr(rrr#rrrrr)$s r))r0rc Csttddd}g}|j}t}t|D]b\}}}|r8q(||}|r||}|rdd|d|dn|}|jrd|jd|d }||q(d |} tj | d } | S) N)rrcSs|ddddddS)z Escape html.&z&z>)replace)rrrrescape<sz _render_segments..escapez zz z)code) r(appendr r simplifyget_html_stylelinkjoinJUPYTER_HTML_FORMATformat) r0r6 fragmentsappend_fragmentthemerstylecontrolruler8rrrrr-;s"    r-N)r0rrcCsDt|}t||}zddlm}||Wntk r>YnXdS)zRender segments to Jupyter.r)displayN)r-r IPython.displayrFModuleNotFoundError)r0rrjupyter_renderableipython_displayrrrrFTs   rF)argsrrcOst}|j||S)zProxy for Console print.)r print)rKrr/rrrrLbsrL)typingrrrrrrpip._vendor.rich.consolerr7r segmentr terminal_themer r>r r)r(r-rFrLrrrrs