%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/rich/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/rich/__pycache__/table.cpython-312.pyc

�

"T�eܚ��X�ddlmZmZmZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
ddlmZmZddlmZmZddlmZddlmZmZddlmZdd	lmZdd
lmZddlm Z m!Z!ddl"m#Z#dd
l$m%Z%ddl&m'Z'm(Z(ddl)m*Z*m+Z+erddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2eGd�d��Z3eGd�d��Z4Gd�de	�Z5Gd�de�Z6e7dk(�r�ddl8m-Z-ddl9m:Z:ddl;m6Z6ddl<m=Z=e=d�5e6dd d!�"�Z>e>jd#d$d%d&�'�e>jd(d)�*�e>jd+d!d,�-�e>j�d.d/d0�e>j�d1d2d3�e>j�d4d5d6d7d&�8�e>j�d9d:d;�d<eAd=d>fd?�ZBe-�Z,e:�ZCeBd@�e,j�e>dA�B�d&e>_EeBdC�e,j�e>�dDe>_FeBdE�e,j�e>dA�B�d>e>_FdFe>_EdGdHge>_GeBdI�e,j�e>dA�B�d>e>_FdFe>_EdGdHge>_Gde>_HeBdJ�e,j�e>dA�B�d>e>_FdFe>_EdGdHge>_Gd&e>_Ide>_HeBdK�e,j�e>dA�B�d>d>d>�y>y>#1swYy>xYw)L�)�	dataclass�field�replace)	�
TYPE_CHECKING�Dict�Iterable�List�
NamedTuple�Optional�Sequence�Tuple�Union�)�box�errors)�loop_first_last�	loop_last)�	pick_bool)�ratio_distribute�ratio_reduce)�VerticalAlignMethod)�JupyterMixin)�Measurement)�Padding�PaddingDimensions)�
is_renderable)�Segment)�Style�	StyleType)�Text�TextType)�Console�ConsoleOptions�
JustifyMethod�OverflowMethod�RenderableType�RenderResultc�f�eZdZUdZdZded<	dZded<	dZeed<	dZ	eed<	dZ
eed<	d	Zd
ed<	dZd
ed<	dZ
ded<	dZeeed<	dZeeed<	dZeeed<	dZeeed<	dZeed<	dZeed<	ee��Zeded<d!d�Zededfd��Zedefd ��Zy)"�Columna�
Defines a column within a ~Table.

    Args:
        title (Union[str, Text], optional): The title of the table rendered at the top. Defaults to None.
        caption (Union[str, Text], optional): The table caption rendered below. Defaults to None.
        width (int, optional): The width in characters of the table, or ``None`` to automatically fit. Defaults to None.
        min_width (Optional[int], optional): The minimum width of the table, or ``None`` for no minimum. Defaults to None.
        box (box.Box, optional): One of the constants in box.py used to draw the edges (see :ref:`appendix_box`), or ``None`` for no box lines. Defaults to box.HEAVY_HEAD.
        safe_box (Optional[bool], optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.
        padding (PaddingDimensions, optional): Padding for cells (top, right, bottom, left). Defaults to (0, 1).
        collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to False.
        pad_edge (bool, optional): Enable padding of edge cells. Defaults to True.
        expand (bool, optional): Expand the table to fit the available space if ``True``, otherwise the table width will be auto-calculated. Defaults to False.
        show_header (bool, optional): Show a header row. Defaults to True.
        show_footer (bool, optional): Show a footer row. Defaults to False.
        show_edge (bool, optional): Draw a box around the outside of the table. Defaults to True.
        show_lines (bool, optional): Draw lines between every row. Defaults to False.
        leading (bool, optional): Number of blank lines between rows (precludes ``show_lines``). Defaults to 0.
        style (Union[str, Style], optional): Default style for the table. Defaults to "none".
        row_styles (List[Union, str], optional): Optional list of row styles, if more than one style is given then the styles will alternate. Defaults to None.
        header_style (Union[str, Style], optional): Style of the header. Defaults to "table.header".
        footer_style (Union[str, Style], optional): Style of the footer. Defaults to "table.footer".
        border_style (Union[str, Style], optional): Style of the border. Defaults to None.
        title_style (Union[str, Style], optional): Style of the title. Defaults to None.
        caption_style (Union[str, Style], optional): Style of the caption. Defaults to None.
        title_justify (str, optional): Justify method for title. Defaults to "center".
        caption_justify (str, optional): Justify method for caption. Defaults to "center".
        highlight (bool, optional): Highlight cell contents (if str). Defaults to False.
    �r&�header�footer�header_style�footer_style�style�leftr$�justify�topr�vertical�ellipsisr%�overflowN�width�	min_width�	max_width�ratioF�no_wrapr�_index)�default_factory�_cells�returnc��t|g��S)zReturn a copy of this Column.�r=)r��selfs �,/usr/lib/python3/dist-packages/rich/table.py�copyzColumn.copyrs���t�B�'�'�c#�8K�|jEd{���y7��w)z2Get all cells in the column, not including header.Nr@rAs rC�cellszColumn.cellsvs�����;�;���s���c��|jduS)z!Check if this column is flexible.N)r9rAs rC�flexiblezColumn.flexible{s���z�z��%�%rE)r>r)) �__name__�
