o
    Ëý°j•�  ã                   @   s8  d dl mZmZmZ d dlmZmZmZmZm	Z	m
Z
mZmZmZ ddlmZmZ ddlmZmZ ddlmZ ddlmZmZ ddlmZ dd	lmZ dd
lmZ ddlm Z m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z'm(Z( ddl)m*Z*m+Z+ er†ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 eG dd„ dƒƒZ3eG dd„ dƒƒZ4G dd„ de	ƒZ5G dd„ deƒZ6e7dk�ršd dl8m-Z- d dl9m:Z: d dl;m6Z6 ddl<m=Z= e=dƒ�Æ e6dd d!d"�Z>e>j?d#d$d%d&d'� e>j?d(d)d*� e>j?d+d!d,d-� e> @d.d/d0¡ e> @d1d2d3¡ e>j@d4d5d6d7d&d8� e> @d9d:d;¡ d<eAd=d>fd?d@„ZBe-ƒ Z,e:ƒ ZCeBdAƒ e,jDe>dBdC� d&e>_EeBdDƒ e, De>¡ dEe>_FeBdFƒ e,jDe>dBdC� d>e>_FdGe>_EdHdIge>_GeBdJƒ e,jDe>dBdC� d>e>_FdGe>_EdHdIge>_Gde>_HeBdKƒ e,jDe>dBdC� d>e>_FdGe>_EdHdIge>_Gd&e>_Id e>_HeBdLƒ e,jDe>dBdC� W d>  ƒ d>S 1 �s“w   Y  d>S d>S )Mé    )Ú	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                   @   s.  e Zd ZU dZdZded< 	 dZded< 	 dZeed< 	 dZ	eed< 	 dZ
eed< 	 d	Zd
ed< 	 dZded< 	 dZded< 	 dZee ed< 	 dZee ed< 	 dZee ed< 	 dZee ed< 	 dZeed< 	 dZeed< 	 eed�Zed ed< d$dd„Zeded fd d!„ƒZedefd"d#„ƒZdS )%ÚColumnzDefines a column in a table.Ú 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                 C   s   t | g d�S )zReturn a copy of this Column.©r;   )r   ©Úself© r@   ú‰/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_vendor/rich/table.pyÚcopyV   s   zColumn.copyc                 c   s   � | j E dH  dS )z2Get all cells in the column, not including header.Nr=   r>   r@   r@   rA   ÚcellsZ   s   €zColumn.cellsc                 C   s
   | j duS )z!Check if this column is flexible.N)r7   r>   r@   r@   rA   Úflexible_   ó   
zColumn.flexible)r<   r'   ) Ú__name__Ú
__module__Ú__qualname__Ú__doc__r)   Ú__annotations__r*   r+   r   r,   r-   r/   r1   r3   r4   r
   Úintr5   r6   r7   r8   Úboolr9   r   Úlistr;   r   rB   Úpropertyr   rC   rD   r@   r@   r@   rA   r'   &   sH   
 
r'   c                   @   s0   e Zd ZU dZdZee ed< 	 dZe	ed< dS )ÚRowzInformation regarding a row.Nr-   FÚend_section)
rF   rG   rH   rI   r-   r
   r   rJ   rP   rL   r@   r@   r@   rA   rO   e   s   
 rO   c                   @   s.   e Zd ZU dZeed< 	 ded< 	 eed< dS )Ú_CellzA single cell in a table.r-   r%   Ú
renderabler1   N)rF   rG   rH   rI   r   rJ   r   r@   r@   r@   rA   rQ   p   s   
 rQ   c                7   @   sj  e Zd ZU dZee ed< ee ed< ddddej	ddddddddddd	dd
