HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_vendor/rich/__pycache__/layout.cpython-37.pyc
B

L��g�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-hv55ucu3/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.N)r#r$r%r&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)r/r0)�selfr/r0r(r(r)�__init__8sz_Placeholder.__init__)�console�optionsr1ccsx|j}|jp|jj}|j}|jr8|j�d|�d|�d�nd|�d|�d�}ttjt|�dd�|j	|�
|�d|d�VdS)	Nz (z x �)�(�middle)ZverticalZblue)r0�titleZborder_style�height)�	max_widthr:�sizer/�namerr�centerrr0�highlighter)r2r4r5�widthr:r/r9r(r(r)�__rich_console__<sz_Placeholder.__rich_console__)r.)r#r$r%r&rr?rr3rrrrAr(r(r(r)r-3s
r-c@sVeZdZUdZdZeed<eed�dd��Zee	de
eede
fd�d	d
��Z
dS)�SplitterzBase class for a splitter.r.r=)r1cCsdS)z(Get the icon (emoji) used in layout.treeNr()r2r(r(r)�
get_tree_iconUszSplitter.get_tree_iconr*)�childrenr!r1cCsdS)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()r2rDr!r(r(r)�divideYs	zSplitter.divideN)r#r$r%r&r=�strr'rrCr
rr	rrEr(r(r(r)rBPs
rBc@sDeZdZdZdZed�dd�Zedee	e
defd�dd	�Zd
S)�RowSplitterz!Split a layout region in to rows.�row)r1cCsdS)Nu[layout.tree.row]⬌r()r2r(r(r)rCjszRowSplitter.get_tree_iconr*)rDr!r1ccsZ|\}}}}t||�}d}t}	x6t||�D](\}
}|
|	|||||�fV||7}q*WdS)Nr)rr�zip)r2rDr!�x�yr@r:Z
render_widths�offset�_Region�childZchild_widthr(r(r)rEms
zRowSplitter.divideN)r#r$r%r&r=rFrCr
rr	rrEr(r(r(r)rGes
rGc@sDeZdZdZdZed�dd�Zedee	e
defd�dd	�Zd
S)�ColumnSplitterz$Split a layout region in to columns.�column)r1cCsdS)Nu[layout.tree.column]⬍r()r2r(r(r)rC~szColumnSplitter.get_tree_iconr*)rDr!r1ccsZ|\}}}}t||�}d}t}	x6t||�D](\}
}|
|	|||||�fV||7}q*WdS)Nr)rrrI)r2rDr!rJrKr@r:Zrender_heightsrLrMrNZchild_heightr(r(r)rE�s
zColumnSplitter.divideN)r#r$r%r&r=rFrCr
rr	rrEr(r(r(r)rOys
rOc
@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.
    )rHrPNrT)r=r<�minimum_size�ratio�visible)�
renderabler=r<rQrRrSr1cCsR|p
t|�|_||_||_||_||_||_|jd�|_g|_	i|_
t�|_dS)NrP)
r-�_renderabler<rQrRr=rS�	splitters�splitter�	_children�_render_mapr�_lock)r2rTr=r<rQrRrSr(r(r)r3�s
zLayout.__init__)r1ccs<d|jdfVd|jdfVd|jdfVd|jdfVdS)Nr=r<rQrrR)r=r<rQrR)r2r(r(r)�
__rich_repr__�szLayout.__rich_repr__cCs|jr
|S|jS)zLayout renderable.)rXrU)r2r(r(r)rT�szLayout.renderablecCsdd�|jD�S)zGets (visible) layout children.cSsg|]}|jr|�qSr()rS)�.0rNr(r(r)�
<listcomp>�sz#Layout.children.<locals>.<listcomp>)rX)r2r(r(r)rD�szLayout.childrencCs|jS)zGet a map of the last render.)rY)r2r(r(r)�map�sz
Layout.map)r=r1cCs8|j|kr|Sx$|jD]}|�|�}|dk	r|SqWdS)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)r=rX�get)r2r=rNZnamed_layoutr(r(r)r_�s	

z
Layout.getcCs$|�|�}|dkr td|����|S)NzNo layout with name )r_�KeyError)r2r=r/r(r(r)�__getitem__�s
zLayout.__getitem__rcs�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)�Table)rr*)r/r1csF|j��}�jdd�}|jr$t|�n�t|�d�}|�||�|}|S)N)rrrr)�paddingZdim)rWrCZgridrSrZadd_row)r/Zicon�table�textZ_summary)rbrcr(r)�summary�s
zLayout.tree.<locals>.summaryzlayout.tree.T)�guide_styleZ	highlightrN)�treer/r1cs6x0|jD]&}�|j�|�d|jj��d�|�qWdS)Nzlayout.tree.)rh)rX�addrWr=)rir/rN)�recursergr(r)rk�szLayout.tree.<locals>.recurse)Zpip._vendor.rich.styledrbZpip._vendor.rich.tablerc�pip._vendor.rich.treerrWr=)r2rr/rir()rbrcrkrgr)ri�s