__module__�__qualname__�__doc__r+�__annotations__r,r-rr.r/r1r3r5r6r�intr7r8r9r:�boolr;r�listr=r	rD�propertyrrGrI�rErCr)r)&s(���< "�F��!�H�!�F��!�H� �L�)� �-� �L�)� �-��E�9��-�%�G�_�%�[�&+�H�#�+�M�!+�H��+���E�8�C�=��\�#�I�x��}�#�_�#�I�x��}�#�_��E�8�C�=��w��G�T��R��F�C�O��%*�4�%@�F�D�!�"�@�(���x� 0�1�����&�$�&��&rEr)c�6�eZdZUdZdZeeed<	dZe	ed<y)�RowzInformation regarding a row.Nr/F�end_section)
rJrKrLrMr/rrrNrVrPrSrErCrUrU�s$��&�!%�E�8�I��%� ��K���LrErUc�4�eZdZUdZeed<	ded<	eed<y)�_CellzA single cell in a table.r/r&�
renderabler3N)rJrKrLrMrrNrrSrErCrXrX�s ��#���!� � ��!�!�"rErXc7�
�eZdZUdZeeed<eeed<ddddejddddddddddd	dd
dddddddd
�de
eefdee
dee
deedeedeejdeedededededededededededeeed eed!eed"eed#eed$eed%d&d'd&d(ed)df6d*�Zeddddd+�de
eefdedededed)dfd,��Zed)efd-��Zej2ded)dfd.��Zed)efd/��Zed)efd0��Zd1d2d3ed)efd4�Zd1d2d5d6d)efd7�Zed)eeeeeffd8��Z e j2ded)dfd9��Z 		d[dddd:d;d<dddddd=�d>d?d@d?d eed!eedeedAd&dBdCdDdEdeedeedFeedGeedHed)dfdI�Z!dddJ�dKed?deedLed)dfdM�Z"d\dN�Z#						d]dP�Z$d1d2d5d6d)eefdQ�Z%edReedSeedFed)eefdT��Z&d1d2dUedVed)ee'fdW�Z(dUed)efdX�Z)d1d2d5d6dVed)efdY�Z*d1d2d5d6dReed)dOfdZ�Z+y)^�TableaA console renderable to draw a table.

    Args:
        *headers (Union[Column, str]): Column headers, either as a string, or :class:`~rich.table.Column` instance.
        title (Union[str, Text], optional): The title of the table rendered at the top. Defaults to None.
        caption (Union[str, Text], optional): The table caption rendered below. Defaults to None.
        width (int, optional): The width in characters of the table, or ``None`` to automatically fit. Defaults to None.
        min_width (Optional[int], optional): The minimum width of the table, or ``None`` for no minimum. Defaults to None.
        box (box.Box, optional): One of the constants in box.py used to draw the edges (see :ref:`appendix_box`), or ``None`` for no box lines. Defaults to box.HEAVY_HEAD.
        safe_box (Optional[bool], optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.
        padding (PaddingDimensions, optional): Padding for cells (top, right, bottom, left). Defaults to (0, 1).
        collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to False.
        pad_edge (bool, optional): Enable padding of edge cells. Defaults to True.
        expand (bool, optional): Expand the table to fit the available space if ``True``, otherwise the table width will be auto-calculated. Defaults to False.
        show_header (bool, optional): Show a header row. Defaults to True.
        show_footer (bool, optional): Show a footer row. Defaults to False.
        show_edge (bool, optional): Draw a box around the outside of the table. Defaults to True.
        show_lines (bool, optional): Draw lines between every row. Defaults to False.
        leading (bool, optional): Number of blank lines between rows (precludes ``show_lines``). Defaults to 0.
        style (Union[str, Style], optional): Default style for the table. Defaults to "none".
        row_styles (List[Union, str], optional): Optional list of row styles, if more than one style is given then the styles will alternate. Defaults to None.
        header_style (Union[str, Style], optional): Style of the header. Defaults to "table.header".
        footer_style (Union[str, Style], optional): Style of the footer. Defaults to "table.footer".
        border_style (Union[str, Style], optional): Style of the border. Defaults to None.
        title_style (Union[str, Style], optional): Style of the title. Defaults to None.
        caption_style (Union[str, Style], optional): Style of the caption. Defaults to None.
        title_justify (str, optional): Justify method for title. Defaults to "center".
        caption_justify (str, optional): Justify method for caption. Defaults to "center".
        highlight (bool, optional): Highlight cell contents (if str). Defaults to False.
    �columns�rowsN)rrFTr�noneztable.headerztable.footer�center)�title�captionr6r7r�safe_box�padding�collapse_padding�pad_edge�expand�show_header�show_footer�	show_edge�
