U cf(@sfddlZddlmZddlmZmZmZejdkr@ddlmZn ddl mZddl m Z ddl m Z dd lmZdd lmZdd lmZerdd lmZmZmZmZed ZedZGddde ZGddde ZedkrbddlmZmZddl m!Z!ddl"m#Z#e!Z$eZe#ee%e$de&e$de'e$dddddZ(e)ej&e(ddej*ddS) N)chain) TYPE_CHECKINGIterableOptional))Literal) Constrain) JupyterMixin) Measurement)Segment) StyleType)ConsoleConsoleOptionsRenderableType RenderResultleftcenterrighttopmiddlebottomc @s0eZdZdZdddddddeeeeeeee ee dddd Z e d d d Z e dddddddeeeeeee ee dd ddZe dddddddeeeeeee ee dd ddZe dddddddeeeeeee ee dd ddZddddddZddedddZdS) AlignaAlign a renderable by adding spaces if necessary. Args: renderable (RenderableType): A console renderable. align (AlignMethod): One of "left", "center", or "right"" style (StyleType, optional): An optional style to apply to the background. vertical (Optional[VerticalAlignMethod], optional): Optional vertical align, one of "top", "middle", or "bottom". Defaults to None. pad (bool, optional): Pad the right with spaces. Defaults to True. width (int, optional): Restrict contents to given width, or None to use default width. Defaults to None. height (int, optional): Set height of align renderable, or None to fit to contents. Defaults to None. Raises: ValueError: if ``align`` is not one of the expected values. rNT)verticalpadwidthheightr) renderablealignstylerrrrreturncCsf|dkrtd|d|dk r8|dkr8td|d||_||_||_||_||_||_||_dS)NrzDinvalid value for align, expected "left", "center", or "right" (not )rzGinvalid value for vertical, expected "top", "middle", or "bottom" (not ) ValueErrorr r!r"rrrr)selfr r!r"rrrrr'D/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/rich/align.py__init__'s   zAlign.__init__r#cCsd|jd|jdS)NzAlign(z, r$)r r!r&r'r'r(__repr__BszAlign.__repr__)r r"rrrrr#c Cs||d|||||dS)zAlign a renderable to the left.rr"rrrrr'clsr r"rrrrr'r'r(rEs z Align.leftc Cs||d|||||dS)z!Align a renderable to the center.rr-r'r.r'r'r(r[s z Align.centerc Cs||d|||||dS)z Align a renderable to the right.rr-r'r.r'r'r(rqs z Align.rightrrrconsoleoptionsr#c #sj|jj|dj}|tjjdkr0|n t|j|jdd}t t |t \}}t ||t |j|jdk r|jndtt dfdd }jrt djp|jdnt dttt dfd d }jp|j}jr|dk rjd krH||} t||| } nTjd kr||d } || |} t|| ||| } n||} t|| |} n|} jr|jt | } | EdHdS)N)r2rr*c3sdkr$D]}|EdHVq ndkrjjr@tdnd}D]}|EdH|r`|VVqHndkrԈd}td|}jrtd|nd}D](}|r|V|EdH|r|VVqn8dkr td}D]}|V|EdHVqdS)Nrr rr)rr )linerr pad_right)r! excess_spacelinesnew_liner&r"r'r(generate_segmentss:        z1Align.__rich_console__..generate_segmentsr4 countr#c3s |dkrt|D] }VqdS)Nrranger>_) blank_liner'r( blank_liness z+Align.__rich_console__..blank_linesrrr5)r!measurer maximumrenderr rminupdatelistr split_lines get_shape set_shaper6 max_widthr" get_stylerrintrrr apply_style) r&r1r2rrenderedrr;rDvertical_height bottom_space iter_segments top_spacer')r!rCr8r9r:r&r"r(__rich_console__sR   )      zAlign.__rich_console__cCst|||j}|SNr getr r&r1r2 measurementr'r'r(__rich_measure__szAlign.__rich_measure__)rN)N)N)N)__name__ __module__ __qualname____doc__ AlignMethodrrVerticalAlignMethodboolrPr)strr, classmethodrrrrWr r]r'r'r'r(rs  ]rc@sZeZdZdZddeeddddZeddd Zd d d d ddZ d d e d ddZ dS)VerticalCenterzVertically aligns a renderable. Warn: This class is deprecated and may be removed in a future version. Use Align class with `vertical="middle"`. Args: renderable (RenderableType): A renderable object. Nr)r r"r#cCs||_||_dSrX)r r")r&r r"r'r'r(r)szVerticalCenter.__init__r*cCsd|jdS)NzVerticalCenter(r$)r r+r'r'r(r,szVerticalCenter.__repr__rrrr0c #s|jdk r||jnd}|j|j|jdddd}t|\}}t|jpV|j j}|t |d}||t |} td||t t tdfdd } |d kr| |EdH|D]} | EdHVq| d kr| | EdHdS) Nr3F)rr5r4r=c3st|D]}VVqdSrXr?rArCr:r'r(rDs z4VerticalCenter.__rich_console__..blank_linesr) r"rO render_linesr rIr rLr6rsizelenrPr) r&r1r2r"r9r_heightrrVrTrDr6r'rhr(rWs(  zVerticalCenter.__rich_console__cCst|||j}|SrXrYr[r'r'r(r]szVerticalCenter.__rich_measure__)N) r^r_r`rarrr)rer,rWr r]r'r'r'r(rgs    rg__main__)rGroup)ReprHighlighter)Panelz align='left'zalign='center'z align='right'<z on dark_blue)rr"titlerzon red)rr"r)+sys itertoolsrtypingrrr version_inforZpip._vendor.typing_extensions constrainr jupyterr rEr segmentr r"rr1rrrrrbrcrrgr^pip._vendor.rich.consolernZpip._vendor.rich.highlighterroZpip._vendor.rich.panelrp highlighterrrrpanelprintrr'r'r'r(sH        T8