HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/output/__pycache__/table_out.cpython-310.pyc
o

�N�g�1�@sVdZddlZddlmZddlZddlZddlZdZdd�Z	Gdd�d�Z
d	d
�ZdS)a�
Display output in a table format
=================================

.. versionadded:: 2017.7.0

The ``table`` outputter displays a sequence of rows as table.

Example output:

.. code-block:: text

    edge01.bjm01:
    ----------
        comment:
        ----------
        out:
        ----------
            ______________________________________________________________________________
            | Active | Interface | Last Move |        Mac        | Moves | Static | Vlan |
            ______________________________________________________________________________
            |  True  |  ae1.900  |    0.0    | 40:A6:77:5A:50:01 |   0   | False  | 111  |
            ______________________________________________________________________________
            |  True  |  ae1.111  |    0.0    | 64:16:8D:32:26:58 |   0   | False  | 111  |
            ______________________________________________________________________________
            |  True  |  ae1.111  |    0.0    | 8C:60:4F:73:2D:57 |   0   | False  | 111  |
            ______________________________________________________________________________
            |  True  |  ae1.111  |    0.0    | 8C:60:4F:73:2D:7C |   0   | False  | 111  |
            ______________________________________________________________________________
            |  True  |  ae1.222  |    0.0    | 8C:60:4F:73:2D:57 |   0   | False  | 222  |
            ______________________________________________________________________________
            |  True  |  ae1.222  |    0.0    | F4:0F:1B:76:9D:97 |   0   | False  | 222  |
            ______________________________________________________________________________
        result:
        ----------


CLI Example:

.. code-block:: bash

    salt '*' foo.bar --out=table
�N)�reduce�tablecCstS�N)�__virtualname__�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/output/table_out.py�__virtual__7src@sjeZdZdZejejejd�Z										
ddd�Z	ddd�Z
dd�Zdd�Zdd�Z
ddd�Zd
S)�TableDisplayz+
    Manage the table display content.
    )�center�right�leftT�-� | r
�| � |�2Nc

Cs�|j�tjj�t�d�t�d���t�dd�|_||_	||_
||_||_||_
||_||_||_|	r7t|	�s=|j|_dS|	|_dS)N�colorZcolor_theme�strip_colorsT)�__dict__�update�salt�utilsrZ
get_colors�__opts__�getr�
has_header�
row_delimiter�delim�justify�
separate_rows�prefix�suffix�width�callable�wrap_onspace�wrapfunc)
�selfrrrrrrr r!r$rrr�__init__Fs"��
zTableDisplay.__init__�cCsb|dur|j}|d9}d}z|�||||||�WSty0|�|||tjj�|�||�YSw)z)Build the unicode string to be displayed.N� z{0}{1}{2}{3}{4}{5})ZENDC�format�UnicodeDecodeErrorrr�data�decode)r%�indentr�msgrr Zendc�fmtrrr�ustringgs��zTableDisplay.ustringcs�fdd�}t||�d��S)z~
        When the text inside the column is longer then the width, will split by space and continue on the next line.
        c	sDdj|dt||�d�dd��t|�dd�d��jk|d�S)Nz{line}{part}{word}z 