show_lines�leadingr/�
row_stylesr-r.�border_style�title_style�
caption_style�
title_justify�caption_justify�	highlight�headersr`rar6r7rrbrcrdrerfrgrhrirjrkr/rlr-r.rmrnrorpr$rqrrr>c��g|_g|_||_||_||_||_||_||_tj|�|_
|	|_|
|_||_
||_|
|_||_||_||_||_|xsd|_|xsd|_||_||_||_||_||_||_t9|xsg�|_|jj<}|D]G}t?|t@�r|jC|���&tE|j�|_#||��Iy)Nr*)r+)$r\r]r`rar6r7rrbr�unpack�_paddingre�_expandrgrhrirjrkrdr/r-r.rmrnrorprqrrrQrl�append�
isinstance�str�
add_column�lenr;)rBr`rar6r7rrbrcrdrerfrgrhrirjrkr/rlr-r.rmrnrorprqrrrs�
append_columnr+s                             rC�__init__zTable.__init__�s6��:&(���!��	���
������
�"������ ��
����w�/��
� ��
����&���&���"���$������ 0�����
�(�.�B���(�.�B���(���&���*���.;���0?���"���/3�J�4D�"�/E������+�+�
��	&�F��&�#�&����v��.� #�D�L�L� 1��
��f�%�	&rE)rcrdrerfc� �||d||ddd||d��S)a�Get a table with no lines, headers, or footer.

        Args:
            *headers (Union[Column, str]): Column headers, either as a string, or :class:`~rich.table.Column` instance.
            padding (PaddingDimensions, optional): Get padding around cells. Defaults to 0.
            collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to True.
            pad_edge (bool, optional): Enable padding around edges of table. Defaults to False.
            expand (bool, optional): Expand the table to fit the available space if ``True``, otherwise the table width will be auto-calculated. Defaults to False.

        Returns:
            Table: A table instance.
        NF)rrcrdrgrhrirerfrS)�clsrcrdrerfrss      rC�gridz
Table.grid�s,��*�
���-������

�
	
rEc�:�|jxs|jduS)z-Setting a non-None self.width implies expand.N)rwr6rAs rCrfzTable.expands���|�|�5�t�z�z��5�5rEc��||_y)zSet expand.N)rw)rBrfs  rCrfzTable.expand s����rEc��d}|jr|jr|dz
}|jr|t|j�dz
z
}|S)z'Get extra width to add to cell content.r�r)rrir|r\)rBr6s  rC�_extra_widthzTable._extra_width%sC�����8�8�����Q�J�E��8�8��S����&��*�*�E��rEc�,�t|j�S)zGet the current number of rows.)r|r]rAs rC�	row_countzTable.row_count/s���4�9�9�~�rE�consoler"�indexc��tj�}|jr7||j|j|t	|j�z�z
}|j
|j}|�||j|�z
}|S)zGet the current row style.)r�nullrl�	get_styler|r]r/)rBr�r�r/�	row_styles     rC�
get_row_stylezTable.get_row_style4st���
�
����?�?��W�&�&�t���u�s�4�?�?�?S�7S�'T�U�U�E��I�I�e�$�*�*�	�� ��W�&�&�y�1�1�E��rE�optionsr#c	�6�|j}|j�|j}|dkrtdd�S|j}t	|j||j
||z
���}|j}|jD�cgc]}|||j
|�|���}}t	d�|D��|z}|j�t	d�|D��|zn|j}	t||	�}
|
j|j�}
|
Scc}w)Nrc3�4K�|]}|j���y�w�N)�minimum��.0�measurements  rC�	<genexpr>z)Table.__rich_measure__.<locals>.<genexpr>T�����D���#�#�D���c3�4K�|]}|j���y�wr�)�maximumr�s  rCr�z)Table.__rich_measure__.<locals>.<genexpr>Wr�r�)r8r6rr��sum�_calculate_column_widths�update_width�_measure_columnr\�clampr7)rBr�r�r8�extra_widthr��column�measurements�
minimum_width�
maximum_widthr�s           rC�__rich_measure__zTable.__rich_measure__>s&���%�%�	��:�:�!��
�
�I��q�=��q�!�$�$��'�'����)�)���-�-�i�+�.E�F�
�
�	�
�.�.���,�,�
��
�G�W�%9�%9�)�%D�f�M�
��
�

�D�|�D�D�{�R�	�
�
�
�"�
�D�|�D�D�{�R����	�
"�-��?��!�'�'����7�����
s�	 Dc��|jS)zGet cell padding.)rvrAs rCrcz
Table.padding_s���}�}�rEc�:�tj|�|_|S)zSet cell padding.)rrurv)rBrcs  rCrcz
Table.paddingds�� ���w�/��
��rEr0r2r4)r-r.r/r1r3r5r6r7r8r9r:r+r&r,r1r3rr5r%r8r9r:c��tt|j�|||xsd|xsd|xsd||||	|
|||
��}|jj|�y)a�Add a column to the table.

        Args:
            header (RenderableType, optional): Text or renderable for the header.
                Defaults to "".
            footer (RenderableType, optional): Text or renderable for the footer.
                Defaults to "".
            header_style (Union[str, Style], optional): Style for the header, or None for default. Defaults to None.
            footer_style (Union[str, Style], optional): Style for the footer, or None for default. Defaults to None.
            style (Union[str, Style], optional): Style for the column cells, or None for default. Defaults to None.
            justify (JustifyMethod, optional): Alignment for cells. Defaults to "left".
            vertical (VerticalAlignMethod, optional): Vertical alignment, one of "top", "middle", or "bottom". Defaults to "top".
            overflow (OverflowMethod): Overflow method: "crop", "fold", "ellipsis". Defaults to "ellipsis".
            width (int, optional): Desired width of column in characters, or None to fit to contents. Defaults to None.
            min_width (Optional[int], optional): Minimum width of column, or ``None`` for no minimum. Defaults to None.
            max_width (Optional[int], optional): Maximum width of column, or ``None`` for no maximum. Defaults to None.
            ratio (int, optional): Flexible ratio for the column (requires ``Table.expand`` or ``Table.width``). Defaults to None.
            no_wrap (bool, optional): Set to ``True`` to disable wrapping of this column.
        r*)r;r+r,r-r.r/r1r3r5r6r7r8r9r:N)r)r|r\rx)rBr+r,r-r.r/r1r3r5r6r7r8r9r:r�s               rCr{zTable.add_columnjsd��J��t�|�|�$���%�+��%�+���+�2���������
�� 	
�����F�#rE�r/rV�renderablesrVc��dtddddfd�}t|�}|j}t|�t|�krg|�dgt|�t|�z
z�}t	|�D]�\}}|t|�k(rKt|��}	|j
D]}
||	t
d���|jj|	�n||}	|�
||	d��pt|�r
||	|���tjd	t|�j�d
���|j
jt||���y)a�Add a row of renderables.

        Args:
            *renderables (None or renderable): Each cell in a row must be a renderable object (including str),
                or ``None`` for a blank cell.
            style (StyleType, optional): An optional style to apply to the entire row. Defaults to None.
            end_section (bool, optional): End a section and draw a line. Defaults to False.

        Raises:
            errors.NotRenderableError: If you add something that can't be rendered.
        r�rYr&r>Nc�:�|jj|�yr�)r=rx)r�rYs  rC�add_cellzTable.add_row.<locals>.add_cell�s���M�M� � ��,rE)r;r*zunable to render z1; a string or other renderable object is requiredr�)r)rQr\r|�	enumerater]r rxrr�NotRenderableError�typerJrU)rBr/rVr�r��cell_renderablesr\r�rYr��_s           rC�add_rowz
Table.add_row�sK��$	-�V�	-�1A�	-�d�	-�>B�+�=N���,�,���� �3�w�<�/� �!� ���3�w�<�#�.>�*?�?�@� ��"+�+;�!<�	��E�:���G��$��u�-�����/�A��V�T�"�X�.�/����#�#�F�+� �����!����$��z�*����,��/�/�'��Z�(8�(A�(A�'B�Bs�t���	� 	
�	�	����5�k�B�CrEc�F�|jrd|jd_yy)z2Add a new section (draw a line after current row).T���N)r]rVrAs rC�add_sectionzTable.add_section�s ���9�9�(,�D�I�I�b�M�%�rEr'c	#���K�|jstd���y|j}|j�|j}|j}|j�|j
||z
��}t|�|z}|j||jd���	d
dtdtddddf��fd	�
}|jrE||jtj|jd
�|j ��Ed{���|j#��|�Ed{���|j$rF||j$tj|j&d�|j(��Ed{���yy7�r7�Y7�
�w)N�
)r6rr�height�textr/r1r$r>r'c���t|t�r�j||d��n|}�j|�j	|����S)NF)r/rr�r1)r�)ryrz�
render_str�render�update)r�r/r1�render_textr��render_optionss    ��rC�render_annotationz1Table.__rich_console__.<locals>.render_annotation�sY���
�d�C�(��"�"�4�u��"�F��
�
�>�>��^�%:�%:�7�%:�%K�"��
rEztable.title)r/r1z
table.caption)r_)r\rr8r6r�r�r�r�r�rrr!rr`r�
pick_firstrnrp�_renderrarorq)	rBr�r�r8r��widths�table_widthr�r�s	 `      @rC�__rich_console__zTable.__rich_console__�st������|�|��$�-����%�%�	��:�:�!��
�
�I��'�'���.�.��W�)�)�)�k�*A�B�
���&�k�K�/�� ��������(�
��
JR�
	��
	�#,�
	�7F�
	�
�
	��:�:�(��
�
��&�&�t�'7�'7��G��*�*��
�
�
�<�<����@�@�@��<�<�(�����&�&�t�'9�'9�?�K��,�,��
�
��

��
	A��
�s7�DE=�E7�E=�E9� AE=�0E;�1E=�9E=�;E=c
�,�|j}|j}|D�cgc]}|j|||���}}|D�cgc]}|jxsd��}}|j}	|j
}
|j�r|D�cgc]}|js�|jxsd��!}}t|�r�t||�D��cgc]\}}|jrdn|j��!}
}}|D�cgc]1}|jr#|jxsd|	|j�z��3}}|t|
�z
}t|||�}t|�}t!|�D]&\}}|js�|
|t#|�z||<�(t|�}||kDr�|j%||D�cgc]}|jduxr
|j&��!c}|�}t|�}||kDr+||z
}t)|dgt+|�z||�}t|�}t||�D��cgc]'\}}|j||j-|�|���)}}}|D�cgc]}|jxsd��}}||kr|js|j.�i||j.|
z
krW|j.�|nt1|j.|
z
|�}t||z
|�}t||�D��cgc]
\}}||z��}}}|Scc}wcc}wcc}wcc}}wcc}wcc}wcc}}wcc}wcc}}w)zNCalculate the widths of each column, including padding, not including borders.rrN)r8r\r�r��_get_padding_widthr�rfrIr9�any�zipr6r;r�r�iterr��next�_collapse_widthsr:rr|r�r7�min)rBr�r�r8r\r��width_ranges�_ranger��get_padding_widthr��col�ratios�fixed_widths�flex_minimum�flexible_width�flex_widths�iter_flex_widthsr�r��excess_widthr6�
_max_width�
pad_widths�_width�pads                          rCr�zTable._calculate_column_widthss:���%�%�	��,�,��IP�
�?E�D� � ��'�6�:�
��
�5A�A�&�&�.�.�%�A�%�A��A� �3�3���'�'���;�;�07�H��3�<�<�c�i�i�n�1�n�H�F�H��6�{�+.�l�G�*D� �&��� ���A�f�n�n�<� �� �#*� ������\�\�&�Q�*;�F�M�M�*J�J� �� �
"+�S��->�!>��.�~�v�|�T��#'��#4� �%.�w�%7�U�M�E�6����(4�U�(;�d�CS�>T�(T��u�
�U��&�k����"��*�*��MT�U�6�&�,�,�$�&�=�v�~�~�+=�=�U���F�
�f�+�K��Y�&�*�Y�6��%�l�Q�C�#�f�+�4E�v�v�V��!�&�k��&)���%9��!�E�6��$�$�W�g�.B�.B�5�.I�6�R��L��9E�E�f�f�n�n�)��)�E�F�E��)�#�����N�N�&�;�$�.�.�;�:V�+W��>�>�)������+�5�y�A�
�
*�*�{�*B�F�K�J�69�&�*�6M�N�{�v�s�f�s�l�N�F�N��
��q
��B��I�� �� �� V����F��Os:�K&�K+�?K0�K0�?$K5�*6K;�$L
�,L�L�Lr��wrapablec����t|�}||z
}t|�r�|r�|dkDr�td�t||�D���t�fd�t||�D��}�|z
}t||�D��	cgc]\}}	|�k(r|	rdnd��}
}}	t|
�r|s	|St	||�gt|�z}t
||
||�}t|�}||z
}|r|dkDr��|Scc}	}w)aMReduce widths so that the total is under max_width.

        Args:
            widths (List[int]): List of widths.
            wrapable (List[bool]): List of booleans that indicate if a column may shrink.
            max_width (int): Maximum width to reduce to.

        Returns:
            List[int]: A new list of widths.
        rc3�,K�|]\}}|s�	|���y�wr�rS)r�r6�
allow_wraps   rCr�z)Table._collapse_widths.<locals>.<genexpr>Ws����!�/�e�Z�J�E�!�s�
�c3�:�K�|]\}}|r|�k7r|nd���y�w)rNrS)r�r6r��
max_columns   �rCr�z)Table._collapse_widths.<locals>.<genexpr>Zs+�����(�)��z�(�E�Z�,?�E�Q�F�(�s�r)r�r��maxr�r�r|r)
r�r�r�r8�total_widthr��second_max_column�column_differencer6r�r��
max_reducer�s
            @rCr�zTable._collapse_widthsEs����&�k��"�Y�.���x�=��,��"2� �!�36�v�x�3H�!��
�%(�(�-0���-B�(�%�!�%/�1B�$B�!�.1���-B��)��z�!�J�.�:�Q�A�E�����6�{�*;���
�"�,�0A�B�C�c�&�k�Q�
�%�l�F�J��O��!�&�k��*�Y�6��'�,��"2�(�
��s�2C�column_indexr�c#��������K�|j�|j�|j�t��}|dk(�|t	|j
�dz
k(�i�dtdtdtttttff������fd�}g}|j}|j}|jr=||jxsd�||j�z}	||	|jf�||jxsd�}
|jD]}||
|f��|j r=||j"xsd�||j"�z}|||j$f�|rTt&}
t)|�D]?\}}\}}t+||
||||��t-|dd	�xs|j.����Ay	|D]-\}}t+||t-|dd	�xs|j.����/y	�w)
z3Get all the cells with padding and optional header.rr�	first_row�last_rowr>c�����j||f�}|r|S�
\}}}}�	r"�
std||z
�}|std||z
�}�s�
rd}�rd}|rd}|rd}||||f}|�||f<|S)Nr)�getr�)r�r��cachedr2�right�bottomr0rv�_padding_cacherd�first_column�last_columnrercs        ������rC�get_paddingz%Table._get_cells.<locals>.get_padding{s����#�'�'��H�(=�>�F���
�'.�$�C�����#��q�$��,�/�D�� ��C�&�L�1�F����D���E���C���F��U�F�D�1�H�4<�N�I�x�0�1��OrEr*r3N)rdrercr�r|r\rPr
rOrxr�rgr-r+r/rGrhr.r,rrrX�getattrr3)rBr�r�r��any_paddingr��	raw_cells�_appendr�r-�
cell_style�cellr.�_Padding�first�lastr/rYr�rdr�r�rercs                  @@@@@@rC�
_get_cellszTable._get_cellsls�����
 �0�0���=�=���,�,���'�l��#�q�(��"�c�$�,�,�&7�!�&;�;��MO��	�4�	�4�	�E�#�s�C�QT�BT�<U�	�	�2?A�	��"�"���%�%�	����$�T�%6�%6�%<�"�=�	��#�#�A��L�
�\�6�=�=�1�2��v�|�|�1�r�2�
��L�L�	(�D��Z��&�'�	(����$�T�%6�%6�%<�"�=�	��#�#�A��L�
�\�6�=�=�1�2���H�4C�I�4N�
�0��t�0�e�Z����Z��U�D�)A�B��J�
�D�9�L�V�_�_���
�&/�
�!��z�����J�
�D�9�L�V�_�_���
�s�G,G4c�n�|j\}}}}|jr|dkDrtd||z
�}||zS)zGet extra width from padding.r)rcrdr�)rBr�r��	pad_right�pad_lefts     rCr�zTable._get_padding_width�sA��$(�L�L�!��9�a��� � ��a���q�(�Y�"6�7���)�#�#rEc���|j}|dkrtdd�S|j|j�}|j�5t|j|z|j|z�j|�Sg}g}|j}|j}	tj}
|j||j|�D])}|
|||j�\}}
||�|	|
��+t|rt|�nd|rt|�n|�j|�}|j|j�dn|j|z|j�d�}|S|j|z�}|S)z0Get the minimum and maximum width of the column.rrN)
r8rr�r;r6�with_maximumrxr�rrYr�r�r7)rBr�r�r�r8�
padding_width�
min_widths�
max_widths�
append_min�
append_max�get_render_widthr��_min�_maxr�s               rCr�zTable._measure_column�st���%�%�	��q�=��q�!�$�$��/�/��
�
�>�
��<�<�#�����}�,�f�l�l�]�.J���l�9�%�
&�!#�
� "�
��&�&�
��&�&�
�&�?�?���O�O�G�V�]�]�F�C�	�D�)�'�7�D�O�O�L�J�D�$��t���t��	�
"�)�C�
�O�q�)�C�
�O�y�
��,�y�
!�	�"�'�'��$�$�,�D�&�2B�2B�]�2R��$�$�,�D�
����39�2B�2B�]�2R�
���rEc#�z���*�+�,�-K��j�jxsd�}|�j�jxsd�z}��fd�t�j�D�}tt
|��}�jr;�jj|t�j�j���nd}|r�js|j�n|}tj�}	�j}
�j}�j}�j }
�j"}�j$}t�*|r��*|j&|��*|j(|��*|j*|�f�*|j,|��*|j.|��*|j0|�f�*|j2|��*|j4|��*|j6|�fg}|
r!�*|j9|�|���|	��ng}�j:}�j}tt=|��D�]H\}\}}}|xr|�,|xr|�+�,s�+s�j>||z
nd}d}g}�,s�+rtAjB�}n||�|r|dz
n|��}t
|||
�D]�\}}}|jE||jF|jH|jJd��}�jM|jN|||j�|z��}tQ|tS|��}|jU|���tQd�|D���-dtVtVtd	d
dtXdt@d
tVtVtf
�*�+�,�-fd�} t
||||
�D��!��cgc]@\}}!}}�*j[| ||!j\|||!j�|z�||���Bc}}}!}|dd|r�|r#|r!�*|j_|d|
��|���|	��||rdn|rdnd\}"}#}$|$j`jc�r|$n)�*|$j`|jd|$jz�}%tg|�D]9}&|
r|"��ti|�D]\}'}(|(|&Ed{���|'r�|%���|
r|#��|	���;n(tg|�D]}&|D]}(|(|&Ed{����|	���|r%|r#|r!�*|j_|d|
��|���|	��|xr|jj})|s���|s|s|)s���|r���|r|tS|�dz
k\r���|r�,r��|r!�*|j_|d|
��|z|���n�*|j_|d|
��|���|	����K|r"|
r�*|jm|�|���|	��yyycc}}}!}w7��7��w)Nr*c3�J�K�|]\}}�j�||����y�wr�)r)r�r�r�r�rBs   ��rCr�z Table._render.<locals>.<genexpr>�s*�����
�$��f�
�O�O�G�\�6�:�
�s� #)�safer)r6r1r:r5r��r/c3�2K�|]}t|����y�wr�)r|)r�r�s  rCr�z Table._render.<locals>.<genexpr>>s����9�4�S��Y�9�s�r�r3rr6r/r>c����rd}n�rd}|dk(r�j||�|�S|dk(r�j||�|�S�j||�|�S)Nr�r2�middle)�	align_top�align_middle�align_bottom)r�r3r6r/�_Segment�
footer_row�
header_row�
row_heights    ����rC�
align_cellz!Table._render.<locals>.align_cell@sj����'�H��$�H��u�$�#�-�-�d�E�:�u�M�M���)�#�0�0��u�j�%�P�P��,�,�T�5�*�e�L�LrE�foot)�edgerr��head�mid�row)7r�r/rmr�r\rQr�r�
substituterrbrg�get_plain_headed_boxr�linerhrirjrk�	head_left�
head_right�
head_vertical�	foot_left�
foot_right�
foot_vertical�mid_left�	mid_right�mid_vertical�get_topr�rr]rr�r�r1r:r5�render_linesrYr�r|rxr	rO�	set_shaper3�get_rowr��strip�background_style�rangerrV�
get_bottom).rBr�r�r��table_stylerm�
_column_cells�	row_cells�_box�new_liner\rgrhrirjrk�box_segmentsr�r�r�rr�row_cellr#�
max_heightrGr�r6r�r�r��linesr�_cellr0r��_divider�divider�line_no�	last_cell�
rendered_cellrVrrrrs.``                                        @@@@rCr�z
Table._render�s
������'�'��
�
�(8�b�9��"�W�%6�%6�t�7H�7H�7N�B�%O�O��
�(1�$�,�,�(?�
�
�.2�#�}�2E�-F�	�
�x�x�
�H�H����i��
�
�w�7G�7G�H�
 �
��	
�/3�4�;K�;K�t�(�(�*�QU���<�<�>���,�,���&�&���&�&���N�N�	��_�_�
��,�,������T�^�^�\�:��T�_�_�l�;��T�/�/��>���T�^�^�\�:��T�_�_�l�;��T�/�/��>���T�]�]�L�9��T�^�^�\�:��T�.�.��=���L�"��t�|�|�F�3�\�B�B����L��*�*�
��%�%�	�.7��	�8R�.S�u	#�*�E�*�E�4���.�;�J��-�+�J�#�:��	�	�%�+�-�.��
�
�J�/1�E��Z�!�J�J�L�	�%�!�'��5�1�9��O��	�(+�6�8�W�'E�
$�#��t�V�!(����"�N�N�"�N�N�#�_�_��"0�"�� �,�,��O�O�"�#�D�J�J�/�)�;�-���
!��S��Z�8�
����U�#�
$� �9�5�9�9�J�
M��4��=�)�
M�/�
M��
M��	
M�
�d�7�m�$�
M�
M�836�f�h��w�2W���/�E�5�$���"�"�������!�%�+�+�.��:�	���	��E�!�H���K�"����V�V�)��D�l���#�N�(4�%�Q�4�a�UV�(X�%��e�X�
 �}�}�*�*�,��!� �
�
�y�'A�'A�H�N�N�'R��� %�Z�0�	#�G� �"�
�4=�e�4D�*�0�	�=�#0��#9�9�9�(�")�M�*�!�#��"�N�	#� %�Z�0�#�G�).�:�
�#0��#9�9�9�:�"�N�#���+���L�L���i�L�@�,������1�#�/�/�K���w�+��(�U�c�)�n�q�6H�-H�(�Z��&� �L�L���Y�L�G�'�Q�(���
'� �L�L���Y�L�G����#�N�ku	#�n�I��4�?�?�6�2�L�A�A��N��4��I�D:��:�sX�NV;�$AV.�)B4V;�V6
�V;�%.V;�V9
�AV;�V;�#V;�'V;�<V;�A5V;�9V;)r*r*)r>N)r�r"r�r#r>r'),rJrKrLrMr	r)rNrUr�
HEAVY_HEADrrzrr!rO�BoxrPrrrr~�classmethodr�rRrf�setterr�r�r�rr�r
rcr{r�r�r�r�r�rXrr�r�r�rSrErCr[r[�st���>�&�\��
�s�)�O�
%)�&*�#�#'�!$���#'�%+�!&��� �!�� ��!�48�,:�,:�,0�+/�-1�)1�+3��7>&�����$�>&���!�>&��(�#�	>&�
��}�>&��C�=�
>&��c�g�g�
�>&��4�.�>&�#�>&��>&��>&��>&��>&��>&��>&� �!>&�"�#>&�$�%>&�&�X�i�0�1�'>&�(�y�)�)>&�*�y�)�+>&�,�y�)�->&�.�i�(�/>&�0 �	�*�1>&�2'�3>&�4)�5>&�6�7>&�8
�9>&�@�&'�!%���

�����$�
�#�
��	
�
�
��

�
�
��
�@�6��6��6��]�]��T��d������c������3�����Y��s��y��� ��+;��	��B���s�C��c�1�2����
�^�^��0��W����$&�#%�5$�
-1�,0�%)�#)�*/�%/�#�#'�#'�#��5$� �5$�!�5$�
�y�)�5$��y�)�
5$��	�"�5$�!�5$�(�5$�#�5$���}�5$��C�=�5$��C�=�5$���}�5$��5$� 
�!5$�t&*�!�	-D��/�0�-D��	�"�-D��	-D�

�-D�^-�-� �-�+;�-�	�-�^>� �>�+;�>�	
�c��>�@�$��#�Y�$�*.�t�*�$�AD�$�	
�c��$��$�LG� �G�03�G�=C�G�	�%��G�R$�s�$�s�$�&��&�"�&��	&�

�&�Pr� �r�+;�r�EI�#�Y�r�	�rrEr[�__main__)r")�ReprHighlighter)r[)�timerzTable renderzStar Wars MovieszRich example tabler�)r`rarq�Released�bright_cyan�cyanT)r-r/r:�Title�magentarz
Box Office�green)r1r/zDec 20, 2019z Star Wars: The Rise of Skywalkerz$952,110,690zMay 25, 2018zSolo: A Star Wars Storyz$393,151,347zDec 15, 2017z!Star Wars Ep. V111: The Last Jediz$1,332,539,889zon blackr�zDec 16, 2016zRogue One: A Star Wars Storyz$1,332,439,889r�r>Nc��tj�tjt|��tj�yr�)r��print�rulerr)r�s rCr+r+�s$���M�M�O��L�L��4��)��M�M�OrEz
Example Tabler_r�zexpand=True�2zwidth=50F�dimr^zrow_styles=['dim', 'none']z%leading=1, row_styles=['dim', 'none']z+show_lines=True, row_styles=['dim', 'none'])J�dataclassesrrr�typingrrrr	r
rrr
rr*rr�_looprr�_pickr�_ratiorr�alignr�jupyterr�measurerrcrr�protocolr�segmentrr/rrr�r r!r�r"r#r$r%r&r'r)rUrXr[rJ�rich.console�rich.highlighterrL�
rich.table�_timerrM�tabler{r�rzr+rrrUrfr6rlrkrjrSrErC�<module>rhs���1�1�
�
�
��-��2�&�!� �/�#��#� �����W&�W&��W&�t�M�M��M�#�J�#�@�L�@�F�z��$�0�)��	�~�	�G/��$�(�#�
��	����]�&�$�	�	
�	����	��2�
����w�g��F�
�
�
��.��	
�
	�
�
�n�&?��P�
�
�
��/����	�	
�	�
�
��*��	
�	��	��	�
�)��#�%�	�����
�
�e�X�
�.�����}���
�
�e������z���
�
�e�X�
�.�������!�6�?����+�,��
�
�e�X�
�.�������!�6�?�����
��6�7��
�
�e�X�
�.�������!�6�?��������
��<�=��
�
�e�X�
�.�OG/�G/��G/�G/�s
�!F5J � J)

Zerion Mini Shell 1.0