o 7]h!@sddlmZmZddlmZmZddlmZddlm Z ddl m Z m Z ddl mZmZddlmZdd lmZmZdd lmZerNdd lmZmZmZmZGd d d e ZedkrddlmZeZddl mZddlmZmZedddeddZ e!e!e dSdS))Optional TYPE_CHECKING)BoxROUNDED) AlignMethod) JupyterMixin) Measurementmeasure_renderables)PaddingPaddingDimensions) StyleType)TextTextType)Segment)ConsoleConsoleOptionsRenderableType RenderResultc @sJeZdZdZefddddddddddddd d d d ed eed edeededee de de de dee dee de de ddfddZ eefdddddddddd d d d ed eed edeededee de de dee de ddfddZedeefddZedeefd d!Z " # $ %  &d,d'd(Z " # $ %  )d-d*d+ZdS).PanelaA console renderable that draws a border around its contents. Example: >>> console.print(Panel("Hello, World!")) Args: renderable (RenderableType): A console renderable object. box (Box, optional): A Box instance that defines the look of the border (see :ref:`appendix_box`. Defaults to box.ROUNDED. safe_box (bool, optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True. expand (bool, optional): If True the panel will stretch to fill the console width, otherwise it will be sized to fit the contents. Defaults to True. style (str, optional): The style of the panel (border and contents). Defaults to "none". border_style (str, optional): The style of the border. Defaults to "none". width (Optional[int], optional): Optional width of panel. Defaults to None to auto-detect. height (Optional[int], optional): Optional height of panel. Defaults to None to auto-detect. padding (Optional[PaddingDimensions]): Optional padding around renderable. Defaults to 0. highlight (bool, optional): Enable automatic highlighting of panel title (if str). Defaults to False. NcenterTnone)rrF) title title_alignsubtitlesubtitle_alignsafe_boxexpandstyle border_stylewidthheightpadding highlight renderablerboxrrrrrrrrr r!r"r#returnc CsX||_||_||_||_||_||_||_||_| |_| |_ | |_ | |_ | |_ ||_ dS)N)r$r%rrrrrrrrr r!r"r#)selfr$r%rrrrrrrrr r!r"r#r(8/usr/lib/python3/dist-packages/pip/_vendor/rich/panel.py__init__&s zPanel.__init__) rrrrrrrr r"c Cs |||||||||| | | dd S)z2An alternative constructor that sets expand=False.F) rrrrrrrr r"rr() clsr$r%rrrrrrrr r"r(r(r)fitGsz Panel.fitcC^|jr-t|jtrt|jn|j}d|_|jdd|_d|_ | | d|SdSN  Tr) r isinstancestrr from_markupcopyendplainreplaceno_wrap expand_tabspad)r' title_textr(r(r)_titleg  z Panel._titlecCr-r.) rr2r3rr4r5r6r7r8r9r:r;)r' subtitle_textr(r(r) _subtitlewr>zPanel._subtitleconsoleroptionsrrccst|j}t|rt|j|n|j}||j}|||j}|jdur*|j nt |j |j}|j dur9|j n|j }|j j ||d} |j} | durN|| _|jrU|dn |j|||ddj} |jpi|jpid} | rp| d8} | durt |j dt| | jd} | d}|j| | |jd} |j|| |d}t| j|}t| j|}t}| dus|dkrt| |dg|Vn(| j|j|d| j dt| j!| j |V|"| EdHt| j | j#|V|V|D]}|V|EdH|V|Vq|j$}|dur||_|dus|dkrt| %|dg|Vn(|j|j&|d| j'dt| j(| j'|V|"|EdHt| j'| j)|V|VdS)N)safe)rB)r r!r#)r) character)*r unpackr"anyr$ get_stylerrr max_widthminrr% substituter=rmeasure update_widthmaximumr!maxcell_lenupdater# render_linesrmid_left mid_rightlineget_topalignrtoptop_leftrender top_rightr@ get_bottomrbottom bottom_left bottom_right)r'rArB_paddingr$rrr rr%r< child_width child_height child_optionslines line_startline_endnew_linerVr?r(r(r)__rich_console__sv         zPanel.__rich_console__r c Csz|j}t|j\}}}}||}|r|j|gn|jg}|jdur5t|||j|d|j |d} n|j} t | | S)NrD) r=r rGr"r$r r rNrJrOr ) r'rArBr=_rightleftr" renderablesr r(r(r)__rich_measure__s$  zPanel.__rich_measure__)rArrBrr&r)rArrBrr&r )__name__ __module__ __qualname____doc__rrrrrboolr intr r* classmethodr,propertyrr=r@rirnr(r(r(r)rs      !       Kr__main__)r)r )rDOUBLEz Hello, World!z rich.Panelz white on blue)rrr%r"N)"typingrrr%rrrXrjupyterrrMr r r"r r rr textrrsegmentrrArrrrrrocrxpprintr(r(r(r)s8    Y