ddddddddœde
eef dee dee dee dee deej dee dededededededededededeee  d ee d!ee d"ee d#ee d$ee d%d&d'd&d(ed)df6d*d+„Zeddddd,œde
eef dedededed)d fd-d.„ƒZed)efd/d0„ƒZejded)dfd1d0„ƒZed)efd2d3„ƒZed)efd4d5„ƒZd6d7d8ed)efd9d:„Zd6d7d;d<d)efd=d>„Zed)eeeeef fd?d@„ƒZ e jded)d fdAd@„ƒZ 	B	BdlddddCdDdEddddddFœdGdHdIdHd ee d!ee dee dJd&dKdLdMdNdee dee dOee dPee dQed)dfdRdS„Z!dddTœdUedH dee dVed)dfdWdX„Z"	6	7	;	<	)	YdmdZd[„Z#d6d7d;d<d)ee fd\d]„Z$ed^ee d_ee dOed)ee fd`da„ƒZ%d6d7dbedced)ee& fddde„Z'dbed)efdfdg„Z(d6d7d;d<dced)efdhdi„Z)d6d7d;d<d^ee d)dYfdjdk„Z*dS )nÚTablea  A 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)r   r   FTr   Únoneztable.headerztable.footerÚcenter)ÚtitleÚcaptionr4   r5   r   Ú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ÚheadersrX   rY   r4   r5   r   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   r-   rd   r+   r,   re   rf   rg   rh   r#   ri   rj   r<   c                G   sú   g | _ g | _|| _|| _|| _|| _|| _|| _t 	|¡| _
|	| _|
| _|| _|| _|| _|| _|| _|| _|| _|p<d| _|pAd| _|| _|| _|| _|| _|| _|| _t|pYg ƒ| _| j j}|D ]}t|t ƒrp| j!|d� qbt"| j ƒ|_#||ƒ qbd S )Nr(   )r)   )$rT   rU   rX   rY   r4   r5   r   rZ   r   ÚunpackÚ_paddingr]   Ú_expandr_   r`   ra   rb   rc   r\   r-   r+   r,   re   rf   rg   rh   ri   rj   rM   rd   ÚappendÚ
isinstanceÚstrÚ
add_columnÚlenr9   )r?   rX   rY   r4   r5   r   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   r-   rd   r+   r,   re   rf   rg   rh   ri   rj   rk   Úappend_columnr)   r@   r@   rA   Ú__init__ž   sD   