�
�r)�line�part�word)r)�len�rfind�splitr!)r3r5�r%rr�	_truncate{s,���z,TableDisplay.wrap_onspace.<locals>._truncater()rr8)r%�textr:rr9rr#vszTableDisplay.wrap_onspacec	s.g}�fdd���fdd�|D�}tdd�gttj|��R�}dd�|D�}�jt�j�t�j�t|�t�j	�t|�d}�j
�j����j
rX|���|�j|��|D]:}	|	D]#}
�j�j	��fd	d�t|
|�D���j}|���|�j|��q^�j
s�|r�|���|�j|��d
}qZ|S)z%Prepare rows content to be displayed.csd�fdd�|D�}g}tdd�g|�R�D]}t|ttf�r)|�dd�|D��q|�|g�q|S)Ncsg|]
}��|��d��qS)r1)r$r8��.0�itemr9rr�
<listcomp>�szBTableDisplay.prepare_rows.<locals>.row_wrapper.<locals>.<listcomp>cW�|Srr��argsrrr�<lambda>��z@TableDisplay.prepare_rows.<locals>.row_wrapper.<locals>.<lambda>cSsg|]}|pd�qS)r'r)r=�substrrrrr?��)�map�
isinstance�tuple�list�append)�rowZnew_rows�rowsr>r9rr�row_wrapper�sz.TableDisplay.prepare_rows.<locals>.row_wrappercsg|]}�|��qSrr�r=rL)rNrrr?�rFz-TableDisplay.prepare_rows.<locals>.<listcomp>cWr@rrrArrrrC�rDz+TableDisplay.prepare_rows.<locals>.<lambda>cSsg|]}tdd�|D���qS)css�|]	}tt|��VqdSr)r6�strr<rrr�	<genexpr>�s�z7TableDisplay.prepare_rows.<locals>.<listcomp>.<genexpr>)�max)r=�columnrrrr?�sr2csg|]\}}�t|�|��qSr)rP)r=r>r!)rrrr?�s��F)rGr�operator�addrr6rr �sumr�_JUSTIFY_MAPr�lowerrrKr0Z
LIGHT_GRAY�join�zip�WHITE)r%rMr-r�outZlogical_rows�columnsZ
max_widthsZ
row_separatorZ
physical_rowsrLr3r)rrNr%r�prepare_rows�s^
������
�����
�
���zTableDisplay.prepare_rowscCs"g}|s|St|d�}d}|dd�D]
}t|�|krd}q|s#|St|t�r:g}t|�D]	}	|�||	�q.|}|turlg}
|sMdd�t|d�D�}|D]}g}t|�D]}	|�t||	��qW|
�|�qO|
}nt|dt�rzdd�|D�}|r�|g|n|}|jo�|}
|�||d	|
�S)
z"Prepares row content and displays.rTr2NFcSs g|]}t|��dd����qS)�_r()rP�replace�title)r=Zlabelrrrr?�s�z-TableDisplay.display_rows.<locals>.<listcomp>cSsg|]}|g�qSrrrOrrrr?�s��)�typerH�dict�sortedrKrPrr^)r%rM�labelsr-r\Zfirst_row_typeZ
consistentrLZlabels_temp�keyZ	temp_rowsZtemp_rowZlabels_and_rowsrrrr�display_rows�sF�

��
zTableDisplay.display_rowsc
	Cs4g}d}t|t�r�|r|rj|t|���vrjt|�D]N}|r"||kr"q||}	|s@|�|j||j|dd��|�|�||jd��t|	ttf�r[|	}|rP|�	|�}|�
|�|||��q|j|	|d|||d�q|S|r�t|�D]}||}	|j|	||||d�qp|St|ttf�r�|s�|}|�
|�|||��|S)zDisplay table(s).N�:�r z
----------rb��rows_key�
labels_key)
rHrdrJ�keysrerKr0Z	DARK_GRAYrIr�extendrh�display)
r%�retr-r\rlrmrMrfrg�valrrrrp�sb
����
��
��zTableDisplay.display)	Tr
rr
TrrrN)r'r'N)NN)�__name__�
__module__�__qualname__�__doc__rPr
�rjust�ljustrWr&r0r#r^rhrprrrrr	;s*�
�
!=.r	c	Ks�d|vr	|�d�a|�dd�pt�dd�}|�d�pt�d�}|�d�p(t�d�}|�d	�p2t�d
�}i}d}|D]}|�|�pGt�d|���}	|	d
urP|	||<q9tdi|��}
g}|rk|rk|�|
j|||
jdd��d�|
jt	j
j�|�||||d��S)a�
    Display the output as table.

    Args:

        * nested_indent: integer, specify the left alignment.
        * has_header: boolean specifying if header should be displayed. Default: True.
        * row_delimiter: character to separate rows. Default: ``_``.
        * delim: character to separate columns. Default: ``" | "``.
        * justify: text alignment. Default: ``center``.
        * separate_rows: boolean specifying if row separator will be displayed between consecutive rows. Default: True.
        * prefix: character at the beginning of the row. Default: ``"| "``.
        * suffix: character at the end of the row. Default: ``" |"``.
        * width: column max width. Default: ``50``.
        * rows_key: display the rows under a specific key.
        * labels_key: use the labels under a certain key. Otherwise will try to use the dictionary keys (if any).
        * title: display title when only one table is selected (using the ``rows_key`` argument).
    �optsZ
nested_indentrzout.table.nested_indentrlzout.table.rows_keyrmzout.table.labels_keyrazout.table.title)rrrrrrr r!z
out.table.Nr1rjrkr)
�poprrr	rKr0r[rYrprrr+r,)rq�kwargsZbase_indentrlrmraZclass_kvargsZargksZargk�argvrr\rrr�output/sF
����	��r})rvrT�	functoolsrZsalt.outputrZsalt.utils.colorZsalt.utils.datarrr	r}rrrr�<module>s,u