zLayout.treerP)rW)�layoutsrWr1cGsddd�|D�}y 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*)r\r/r(r(r)r]sz Layout.split.<locals>.<listcomp>zNo splitter called N)rnrBrVrWr`r,rX)r2rWrm�_layoutsr(r(r)�splitszLayout.split)rmr1cGsdd�|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|�VqdS)N)rnr*)r\r/r(r(r)�	<genexpr>'sz#Layout.add_split.<locals>.<genexpr>N)rX�extend)r2rmror(r(r)�	add_splitszLayout.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.
        rWrHN)rp)r2rmr(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.
        rWrPN)rp)r2rmr(r(r)�split_column4szLayout.split_columncCs|jdd�=dS)zReset splits to initial state.N)rX)r2r(r(r)�unsplit<szLayout.unsplit)rTr1c	Cs|j�||_WdQRXdS)zjUpdate renderable.

        Args:
            renderable (RenderableType): New renderable object.
        N)rZrU)r2rTr(r(r)�update@sz
Layout.updater)r4�layout_namer1c	Csl|j�\||}|j|\}}|\}}}}	|�||j�||	��}
t||
�|j|<|�|
||�WdQRXdS)z�Refresh a sub-layout.

        Args:
            console (Console): Console instance where Layout is to be rendered.
            layout_name (str): Name of layout.
        N)rZrY�render_linesr5�update_dimensionsr Zupdate_screen_lines)r2r4rxr/r!�_linesrJrKr@r:�linesr(r(r)�refresh_screenIszLayout.refresh_screen)r@r:r1c
Cs�|tdd||�fg}|j}|j}g}|j}xH|rr||��|d\}}	|j}
|
r,x|j�|
|	�D]}||�q`Wq,Wdd�t|td�d�D�}|S)z,Create a dict that maps layout on to Region.r���cSsi|]\}}||�qSr(r()r\r/r!r(r(r)�
<dictcomp>isz+Layout._make_region_map.<locals>.<dictcomp>r)�key)r�append�poprDrWrE�sortedr)
r2r@r:�stack�pushr��layout_regionsZappend_layout_regionr/r!rDZchild_and_region�
region_mapr(r(r)�_make_region_mapZs
zLayout._make_region_map)r4r5r1c
Csz|j}|jp|j}|�||�}dd�|��D�}i}|j}|j}	x4|D],\}
}||
j|	|j|j��}t||�||
<qFW|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()rD)r\r/r!r(r(r)r]}sz!Layout.render.<locals>.<listcomp>)	r;r:r��itemsryrzrTr@r )
r2r4r5Zrender_widthZ
render_heightr�r��
render_mapryrzr/r!r|r(r(r)r"os
z
Layout.renderc	cs�|j��|jp|j}|jp|j}|�||�||��}||_dd�t|�D�}t}xN|�	�D]B\}}	|\}
}}}
x,t
|||||
�|	�D]\}}|�|�q�WqZWt�
�}x|D]}|EdH|Vq�WWdQRXdS)NcSsg|]}g�qSr(r()r\�_r(r(r)r]�sz+Layout.__rich_console__.<locals>.<listcomp>)rZr;r@r:r"rzrY�ranger�valuesrIrrr�line)r2r4r5r@r:r�Zlayout_lines�_islicer!r|�_xrKZ
_layout_widthZ
layout_heightrHr��new_lineZ
layout_rowr(r(r)rA�s 

zLayout.__rich_console__)N)(r#r$r%r&rGrOrVrrrF�int�boolr3rr[�propertyrTr
rD�	RenderMapr^r_rarirrBrprsrtrurvrwr}�	RegionMapr�rrr"rrAr(r(r(r)r*�s@
*
	�__main__)r�header�)r=r<�main)rRr=�
�footer)r<r=Zside)r=�body�)r=rR�content�s2�topr8ZbottomZleft1Zleft2ZfooN)@�abcrr�	itertoolsr�operatorr�	threadingr�typingrrr	r
rrr
rrZ_ratiorZalignrr4rrrrr?rZpanelr�prettyrr!r�reprrr�segmentrr0rrlrr r�r��	Exceptionr+r,r-rBrGrOr*r#Zpip._vendor.rich.consoler/rurtrirw�printr(r(r(r)�<module>sV,