ûzTable.__init__)r[   r\   r]   r^   c                G   s   | |d||ddd||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)r   r[   r\   r_   r`   ra   r]   r^   r@   )Úclsr[   r\   r]   r^   rk   r@   r@   rA   Úgridß   s   ÷z
Table.gridc                 C   s   | j p| jduS )z-Setting a non-None self.width implies expand.N)rn   r4   r>   r@   r@   rA   r^      s   zTable.expandc                 C   s
   || _ dS )zSet expand.N)rn   )r?   r^   r@   r@   rA   r^     rE   c                 C   s4   d}| j r| jr|d7 }| j r|t| jƒd 7 }|S )z'Get extra width to add to cell content.r   é   r   )r   ra   rs   rT   )r?   r4   r@   r@   rA   Ú_extra_width
  s   zTable._extra_widthc                 C   s
   t | jƒS )zGet the current number of rows.)rs   rU   r>   r@   r@   rA   Ú	row_count  rE   zTable.row_countÚconsoler!   Úindexc                 C   sR   t  ¡ }| jr|| | j|t| jƒ  ¡7 }| j| j}|dur'|| |¡7 }|S )zGet the current row style.N)r   Únullrd   Ú	get_stylers   rU   r-   )r?   r{   r|   r-   Ú	row_styler@   r@   rA   Úget_row_style  s   zTable.get_row_styleÚoptionsr"   c                    s¾   ˆj ‰| jd ur| j‰ˆdk rtddƒS | j}t|  ˆˆ ˆ| ¡¡ƒ‰| j‰ ‡ ‡‡‡fdd„| jD ƒ}tdd„ |D ƒƒ| }| jd u rOtdd„ |D ƒƒ| n| j}t||ƒ}| 	| j
¡}|S )Nr   c                    s   g | ]}ˆ ˆˆ  ˆ¡|ƒ‘qS r@   )Úupdate_width©Ú.0Úcolumn©Ú_measure_columnr{   r6   r�   r@   rA   Ú
<listcomp>4  s    ÿÿz*Table.__rich_measure__.<locals>.<listcomp>c                 s   ó   � | ]}|j V  qd S ©N)Úminimum©r„   Úmeasurementr@   r@   rA   Ú	<genexpr>9  ó   € z)Table.__rich_measure__.<locals>.<genexpr>c                 s   r‰   rŠ   ©ÚmaximumrŒ   r@   r@   rA   rŽ   <  r�   )r6   r4   r   ry   ÚsumÚ_calculate_column_widthsr‚   r‡   rT   Úclampr5   )r?   r{   r�   Úextra_widthÚmeasurementsÚminimum_widthÚmaximum_widthr�   r@   r†   rA   Ú__rich_measure__#  s0   

ÿÿþÿ
ÿý
zTable.__rich_measure__c                 C   s   | j S )zGet cell padding.)rm   r>   r@   r@   rA   r[   D  s   zTable.paddingc                 C   s   t  |¡| _| S )zSet cell padding.)r   rl   rm   )r?   r[   r@   r@   rA   r[   I  s   r(   r.   r0   r2   )r+   r,   r-   r/   r1   r3   r4   r5   r6   r7   r8   r)   r%   r*   r/   r1   r   r3   r$   r6   r7   r8   c                C   sF   t t| jƒ|||p
d|pd|pd||||	|
|||d�}| j |¡ dS )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(   )r9   r)   r*   r+   r,   r-   r/   r1   r3   r4   r5   r6   r7   r8   N)r'   rs   rT   ro   )r?   r)   r*   r+   r,   r-   r/   r1   r3   r4   r5   r6   r7   r8   r…   r@   r@   rA   rr   O  s"   %òzTable.add_column©r-   rP   ÚrenderablesrP   c                G   s   dt ddddfdd„}t|ƒ}| j}t|ƒt|ƒk r)g |¢dgt|ƒt|ƒ  ¢}t|ƒD ]F\}}|t|ƒkrPt |d�}	| jD ]	}
||	td	ƒƒ q?| j |	¡ n|| }	|du r^||	d	ƒ q-t|ƒrh||	|ƒ q-t	 
d
t|ƒj› d�¡‚| j t||d�¡ dS )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…   rR   r%   r<   Nc                 S   s   | j  |¡ d S rŠ   )r;   ro   )r…   rR   r@   r@   rA   Úadd_cell˜  s   zTable.add_row.<locals>.add_cell)r9   r(   zunable to render z1; a string or other renderable object is requiredrš   )r'   rM   rT   rs   Ú	enumeraterU   r   ro   r   r   ÚNotRenderableErrorÚtyperF   rO   )r?   r-   rP   r›   rœ   Úcell_renderablesrT   r|   rR   r…   Ú_r@   r@   rA   Úadd_row†  s0   ÿþ

ÿzTable.add_rowr&   c              	   #   sö   � | j stdƒV  d S |j}| jd ur| j}| j}|  ˆ | || ¡¡}t|ƒ| }|j|| j	d d�‰	ddt
dtdddd	f‡ ‡fd
d„}| jrY|| jt | jd¡| jd�E d H  |  ˆ ˆ|¡E d H  | jry|| jt | jd¡| jd�E d H  d S d S )NÚ
)r4   rj   ÚheightrW   Útextr-   r/   r#   r<   r&   c                    s4   t | tƒrˆ j| |dd�n| }ˆ j|ˆj|d�d�S )NF)r-   rj   ©r/   )r�   )rp   rq   Ú
render_strÚrenderÚupdate)r¥   r-   r/   Úrender_text©r{   Úrender_optionsr@   rA   Úrender_annotationË  s   ÿýÿz1Table.__rich_console__.<locals>.render_annotationztable.title)r-   r/   ztable.caption)rW   )rT   r   r6   r4   ry   r“   r‚   r’   r©   rj   r    r   rX   r   Ú
pick_firstrf   rh   Ú_renderrY   rg   ri   )r?   r{   r�   r6   r•   ÚwidthsÚtable_widthr­   r@   r«   rA   Ú__rich_console__µ  sN   €

ÿÿÿÿÿÿþýýÿzTable.__rich_console__c                    s¾  ˆj }ˆj}‡ ‡‡fdd„|D ƒ}dd„ |D ƒ}ˆj‰ˆj}ˆjredd„ |D ƒ}t|ƒredd„ t||ƒD ƒ}	‡fdd„|D ƒ}
|t|	ƒ }t|||
ƒ}t	|ƒ}t
|ƒD ]\}}|jrd|	| t|ƒ ||< qSt|ƒ}||krªˆ |dd„ |D ƒ|¡}t|ƒ}||kr•|| }t|dgt|ƒ ||ƒ}t|ƒ}‡ ‡‡fd	d„t||ƒD ƒ}d
d„ |D ƒ}||k r±ˆjs½ˆjdurÝ|ˆj| k rÝˆjdu rÄ|ntˆj| |ƒ}t|| |ƒ}dd„ t||ƒD ƒ}|S )zNCalculate the widths of each column, including padding, not including borders.c                    s   g | ]	}ˆ  ˆ ˆ|¡‘qS r@   )r‡   rƒ   ©r{   r�   r?   r@   rA   rˆ   ë  s    ÿz2Table._calculate_column_widths.<locals>.<listcomp>c                 S   ó   g | ]}|j pd ‘qS ©r   r�   ©r„   Ú_ranger@   r@   rA   rˆ   î  ó    c                 S   s   g | ]
}|j r|jpd ‘qS ©r   )rD   r7   )r„   Úcolr@   r@   rA   rˆ   ò  s    c                 S   s    g | ]\}}|j rd n|j‘qS r¹   )rD   r‘   )r„   r·   r…   r@   r@   rA   rˆ   ô  s    ÿÿc                    s&   g | ]}|j r|jpd ˆ |jƒ ‘qS rµ   )rD   r4   r9   rƒ   )Úget_padding_widthr@   rA   rˆ   ø  s    ýÿc                 S   s   g | ]}|j d u o|j ‘qS rŠ   )r4   r8   rƒ   r@   r@   rA   rˆ     s    r   c                    s$   g | ]\}}ˆ  ˆ ˆ |¡|¡‘qS r@   )r‡   r‚   )r„   r4   r…   r³   r@   rA   rˆ     ó    ÿÿc                 S   r´   r¹   r�   r¶   r@   r@   rA   rˆ     r¸   Nc                 S   s   g | ]\}}|| ‘qS r@   r@   )r„   Ú_widthÚpadr@   r@   rA   rˆ   !  s    )r6   rT   Ú_get_padding_widthry   r^   ÚanyÚzipr’   r   Úiterr�   rD   ÚnextÚ_collapse_widthsr   rs   r5   Úmin)r?   r{   r�   r6   rT   Úwidth_rangesr°   r•   ÚratiosÚfixed_widthsÚflex_minimumÚflexible_widthÚflex_widthsÚiter_flex_widthsr|   r…   r±   Úexcess_widthÚ
_max_widthÚ
pad_widthsr@   )r{   r»   r�   r?   rA   r“   å  sb   ÿþ
þ€ýþ
ÿýzTable._calculate_column_widthsr°   Úwrapablec           
         sÌ   t |ƒ}|| }t|ƒrd|rd|dkrdtdd„ t||ƒD ƒƒ‰ t‡ fdd„t||ƒD ƒƒ}ˆ | }‡ fdd„t||ƒD ƒ}t|ƒrB|sE	 |S t||ƒgt|ƒ }	t|||	|ƒ}t |ƒ}|| }|rd|dks|S )aM  Reduce 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.
        r   c                 s   s   � | ]	\}}|r|V  qd S rŠ   r@   ©r„   r4   Ú
allow_wrapr@   r@   rA   rŽ   7  s   € ÿ
ÿz)Table._collapse_widths.<locals>.<genexpr>c                 3   s(   � | ]\}}|r|ˆ kr|nd V  qdS )r   Nr@   rÑ   ©Ú
max_columnr@   rA   rŽ   :  s
   € ÿ
ÿc                    s$   g | ]\}}|ˆ kr|rd nd‘qS )r   r   r@   rÑ   rÓ   r@   rA   rˆ   ?  r¼   z*Table._collapse_widths.<locals>.<listcomp>)r’   rÀ   ÚmaxrÁ   rÅ   rs   r   )
rv   r°   rÐ   r6   Útotal_widthrÍ   Úsecond_max_columnÚcolumn_differencerÇ   Ú
max_reducer@   rÓ   rA   rÄ   %  s.   ÿþ
þûízTable._collapse_widthsÚcolumn_indexr…   c              
   #   sr  � | j ‰| j‰| j‰tˆƒ}|dk‰|t| jƒd k‰i ‰ dtdtdtttttf f‡ ‡‡‡‡‡fdd„}g }|j	}|j
}| jrS|| jpEdƒ||jƒ }	||	|jfƒ ||jpXdƒ}
|jD ]}||
|fƒ q]| jr||| jpndƒ||jƒ }|||jfƒ |r¢t}t|ƒD ]\}}\}}t||||||ƒƒt|d	d
ƒpœ|jƒV  q„d
S |D ]\}}t||t|d	d
ƒp³|jƒV  q¤d
S )z3Get all the cells with padding and optional header.r   r   Ú	first_rowÚlast_rowr<   c                    sŠ   ˆ   | |f¡}|r|S ˆ\}}}}ˆr%ˆstd|| ƒ}|s%td|| ƒ}ˆs7ˆr+d}ˆr/d}| r3d}|r7d}||||f}|ˆ | |f< |S )Nr   )ÚgetrÕ   )rÛ   rÜ   Úcachedr0   ÚrightÚbottomr.   rm   ©Ú_padding_cacher\   Úfirst_columnÚlast_columnr]   r[   r@   rA   Úget_padding[  s*   z%Table._get_cells.<locals>.get_paddingr(   r1   N)r\   r]   r[   rÀ   rs   rT   rL   r   rK   ro   r~   r_   r+   r)   r-   rC   r`   r,   r*   r   r   rQ   Úgetattrr1   )r?   r{   rÚ   r…   Úany_paddingrå   Ú	raw_cellsÚ_appendr~   r+   Ú
cell_styleÚcellr,   Ú_PaddingÚfirstÚlastr-   rR   r@   rá   rA   Ú
_get_cellsL  sR   €0ÿ
ÿýÿýÿzTable._get_cellsc                 C   s2   | j \}}}}| jr|dkrtd|| ƒ}|| S )zGet extra width from padding.r   )r[   r\   rÕ   )r?   rÚ   r¡   Ú	pad_rightÚpad_leftr@   r@   rA   r¿   •  s
   zTable._get_padding_widthc                 C   s  |j }|dk rtddƒS |  |j¡}|jdur%t|j| |j| ƒ |¡S g }g }|j}|j}	tj}
