HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/python38/lib/python3.8/site-packages/pip/_vendor/rich/__pycache__/layout.cpython-38.pyc
U

�{�e�6�@stddlmZmZddlmZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZmZddlmZddlmZdd	lmZmZmZmZdd
lmZddlmZddl m!Z!dd
l"m#Z#ddl$m%Z%m&Z&ddl'm(Z(ddl)m*Z*e
r�ddl+m,Z,Gdd�de�Z-ede#fZ.ede-fZ/Gdd�de0�Z1Gdd�de1�Z2Gdd�d�Z3Gdd�de�Z4Gdd�de4�Z5Gdd �d e4�Z6e&Gd!d�d��Z7e8d"k�rpdd#l9mZe�Ze7�Z:e:�;e7d$d%d&�e7dd'd(�e7d)d*d+��e:d'�<e7d,d-�e7d.d/d0��e:d.�<e7d1d/d0�e7d2d-��e:d2�;e7d3d-�e7d4d-�e7d5d-��e:d,�;e7e:j=d6d-�e7d7d-��e:d1�>d8�e�?e:�d9S):�)�ABC�abstractmethod)�islice)�
itemgetter)�RLock)	�
TYPE_CHECKING�Dict�Iterable�List�
NamedTuple�Optional�Sequence�Tuple�Union�)�
ratio_resolve)�Align)�Console�ConsoleOptions�RenderableType�RenderResult)�ReprHighlighter)�Panel)�Pretty)�Region)�Result�	rich_repr)�Segment)�	StyleType��Treec@s*eZdZUdZeed<eeeed<dS)�LayoutRenderzAn individual layout render.�region�renderN)�__name__�
__module__�__qualname__�__doc__r�__annotations__r
r�r)r)�;/tmp/pip-unpacked-wheel-_0scjqea/pip/_vendor/rich/layout.pyr! s
r!�Layoutc@seZdZdZdS)�LayoutErrorzLayout related error.N�r$r%r&r'r)r)r)r*r,+sr,c@seZdZdZdS)�
NoSplitterz"Requested splitter does not exist.Nr-r)r)r)r*r./sr.c@s<eZdZdZe�Zddedd�dd�Zee	e
d�d	d
�ZdS)�_Placeholderz4An internal renderable used as a Layout placeholder.�r+N)�layout�style�returncCs||_||_dS�N)r1r2)�selfr1r2r)r)r*�__init__8sz_Placeholder.__init__��console�optionsr3ccsx|j}|jp|jj}|j}|jr8|j�d|�d|�d�nd|�d|�d�}ttjt|�dd�|j	|�
|�d|d�VdS)	Nz (z x �)�(�middle)ZverticalZblue)r2�titleZborder_style�height)�	max_widthr>�sizer1�namerr�centerrr2�highlighter)r5r8r9�widthr>r1r=r)r)r*�__rich_console__<s���z_Placeholder.__rich_console__)r0)r$r%r&r'rrCrr6rrrrEr)r)r)r*r/3s�r/c@sVeZdZUdZdZeed<eed�dd��Zee	de
eede
fd�d	d
��Z
dS)�SplitterzBase class for a splitter.r0rA�r3cCsdS)z(Get the icon (emoji) used in layout.treeNr)�r5r)r)r*�
get_tree_iconUszSplitter.get_tree_iconr+��childrenr"r3cCsdS)z�Divide a region amongst several child layouts.

        Args:
            children (Sequence(Layout)): A number of child layouts.
            region (Region): A rectangular region to divide.
        Nr))r5rKr"r)r)r*�divideYszSplitter.divideN)r$r%r&r'rA�strr(rrIr
