U cf#@sddlmZmZmZmZddlmZmZddlm Z m Z m Z m Z ddl mZddlmZddlmZddlmZmZmZdd lmZGd d d eZed krdd lmZddlmZddlm Z ddl!m"Z"ddl#m$Z$e$ddgdZ%e%j&dddde%j&ddde%j&dddde%'d d!d"e%'d#d$d%e%'d&d'd(e%'d)d*d+d,Z(e"e(d-d.dd/Z)ed0Z*ed1ddd2Z+e+j,d3d4d5Z-e-j,d6d7d5Z.e.,ed8e)e.,ed9e e*dd:e-j,d;de2e/,ed?e%e Ze3e+d@S)A)IteratorListOptionalTuple) loop_first loop_last)ConsoleConsoleOptionsRenderableType RenderResult) JupyterMixin) Measurement)Segment)Style StyleStack StyleType)Styledc @seZdZdZddddddeeeeeeddd d Zddddd eeeeeeeedd d dZ ddddddZ ddddddZ dS)TreeaA renderable for a tree structure. Args: label (RenderableType): The renderable or str for the tree label. style (StyleType, optional): Style of this tree. Defaults to "tree". guide_style (StyleType, optional): Style of the guide lines. Defaults to "tree.line". expanded (bool, optional): Also display children. Defaults to True. highlight (bool, optional): Highlight renderable (if str). Defaults to False. treez tree.lineTF)style guide_styleexpanded highlight hide_rootN)labelrrrrrreturncCs.||_||_||_g|_||_||_||_dSN)rrrchildrenrrr)selfrrrrrrr C/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/rich/tree.py__init__s z Tree.__init__rrrr)rrrrrrcCsLt||dkr|jn||dkr"|jn|||dkr4|jn|d}|j||S)a3Add a child tree. Args: label (RenderableType): The renderable or str for the tree label. style (StyleType, optional): Style of this tree. Defaults to "tree". guide_style (StyleType, optional): Style of the guide lines. Defaults to "tree.line". expanded (bool, optional): Also display children. Defaults to True. highlight (Optional[bool], optional): Highlight renderable (if str). Defaults to False. Returns: Tree: A new child Tree, which may be further modified. Nr#)rrrrrappend)rrrrrrnoder r r!add)s zTree.addr r r )consoleoptionsrc#sg}|j}|j}t}|j}t}||jddp6|} td\} } } } ddddgtt ttdfd d }|| | g}|t t |gt ||j}t ||j }td d d }d }|r|}zt|\}}WnVtk r2||r*|dj p |} || | |d<||YqYnX|||r\|| |dj pT||d<|j||j} |j||j }||jrdndd}|jt|j|jjtdd|D|jddjdk d}|d kr|jsXt|D]h\}}|rj||j|dEdH|EdH|V|r|r||r<| n| |dj pL||d<q|jr|jr||rp| n| |dj p||d<||t|jdkr| n| | | ||j | ||j|t t |j|d7}qdS)N)default) z| z+-- z`-- )r,u│ u ├── u └── )r,u┃ u ┣━━ u ┗━━ )r,u║ u ╠══ u ╚══ )indexrrcsHjr|}n.|jrdn |jr$dnd}jr4dn||}||S)z.Make a Segment for a level of the guide lines.rr) ascii_onlybold underline2legacy_windows)r-rlineZguideZ ASCII_GUIDESZ TREE_GUIDES_Segmentr(r r! make_guide]s  z)Tree.__rich_console__..make_guideF)r0r1rr.rcss|] }|jVqdSr) cell_length).0levelr r r! sz(Tree.__rich_console__..)widthrheight)pad) post_style)!popr$rr3 get_stylernullrrangeintiterrrrnext StopIterationcurrentr render_linesrrupdate max_widthsumrjustifyr apply_stylebackground_stylerrlenpush)rr'r(stackr@rQnew_linerAZ null_stylerSPACECONTINUEZFORKZENDr6ZlevelsZguide_style_stack style_stackZremove_guide_stylesdepthZ stack_nodelastr%rprefixZrenderable_linesfirstr3r r4r!__rich_console__Hs            zTree.__rich_console__rcCst|gg}|j}|j}d}d}tj}d} |r|} z t| } Wn tk r`| d8} Yq*YnX|| |||| j\} } | d}t| ||}t| ||}| j r*| j r*|t| j | d7} q*t||S)Nrrr+) rEr@r$rgetrFrGrmaxrr)rr'r(rRr@rQminimummaximummeasurer:Z iter_treerZ min_measureZ max_measureindentr r r!__rich_measure__s.     zTree.__rich_measure__) __name__ __module__ __qualname____doc__r rboolr"rr&r[rbr r r r!r sF   ar__main__)Group)Markdown)Panel)Syntax)Tabler)dim) row_stylesZReleasedcyanT)rno_wrapZTitlemagenta)rz Box Officerightgreen)rMrz Dec 20, 2019z Star Wars: The Rise of Skywalkerz $952,110,690z May 25, 2018zSolo: A Star Wars Storyz $393,151,347z Dec 15, 2017z!Star Wars Ep. V111: The Last Jediz$1,332,539,889z Dec 16, 2016zRogue One: A Star Wars Storyz$1,332,439,889zmclass Segment(NamedTuple): text: str = "" style: Optional[Style] = None is_control: bool = False pythonmonokai)theme line_numbersz=### example.md > Hello, World! > > Markdown _all_ the things u🌲 [b green]Rich Tree)rrz:file_folder: Renderablesred)rz!:file_folder: [bold yellow]Atomiczuu greenu 📄 Syntaxu 📄 Markdown) border_stylez&:file_folder: [bold magenta]Containersz bold magentaz Just a panelu 📄 Panelsu📄 [b magenta]TableN)4typingrrrr_looprrr'r r r r jupyterr r`rsegmentrrrrrstyledrrrcpip._vendor.rich.consoleriZpip._vendor.rich.markdownrjZpip._vendor.rich.panelrkZpip._vendor.rich.syntaxrlpip._vendor.rich.tablermtable add_columnadd_rowcodesyntaxmarkdownrootr&r%Z simple_nodeZcontainers_noderfitpanelprintr r r r!sV    9