|  ||j|¡D ]}|
|||j	ƒ\}}||ƒ |	|ƒ q:t|rUt
|ƒnd|r\t
|ƒn|ƒ |¡}| |jdu rkdn|j| |j du ryd¡}|S |j | ¡}|S )z0Get the minimum and maximum width of the column.r   r   N)r6   r   r¿   r9   r4   Úwith_maximumro   rÝ   rï   rR   rÕ   r”   r5   )r?   r{   r�   r…   r6   Úpadding_widthÚ
min_widthsÚ
max_widthsÚ
append_minÚ
append_maxÚget_render_widthrë   Ú_minÚ_maxr�   r@   r@   rA   r‡   �  sB   

ÿþ
þýþþþzTable._measure_columnc           %      #   s‚  � ˆ  ˆ	jpd¡}|ˆ  ˆ	jpd¡ }‡‡	fdd„tˆ	jƒD ƒ}tt|Ž ƒ}ˆ	jr6ˆ	jj|t	ˆ	j
ˆj
ƒd�nd }t ¡ }	ˆ	j}
ˆ	j}ˆ	j}ˆ	j}ˆ	j}ˆ	j}t‰ |r“ˆ |j|ƒˆ |j|ƒˆ |j|ƒfˆ |j|ƒˆ |j|ƒˆ |j|ƒfˆ |j|ƒˆ |j|ƒˆ |j|ƒfg}|r’ˆ | |¡|ƒV  |	V  ng }ˆ	j}ˆj ‰tt|ƒƒD �]†\}\}}}|o¬|‰|o°|‰ˆs¼ˆs¼ˆ	j||  nd }d‰g }ˆsÆˆrËt  ¡ ‰nˆ|ˆ|rÔ|d n|ƒƒ‰t|||
ƒD ],\}}}|j!||j"|j#|j$d d�}ˆj%|j&|ˆ|jƒˆ d�}t'ˆt(|ƒƒ‰| )|¡ qÞt'dd„ |D ƒƒ‰d	t*t*t  d
ddt+dtdt*t*t  f
‡ ‡‡‡fdd„‰‡ ‡‡‡‡fdd„t||||
ƒD ƒ|d d …< |�r°|�r^|�r^ˆ |j,|d|d�|ƒV  |	V  ||�rddn|�ridnd \}}}|j- .¡ �rw|n	ˆ |j-ˆj/|j ƒ} t0ˆƒD ])}!|�r�|V  t1|ƒD ]\}"}#|#|! E d H  |"�s¢| V  �q‘|�rª|V  |	V  �q…nt0ˆƒD ]}!|D ]
}#|#|! E d H  �q¸|	V  �q´|�rà|�rà|�ràˆ |j,|d|d�|ƒV  |	V  |�oå|j2}$|�r(|�sò|�sò|$�r(|�s(|�r|t(|ƒd k�s(|�rˆ�s(|�rˆ |j,|d|d�| |ƒV  nˆ |j,|d|d�|ƒV  |	V  q¡|�r=|�r?ˆ | 3|¡|ƒV  |	V  d S d S d S )Nr(   c                 3   s"   � | ]\}}ˆ  ˆ ||¡V  qd S rŠ   )rï   )r„   rÚ   r…   )r{   r?   r@   rA   rŽ   Ë  s
   € ÿ
