HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/rich/__pycache__/layout.cpython-310.pyc
o

;jx6�@sxddlmZmZddlmZddlmZddlmZddl	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�r:dd#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:�d9Sd9S):�)�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)�?/opt/saltstack/salt/lib/python3.10/site-packages/rich/layout.pyr! s
r!�Layoutc@�eZdZdZdS)�LayoutErrorzLayout related error.N�r$r%r&r'r)r)r)r*r-+�r-c@r,)�
NoSplitterz"Requested splitter does not exist.Nr.r)r)r)r*r0/r/r0c@sDeZdZdZe�Zddddeddfdd	�Zd
ede	de
fdd
�ZdS)�_Placeholderz4An internal renderable used as a Layout placeholder.��layoutr+�style�returnNcCs||_||_dS�N)r3r4)�selfr3r4r)r)r*�__init__8s
z_Placeholder.__init__�console�optionsccsz�|j}|jp
|jj}|j}|jr|j�d|�d|�d�nd|�d|�d�}ttjt|�dd�|j	|�
|�d|d�VdS)	Nz (z x �)�(�middle)ZverticalZblue)r4�titleZborder_style�height)�	max_widthr?�sizer3�namerr�centerrr4�highlighter)r7r9r:�widthr?r3r>r)r)r*�__rich_console__<s����z_Placeholder.__rich_console__)r2)r$r%r&r'rrDrr8rrrrFr)r)r)r*r13s���r1c
@sZeZdZUdZdZeed<edefdd��Zede	dd	e
deede
ffd
d��Z
dS)
�SplitterzBase class for a splitter.r2rBr5cC�dS)z(Get the icon (emoji) used in layout.treeNr)�r7r)r)r*�
get_tree_iconU�zSplitter.get_tree_icon�childrenr+r"cCrH)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))r7rLr"r)r)r*�divideYrKzSplitter.divideN)r$r%r&r'rB�strr(rrJr
rr	rrMr)r)r)r*rGPs
���rGc	@�HeZdZdZdZdefdd�Zdeddede	e
deffd	d
�ZdS)�RowSplitterz!Split a layout region in to rows.�rowr5cCrH)Nu[layout.tree.row]⬌r)rIr)r)r*rJj�zRowSplitter.get_tree_iconrLr+r"ccsX�|\}}}}t||�}d}t}	t||�D]\}
}|
|	|||||�fV||7}qdS�Nr�rr�zip)r7rLr"�x�yrEr?Z
render_widths�offset�_Region�childZchild_widthr)r)r*rMm��

�zRowSplitter.divideN�r$r%r&r'rBrNrJr
rr	rrMr)r)r)r*rPe����rPc	@rO)�ColumnSplitterz$Split a layout region in to columns.�columnr5cCrH)Nu[layout.tree.column]⬍r)rIr)r)r*rJ~rRzColumnSplitter.get_tree_iconrLr+r"ccsX�|\}}}}t||�}d}t}	t||�D]\}
}|
|	|||||�fV||7}qdSrSrT)r7rLr"rVrWrEr?Zrender_heightsrXrYrZZchild_heightr)r)r*rM�r[zColumnSplitter.divideNr\r)r)r)r*r^yr]r^c@s�eZdZdZeed�Z	d=dddddd�deedee	d	ee
d
e
de
ded
dfdd�Zd
e
fdd�Zed
efdd��Zed
edfdd��Zed
efdd��Zde	d
edfdd�Zde	d
dfdd�Zed>dd��Zdd �d!edefd"eee	fd
dfd#d$�Zd!edefd
dfd%d&�Zd!edefd
dfd'd(�Zd!edefd
dfd)d*�Zd?d+d,�Zded
dfd-d.�Zd/d0d1e	d
dfd2d3�Z d4e
d5e
d
e!fd6d7�Z"d/e#d8e$d
efd9d:�Z%d/e#d8e$d
e&fd;d<�Z'dS)@r+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.
    )rQr_NrT)rBrA�minimum_size�ratio�visible�
renderablerBrAr`rarbr5cCsR|pt|�|_||_||_||_||_||_|jd�|_g|_	i|_
t�|_dS)Nr_)
r1�_renderablerAr`rarBrb�	splitters�splitter�	_children�_render_mapr�_lock)r7rcrBrAr`rarbr)r)r*r8�s
zLayout.__init__ccs>�d|jdfVd|jdfVd|jdfVd|jdfVdS)NrBrAr`rra)rBrAr`rarIr)r)r*�
__rich_repr__�s
�zLayout.__rich_repr__cCs|jr|S|jS)zLayout renderable.)rgrdrIr)r)r*rc��zLayout.renderablecCsdd�|jD�S)zGets (visible) layout children.cSsg|]}|jr|�qSr))rb)�.0rZr)r)r*�
<listcomp>�sz#Layout.children.<locals>.<listcomp>�rgrIr)r)r*rL�rkzLayout.childrencCs|jS)zGet a map of the last render.)rhrIr)r)r*�map�sz
Layout.mapcCs8|j|kr|S|jD]}|�|�}|dur|Sq
dS)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)rBrg�get)r7rBrZZnamed_layoutr)r)r*rp�s
	

�z
Layout.getcCs$|�|�}|durtd|����|S)NzNo layout with name )rp�KeyError)r7rBr3r)r)r*�__getitem__�s
zLayout.__getitem__r cszddlm�ddlm�ddlm}ddd�f��fdd	��|}|�|�d
|jj��dd�}d��fdd���||�|S)z/Get a tree renderable to show layout structure.r)�Styled)�Tablerr3r+r5csF|j��}�jdd�}|jrt|�n�t|�d�}|�||�|}|S)N)rrrr)�paddingZdim)rfrJZgridrbrZadd_row)r3Zicon�table�textZ_summary)rsrtr)r*�summary�s
�zLayout.tree.<locals>.summary�layout.tree.T)�guide_styleZ	highlight�treer Ncs2|jD]}�|j�|�d|jj��d�|�qdS)Nry)rz)rg�addrfrB)r{r3rZ)�recurserxr)r*r}�s
���zLayout.tree.<locals>.recurse)r{r r3r+r5N)Zrich.styledrsZ
rich.tablert�	rich.treer rfrB)r7r r3r{r))rsrtr}rxr*r{�s�

zLayout.treer_)rf�layoutsrfcGs^dd�|D�}zt|t�r|n|j|�|_Wnty%td|����w||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+�rlr3r)r)r*rms��z Layout.split.<locals>.<listcomp>zNo splitter called N)r�rGrerfrqr0rg)r7rfr�_layoutsr)r)r*�splits��
��zLayout.splitcGsdd�|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|�VqdSr6r�r�r)r)r*�	<genexpr>%s
��
�z#Layout.add_split.<locals>.<genexpr>N)rg�extend)r7rr�r)r)r*�	add_splits�zLayout.add_splitcG�|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.
        rfrQN�r��r7rr)r)r*�	split_row+�zLayout.split_rowcGr�)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.
        rfr_Nr�r�r)r)r*�split_column3r�zLayout.split_columncCs|jdd�=dS)zReset splits to initial state.NrnrIr)r)r*�unsplit;szLayout.unsplitcCs2|j�||_Wd�dS1swYdS)zjUpdate renderable.

        Args:
            renderable (RenderableType): New renderable object.
        N)rird)r7rcr)r)r*�update?s"�z
Layout.updater9r�layout_namecCs�|j�4||}|j|\}}|\}}}}	|�||j�||	��}
t||
�|j|<|�|
||�Wd�dS1s:wYdS)z�Refresh a sub-layout.

        Args:
            console (Console): Console instance where Layout is to be rendered.
            layout_name (str): Name of layout.
        N)rirh�render_linesr:�update_dimensionsr!Zupdate_screen_lines)r7r9r�r3r"�_linesrVrWrEr?�linesr)r)r*�refresh_screenHs�"�zLayout.refresh_screenrEr?c
Cs�|tdd||�fg}|j}|j}g}|j}|r7||��|d\}}	|j}
|
r5|j�|
|	�D]}||�q.|sdd�t|td�d�D�}|S)z,Create a dict that maps layout on to Region.r���cSsi|]\}}||�qSr)r)�rlr3r"r)r)r*�
<dictcomp>hs��z+Layout._make_region_map.<locals>.<dictcomp>r)�key)r�append�poprLrfrM�sortedr)
r7rEr?�stack�pushr��layout_regionsZappend_layout_regionr3r"rLZchild_and_region�
region_mapr)r)r*�_make_region_mapYs"

��zLayout._make_region_mapr:c
Csv|j}|jp|j}|�||�}dd�|��D�}i}|j}|j}	|D]\}
}||
j|	|j|j��}t||�||
<q"|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))rLr�r)r)r*rm{s��z!Layout.render.<locals>.<listcomp>)	r@r?r��itemsr�r�rcrEr!)
r7r9r:Zrender_widthZ
render_heightr�r��
render_mapr�r�r3r"r�r)r)r*r#ns
��z
Layout.renderccs��|j�b|jp
|j}|jp|j}|�||�||��}||_dd�t|�D�}t}|�	�D]\}}	|\}
}}}
t
|||||
�|	�D]	\}}|�|�qBq-t�
�}|D]
}|EdH|VqSWd�dS1siwYdS)NcSsg|]}g�qSr)r))rl�_r)r)r*rm�sz+Layout.__rich_console__.<locals>.<listcomp>)rir@rEr?r#r�rh�ranger�valuesrUr�r�line)r7r9r:rEr?r�Zlayout_lines�_islicer"r�Z_xrWZ
_layout_widthZ
layout_heightrQr�Znew_lineZ
layout_rowr)r)r*rF�s*���
�"�zLayout.__rich_console__r6)r5r )r5N)(r$r%r&r'rPr^rerrrN�int�boolr8rrj�propertyrcr
rL�	RenderMaprorprrr{rrGr�r�r�r�r�r�r��	RegionMapr�rrr#rrFr)r)r)r*r+�sv
��������	
�)�
�
�
�

	����__main__)r�header�)rBrA�main)rarB�
Zfooter)rArBZside)rB�body�)rBra�content�s2�topr=ZbottomZleft1Zleft2ZfooN)@�abcrr�	itertoolsr�operatorr�	threadingr�typingrrr	r
rrr
rrZ_ratiorZalignrr9rrrrrDrZpanelrZprettyrr"r�reprrrZsegmentrr4rr~r r!r�r��	Exceptionr-r0r1rGrPr^r+r$Zrich.consoler3r�r�r{r��printr)r)r)r*�<module>s`,



�� �