o 7]hj @sddlmZmZmZmZmZmZerddlmZm Z m Z m Z ddl m Z ddlmZddlmZddlmZeeeeeeefeeeeeffZGdd d e Zed krgdd lmZeed d dddSdS))castListOptionalTuple TYPE_CHECKINGUnion)ConsoleConsoleOptionsRenderableType RenderResult) JupyterMixin) Measurement)Style)Segmentc @seZdZdZ d!ddddddd d eeefd efd d Ze ddde ddfddZ e dd de e e e e ffddZdefddZ      d"ddZ      d#ddZd S)$Paddinga Draw space around content. Example: >>> print(Padding("Hello", (2, 4), style="on blue")) Args: renderable (RenderableType): String or other renderable. pad (Union[int, Tuple[int]]): Padding for top, right, bottom, and left borders. May be specified with 1, 2, or 4 integers (CSS style). style (Union[str, Style], optional): Style for padding characters. Defaults to "none". expand (bool, optional): Expand padding to fit available width. Defaults to True. rrrrnoneT)styleexpand renderabler padPaddingDimensionsrrcCs0||_||\|_|_|_|_||_||_dS)N)runpacktoprightbottomleftrr)selfrrrrr:/usr/lib/python3/dist-packages/pip/_vendor/rich/padding.py__init__!s zPadding.__init__levelreturncCst|ddd|fddS)zMake padding instance to render an indent. Args: renderable (RenderableType): String or other renderable. level (int): Number of characters to indent. Returns: Padding: A Padding instance. rF)rr)r)clsrr"rrr indent.s zPadding.indentcCst|tr ||||fSt|dkr|d}||||fSt|dkr2ttttf|\}}||||fSt|dkrMttttttf|\}}}}||||fStdt|d)z&Unpack padding specified in CSS style.rrz)1, 2 or 4 integers required for padding; z given) isinstanceintlenrr ValueError)r_padpad_top pad_rightrrrrrrr r<s        zPadding.unpackc Cs.d|jd|jd|jd|jd|jd S)NzPadding(z, (,z)))rrrrr)rrrr __repr__Ls.zPadding.__repr__consoler optionsr r c cs||j}|jr|j}ntt|||jj|j |j |j}| ||j |j }|j dur>|j |j |j|jd}|j|j||dd}t}|j rU|d|j |nd}|j rg|d|j ||gn|g} d} |jr|d|d|g} | |jEdH|r|D]} |V| EdH| EdHqn|D] } | EdH| EdHq|jr| p|d|d|g} | |jEdHdSdS)N)heightT)rr  ) get_stylerr max_widthminrgetrmaximumrr update_widthr3 update_heightrr render_linesrline) rr1r2rwidthrender_optionslines_Segmentrr blank_liner>rrr __rich_console__OsV       zPadding.__rich_console__rcCs\|j}|j|j}||dkrt||St|||j\}}t||||}||}|S)Nr)r7rrrr9r with_maximum)rr1r2r7 extra_width measure_min measure_max measurementrrr __rich_measure__}s    zPadding.__rich_measure__N)r)r1r r2r r#r )r1r r2r r#r)__name__ __module__ __qualname____doc__rstrrboolr! classmethodr)r% staticmethodrrr0rDrJrrrr rsD     .r__main__)printz Hello, World)r&r'zon blue)rN)typingrrrrrrr1r r r r jupyterr measurerrrsegmentrr)rrrKpip._vendor.richrTrrrr s     (w