ÿz Table._render.<locals>.<genexpr>)Úsafer   )r4   r/   r8   r3   r¤   ©r-   c                 s   s   � | ]}t |ƒV  qd S rŠ   )rs   )r„   rë   r@   r@   rA   rŽ     s   € rë   r1   r   r4   r-   r<   c                    sR   ˆrd}nˆr	d}|dkrˆ   | |ˆ|¡S |dkr!ˆ  | |ˆ|¡S ˆ  | |ˆ|¡S )Nrà   r0   Úmiddle)Ú	align_topÚalign_middleÚalign_bottom)rë   r1   r4   r-   )Ú_SegmentÚ
footer_rowÚ
header_rowÚ
row_heightr@   rA   Ú
align_cell   s   z!Table._render.<locals>.align_cellc              
      s8   g | ]\}}}}ˆ   ˆ||j|ˆ|jƒˆ ƒ|ˆ¡‘qS r@   )Ú	set_shaper1   r-   )r„   r4   Ú_cellrë   r…   )r  r  r~   Ú
max_heightr   r@   rA   rˆ   1  s    
öüøÿz!Table._render.<locals>.<listcomp>Úfoot)Úedger   rx   ÚheadÚmidÚrow)4r~   r-   re   r�   rT   rM   rÁ   r   Ú
substituter   rZ   r   Úliner_   r`   ra   rb   rc   Ú	head_leftÚ
head_rightÚhead_verticalÚ	foot_leftÚ
foot_rightÚfoot_verticalÚmid_leftÚ	mid_rightÚmid_verticalÚget_topr€   r   rU   r   r}   r©   r/   r8   r3   Úrender_linesrR   rÕ   rs   ro   r   rK   Úget_rowr¥   ÚstripÚbackground_styleÚranger   rP   Ú
get_bottom)%r?   r{   r�   r°   Útable_stylere   Ú_column_cellsÚ	row_cellsÚ_boxÚnew_linerT   r_   r`   ra   rb   rc   Úbox_segmentsr€   r|   rí   rî   Úrow_cellr  rC   r4   rë   r…   r¬   Úlinesr.   rß   Ú_dividerÚdividerÚline_noÚ	last_cellÚrendered_cellrP   r@   )
r  r  r{   r  r~   r  r  r  r   r?   rA   r¯   Å  s&  €þýÿû	


ý


ý


ýõ€ÿÿý
ÿûý
ÿþýü
ûõÿ"ÿÿý€
÷
ÿÿþÿÿþÿ€
þzTable._render)r(   r(   )r{   r!   r�   r"   r<   r&   )+rF   rG   rH   rI   r   r'   rJ   rO   r   Ú
HEAVY_HEADr   rq   r
   r    rK   ÚBoxrL   r   r   r   ru   Úclassmethodrw   rN   r^   Úsetterry   rz   r€   r   r™   r   r[   rr   r¢   r²   r“   rÄ   rQ   rï   r¿   r‡   r¯   r@   r@   r@   rA   rS   {   sÈ  
 å
þýüûúùø	÷
öõôóòñðïî
íìëêéèçæå
äAú
þýüûúù 	
ÿÿ
þ!ýñþýûúùø	÷
öõôóòñ
ð:üþýü
û/ÿÿ
þ0ÿÿ
þ@ÿÿÿþ&ÿÿÿ
þIþýü
û(ÿÿÿþrS   Ú__main__)r!   )ÚReprHighlighter)rS   )ÚtimerzTable renderzStar Wars MovieszRich example tablerß   )rX   rY   ri   ÚReleasedÚbright_cyanÚcyanT)r+   r-   r8   ÚTitleÚmagentarü   z
Box OfficeÚgreen)r/   r-   zDec 20, 2019z Star Wars: The Rise of Skywalkerz$952,110,690zMay 25, 2018zSolo: A Star Wars Storyz$393,151,347zDec 15, 2017z!Star Wars Ep. V111: The Last Jediz$1,332,539,889zon blackrš   zDec 16, 2016zRogue One: A Star Wars Storyz$1,332,439,889r¥   r<   Nc                 C   s"   t  ¡  t  t| ƒ¡ t  ¡  d S rŠ   )r{   ÚprintÚrulerj   )r¥   r@   r@   rA   r)   ¡  s   r)   zExample TablerW   r¦   zexpand=Trueé2   zwidth=50FÚdimrV   zrow_styles=['dim', 'none']z%leading=1, row_styles=['dim', 'none']z+show_lines=True, row_styles=['dim', 'none'])JÚdataclassesr   r   r   Útypingr   r   r   r   r	   r
   r   r   r   r(   r   r   Ú_loopr   r   Ú_pickr   Ú_ratior   r   Úalignr   Újupyterr   Úmeasurer   r[   r   r   Úprotocolr   Úsegmentr   r-   r   r   r¥   r   r    r{   r!   r"   r#   r$   r%   r&   r'   rO   rQ   rS   rF   Úpip._vendor.rich.consoleÚpip._vendor.rich.highlighterr2  Úpip._vendor.rich.tableÚ_timerr3  Útablerr   r¢   rq   r)   rj   r:  r^   r4   rd   rc   rb   r@   r@   r@   rA   Ú<module>   sº    , 
>
      

ýÿýûý



$¹ù