rr	rrLr)r)r)r*rFPs
�rFc@sDeZdZdZdZed�dd�Zedee	e
defd�dd	�Zd
S)�RowSplitterz!Split a layout region in to rows.�rowrGcCsdS)Nu[layout.tree.row]⬌r)rHr)r)r*rIjszRowSplitter.get_tree_iconr+rJccsV|\}}}}t||�}d}t}	t||�D](\}
}|
|	|||||�fV||7}q(dS�Nr�rr�zip)r5rKr"�x�yrDr>Z
render_widths�offset�_Region�childZchild_widthr)r)r*rLms
zRowSplitter.divideN�r$r%r&r'rArMrIr
rr	rrLr)r)r)r*rNes�rNc@sDeZdZdZdZed�dd�Zedee	e
defd�dd	�Zd
S)�ColumnSplitterz$Split a layout region in to columns.�columnrGcCsdS)Nu[layout.tree.column]⬍r)rHr)r)r*rI~szColumnSplitter.get_tree_iconr+rJccsV|\}}}}t||�}d}t}	t||�D](\}
}|
|	|||||�fV||7}q(dSrPrQ)r5rKr"rSrTrDr>Zrender_heightsrUrVrWZchild_heightr)r)r*rL�s
zColumnSplitter.divideNrXr)r)r)r*rYys�rYc
@s�eZdZdZeed�Zd8dddddd�eeee	ee
e
e
edd�dd	�Ze
d
�dd�Zeed
�d
d��Zeedd
�dd��Zeed
�dd��Ze	edd�dd�Ze	dd�dd�Zedd
�dd��Zdd�edefeee	fdd�dd�Zedefdd �d!d"�Zedefdd �d#d$�Zedefdd �d%d&�Zdd
�d'd(�Zedd)�d*d+�Zd,e	dd-�d.d/�Z e
e
e!d0�d1d2�Z"e#e$ed3�d4d5�Z%e#e$e&d3�d6d7�Z'dS)9r+aBA renderable to divide a fixed height in to rows or columns.

    Args:
        renderable (RenderableType, optional): Renderable content, or None for placeholder. Defaults to None.
        name (str, optional): Optional identifier for Layout. Defaults to None.
        size (int, optional): Optional fixed size of layout. Defaults to None.
        minimum_size (int, optional): Minimum size of layout. Defaults to 1.
        ratio (int, optional): Optional ratio for flexible layout. Defaults to 1.
        visible (bool, optional): Visibility of layout. Defaults to True.
    )rOrZNrT)rAr@�minimum_size�ratio�visible)�
renderablerAr@r[r\r]r3cCsR|p
t|�|_||_||_||_||_||_|jd�|_g|_	i|_
t�|_dS)NrZ)
r/�_renderabler@r[r\rAr]�	splitters�splitter�	_children�_render_mapr�_lock)r5r^rAr@r[r\r]r)r)r*r6�s
zLayout.__init__rGccs<d|jdfVd|jdfVd|jdfVd|jdfVdS)NrAr@r[rr\)rAr@r[r\rHr)r)r*�
__rich_repr__�szLayout.__rich_repr__cCs|jr
|S|jS)zLayout renderable.)rbr_rHr)r)r*r^�szLayout.renderablecCsdd�|jD�S)zGets (visible) layout children.cSsg|]}|jr|�qSr))r])�.0rWr)r)r*�
<listcomp>�sz#Layout.children.<locals>.<listcomp>�rbrHr)r)r*rK�szLayout.childrencCs|jS)zGet a map of the last render.)rcrHr)r)r*�map�sz
Layout.map)rAr3cCs8|j|kr|S|jD]}|�|�}|dk	r|SqdS)z�Get a named layout, or None if it doesn't exist.

        Args:
            name (str): Name of layout.

        Returns:
            Optional[Layout]: Layout instance or None if no layout was found.
        N)rArb�get)r5rArWZnamed_layoutr)r)r*rj�s	



z
Layout.getcCs$|�|�}|dkr td|����|S)NzNo layout with name )rj�KeyError)r5rAr1r)r)r*�__getitem__�s
zLayout.__getitem__r cs�ddlm�ddlm�ddlm}d�d���fdd��|}|�|�d	|jj��d
d�}ddd
d���fdd���||�|S)z/Get a tree renderable to show layout structure.r)�Styled)�Tablerr+)r1r3csF|j��}�jdd�}|jr$t|�n�t|�d�}|�||�|}|S)N)rrrr)�paddingZdim)rarIZgridr]rZadd_row)r1Zicon�table�textZ_summary)rmrnr)r*�summary�s
�zLayout.tree.<locals>.summary�layout.tree.T)�guide_styleZ	highlightr N)�treer1r3cs2|jD]&}�|j�|�d|jj��d�|�qdS)Nrs)rt)rb�addrarA)rur1rW)�recurserrr)r*rw�s
��zLayout.tree.<locals>.recurse)Zpip._vendor.rich.styledrmZpip._vendor.rich.tablern�pip._vendor.rich.treer rarA)r5r r1rur))rmrnrwrrr*ru�s
�

zLayout.treerZ)ra)�layoutsrar3cGsddd�|D�}z t|t�r|n
|j|�|_Wn"tk
rPtd|����YnX||jdd�<dS)z�Split the layout in to multiple sub-layouts.

        Args:
            *layouts (Layout): Positional arguments should be (sub) Layout instances.
            splitter (Union[Splitter, str]): Splitter instance or name of splitter.
        cSs"g|]}t|t�r|nt|��qSr)��
isinstancer+�rfr1r)r)r*rgs�z Layout.split.<locals>.<listcomp>zNo splitter called N)r{rFr`rarkr.rb)r5rary�_layoutsr)r)r*�splits��
�zLayout.split)ryr3cGsdd�|D�}|j�|�dS)z�Add a new layout(s) to existing split.

        Args:
            *layouts (Union[Layout, RenderableType]): Positional arguments should be renderables or (sub) Layout instances.

        css$|]}t|t�r|nt|�VqdSr4rzr|r)r)r*�	<genexpr>&s�z#Layout.add_split.<locals>.<genexpr>N)rb�extend)r5ryr}r)r)r*�	add_splits�zLayout.add_splitcGs|j|ddi�dS)z�Split the layout in to a row (layouts side by side).

        Args:
            *layouts (Layout): Positional arguments should be (sub) Layout instances.
        rarON�r~�r5ryr)r)r*�	split_row,szLayout.split_rowcGs|j|ddi�dS)z�Split the layout in to a column (layouts stacked on top of each other).

        Args:
            *layouts (Layout): Positional arguments should be (sub) Layout instances.
        rarZNr�r�r)r)r*�split_column4szLayout.split_columncCs|jdd�=dS)zReset splits to initial state.NrhrHr)r)r*�unsplit<szLayout.unsplit)r^r3c	Cs|j�||_W5QRXdS)zjUpdate renderable.

        Args:
            renderable (RenderableType): New renderable object.
        N)rdr_)r5r^r)r)r*�update@sz
Layout.updater)r8�layout_namer3c	Csl|j�\||}|j|\}}|\}}}}	|�||j�||	��}
t||
�|j|<|�|
||�W5QRXdS)z�Refresh a sub-layout.

        Args:
            console (Console): Console instance where Layout is to be rendered.
            layout_name (str): Name of layout.
        N)rdrc�render_linesr9�update_dimensionsr!Zupdate_screen_lines)r5r8r�r1r"�_linesrSrTrDr>�linesr)r)r*�refresh_screenIs�zLayout.refresh_screen)rDr>r3c
Cs�|tdd||�fg}|j}|j}g}|j}|rl||��|d\}}	|j}
|
r*|j�|
|	�D]}||�q\q*dd�t|td�d�D�}|S)z,Create a dict that maps layout on to Region.r���cSsi|]\}}||�qSr)r)�rfr1r"r)r)r*�
<dictcomp>is�z+Layout._make_region_map.<locals>.<dictcomp>r)�key)r�append�poprKrarL�sortedr)
r5rDr>�stack�pushr��layout_regionsZappend_layout_regionr1r"rKZchild_and_region�
region_mapr)r)r*�_make_region_mapZs 
�zLayout._make_region_mapr7c
Csv|j}|jp|j}|�||�}dd�|��D�}i}|j}|j}	|D],\}
}||
j|	|j|j��}t||�||
<qD|S)z�Render the sub_layouts.

        Args:
            console (Console): Console instance.
            options (ConsoleOptions): Console options.

        Returns:
            RenderMap: A dict that maps Layout on to a tuple of Region, lines
        cSsg|]\}}|js||f�qSr))rKr�r)r)r*rg|s�z!Layout.render.<locals>.<listcomp>)	r?r>r��itemsr�r�r^rDr!)
r5r8r9Zrender_widthZ
render_heightr�r��
render_mapr�r�r1r"r�r)r)r*r#os 
��z
Layout.renderc	cs�|j��|jp|j}|jp|j}|�||�||��}||_dd�t|�D�}t}|�	�D]>\}}	|\}
}}}
t
|||||
�|	�D]\}}|�|�q�qXt�
�}|D]}|EdH|Vq�W5QRXdS)NcSsg|]}g�qSr)r))rf�_r)r)r*rg�sz+Layout.__rich_console__.<locals>.<listcomp>)rdr?rDr>r#r�rc�ranger�valuesrRr�r�line)r5r8r9rDr>r�Zlayout_lines�_islicer"r��_xrTZ
_layout_widthZ
layout_heightrOr��new_lineZ
layout_rowr)r)r*rE�s$�
zLayout.__rich_console__)N)(r$r%r&r'rNrYr`rrrM�int�boolr6rre�propertyr^r
rK�	RenderMaprirjrlrurrFr~r�r�r�r�r�r��	RegionMapr�rrr#rrEr)r)r)r*r+�s^
���*�

�
	��__main__)r�header�)rAr@�main)r\rA�
�footer)r@rAZside)rA�body�)rAr\�content�s2�topr<ZbottomZleft1Zleft2ZfooN)@�abcrr�	itertoolsr�operatorr�	threadingr�typingrrr	r
rrr
rrZ_ratiorZalignrr8rrrrrCrZpanelr�prettyrr"r�reprrr�segmentrr2rrxr r!r�r��	Exceptionr,r.r/rFrNrYr+r$Zpip._vendor.rich.consoler1r�r�rur��printr)r)r)r*�<module>s`,



��