U
    cUh                  	   @   s  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; eAd<d=d>d?ZBe- Z,e: ZCeBd@ e,jDe>dAdB d&e>_EeBdC e,De> dDe>_FeBdE e,jDe>dAdB d<e>_FdFe>_EdGdHge>_GeBdI e,jDe>dAdB d<e>_FdFe>_EdGdHge>_Gde>_HeBdJ e,jDe>dAdB d<e>_FdFe>_EdGdHge>_Gd&e>_Id e>_HeBdK e,jDe>dAdB W 5 Q R X d<S )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                   @   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< dZeed< eedZed ed< d ddd Zeed dd!d"Zeedd#d$Z dS )%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 (int, 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_wrap	highlightr   _index)default_factory_cellsreturnc                 C   s   t | g dS )zReturn a copy of this Column.r<   )r   self rB   V/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pip/_vendor/rich/table.pycopyu   s    zColumn.copyc                 c   s   | j E dH  dS )z2Get all cells in the column, not including header.Nr?   r@   rB   rB   rC   cellsy   s    zColumn.cellsc                 C   s
   | j dk	S )z!Check if this column is flexible.N)r7   r@   rB   rB   rC   flexible~   s    zColumn.flexible)!__name__
__module____qualname____doc__r)   __annotations__r*   r+   r   r,   r-   r/   r1   r3   r4   r
   intr5   r6   r7   r8   boolr9   r:   r   listr<   r   rD   propertyr   rE   rF   rB   rB   rB   rC   r'   &   s,   
r'   c                   @   s.   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)
rG   rH   rI   rJ   r-   r
   r   rK   rQ   rM   rB   rB   rB   rC   rP      s   
rP   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)rG   rH   rI   rJ   r   rK   r   rB   rB   rB   rC   rR      s
   
rR   c                   @   s  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e
eef ee ee ee ee eej ee eeeeeeeeeeeee  ee ee ee ee ee ddeddddZeddddde
eef eeeed dddZeedddZejeddddZeedddZeedddZdeed d!d"Zdd#ed$d%d&Zeeeeeef dd'd(Z e jed d)d*d(Z dPddddd,d-d.dddddd/d0d0ee ee ee ee dd1d2ee ee ee ee edd3d4d5Z!ddd6ed0 ee edd7d8d9Z"ddd:d;Z#dd#d<d$d=d>Z$dd#ee d$d?d@Z%eee ee eee dAdBdCZ&deeee' dDdEdFZ(eedGdHdIZ)dd#eedJdKdLZ*dd#ee d<dMdNdOZ+dS )Q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 (int, 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_justifyr9   r#   )headersrY   rZ   r4   r5   r   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   r-   re   r+   r,   rf   rg   rh   ri   rj   r9   r>   c                G   s   g | _ g | _|| _|| _|| _|| _|| _|| _t	|| _
|	| _|
| _|| _|| _|| _|| _|| _|| _|| _|pxd| _|pd| _|| _|| _|| _|| _|| _|| _t|pg | _| j j}|D ]0}t|t r| j!|d qt"| j |_#|| qd S )Nr(   )r)   )$rU   rV   rY   rZ   r4   r5   r   r[   r   unpack_paddingr^   _expandr`   ra   rb   rc   rd   r]   r-   r+   r,   rf   rg   rh   ri   rj   r9   rN   re   append
isinstancestr
add_columnlenr:   )rA   rY   rZ   r4   r5   r   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   r-   re   r+   r,   rf   rg   rh   ri   rj   r9   rk   Zappend_columnr)   rB   rB   rC   __init__   sB    


zTable.__init__)r\   r]   r^   r_   )rk   r\   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`   ra   rb   r^   r_   rB   )clsr\   r]   r^   r_   rk   rB   rB   rC   grid   s    z
Table.gridr=   c                 C   s   | j p| jdk	S )z-Setting a non-None self.width implies expand.N)rn   r4   r@   rB   rB   rC   r_     s    zTable.expand)r_   r>   c                 C   s
   || _ dS )zSet expand.N)rn   )rA   r_   rB   rB   rC   r_   #  s    c                 C   s4   d}| j r| jr|d7 }| j r0|t| jd 7 }|S )z'Get extra width to add to cell content.r      r   )r   rb   rs   rU   )rA   r4   rB   rB   rC   _extra_width(  s    zTable._extra_widthc                 C   s
   t | jS )zGet the current number of rows.)rs   rV   r@   rB   rB   rC   	row_count2  s    zTable.row_countr!   )consoleindexr>   c                 C   sR   t  }| jr,||| j|t| j  7 }| j| j}|dk	rN|||7 }|S )zGet the current row style.N)r   nullre   	get_stylers   rV   r-   )rA   rz   r{   r-   	row_stylerB   rB   rC   get_row_style7  s    zTable.get_row_styler"   )rz   optionsr>   c                    s   j | jd k	r| jdk r(tddS | j}t| | | j  fdd| jD }tdd |D | }| jd krtdd |D | n| j}t||}|	| j
}|S )Nr   c                    s   g | ]}  |qS rB   )update_width.0column_measure_columnrz   r6   r   rB   rC   
<listcomp>R  s   z*Table.__rich_measure__.<locals>.<listcomp>c                 s   s   | ]}|j V  qd S N)minimumr   measurementrB   rB   rC   	<genexpr>W  s     z)Table.__rich_measure__.<locals>.<genexpr>c                 s   s   | ]}|j V  qd S r   maximumr   rB   rB   rC   r   Z  s     )r6   r4   r   rx   sum_calculate_column_widthsr   r   rU   clampr5   )rA   rz   r   extra_widthmeasurementsZminimum_widthZmaximum_widthr   rB   r   rC   __rich_measure__A  s2    

 
zTable.__rich_measure__c                 C   s   | j S )zGet cell padding.)rm   r@   rB   rB   rC   r\   b  s    zTable.padding)r\   r>   c                 C   s   t || _| S )zSet cell padding.)r   rl   rm   )rA   r\   rB   rB   rC   r\   g  s    r(   r.   r0   r2   )r+   r9   r,   r-   r/   r1   r3   r4   r5   r6   r7   r8   r%   r   r$   )r)   r*   r+   r9   r,   r-   r/   r1   r3   r4   r5   r6   r7   r8   r>   c                C   sV   t t| j|||pd|dk	r |n| j|p*d|p0d|||	|
||||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.
            highlight (bool, optional): Whether to highlight the text. The default of None uses the value of the table (self) object.
            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(   N)r:   r)   r*   r+   r9   r,   r-   r/   r1   r3   r4   r5   r6   r7   r8   )r'   rs   rU   r9   ro   )rA   r)   r*   r+   r9   r,   r-   r/   r1   r3   r4   r5   r6   r7   r8   r   rB   rB   rC   rr   m  s$    'zTable.add_columnr-   rQ   )renderablesr-   rQ   r>   c                G   s   t ddddd}t|}| j}t|t|k rJ|dgt|t|  }t|D ]\}}|t|krt || jd}	| jD ]}
||	td qz| j|	 n|| }	|dkr||	d qRt	|r||	| qRt
dt|j d	qR| 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%   N)r   rS   r>   c                 S   s   | j | d S r   )r<   ro   )r   rS   rB   rB   rC   add_cell  s    zTable.add_row.<locals>.add_cell)r:   r9   r(   zunable to render z1; a string or other renderable object is requiredr   )r'   rN   rU   rs   	enumerater9   rV   r   ro   r   r   NotRenderableErrortyperG   rP   )rA   r-   rQ   r   r   Zcell_renderablesrU   r{   rS   r   _rB   rB   rC   add_row  s,    
zTable.add_rowc                 C   s   | j rd| j d _dS )z2Add a new section (draw a line after current row).TN)rV   rQ   r@   rB   rB   rC   add_section  s    zTable.add_sectionr&   c                 #   s   | j stdV  d S |j}| jd k	r*| j}| j}|  ||| }t|| }|j|| j	d ddt
tddd fdd}| jr|| jt| jd	| jd
E d H  |  |E d H  | jr|| jt| jd| jd
E d H  d S )N
)r4   r9   heightrX   r#   r&   )textr-   r/   r>   c                    s4   t | tr j| |ddn| } j|j|ddS )NF)r-   r9   r/   )r   )rp   rq   
render_strrenderupdate)r   r-   r/   Zrender_textrz   render_optionsrB   rC   render_annotation  s     
z1Table.__rich_console__.<locals>.render_annotationztable.title)r-   r/   ztable.caption)rX   )rU   r   r6   r4   rx   r   r   r   r   r9   r    r   rY   r   
pick_firstrg   ri   _renderrZ   rh   rj   )rA   rz   r   r6   r   widthstable_widthr   rB   r   rC   __rich_console__  sJ    

      zTable.__rich_console__c                    s  j }j} fdd|D }dd |D }jj}jrdd |D }t|rdd t||D }	fdd|D }
|t|	 }t|||
}t	|}t
|D ]"\}}|jr|	| t| ||< qt|}||krX|dd |D |}t|}||kr.|| }t|dgt| ||}t|} fd	dt||D }d
d |D }||k rjjsjdk	r|j| k rȈjdk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 rB   )r   r   rz   r   rA   rB   rC   r     s    z2Table._calculate_column_widths.<locals>.<listcomp>c                 S   s   g | ]}|j pd qS r   r   r   _rangerB   rB   rC   r     s     c                 S   s   g | ]}|j r|jpd qS r   )rF   r7   )r   colrB   rB   rC   r     s      c                 S   s    g | ]\}}|j rd n|jqS r   )rF   r   )r   r   r   rB   rB   rC   r     s   c                    s&   g | ]}|j r|jpd  |j qS r   )rF   r4   r:   r   )get_padding_widthrB   rC   r     s   c                 S   s   g | ]}|j d ko|j qS r   )r4   r8   r   rB   rB   rC   r   .  s     r   c                    s$   g | ]\}}  ||qS rB   )r   r   )r   r4   r   r   rB   rC   r   8  s   c                 S   s   g | ]}|j pd qS r   r   r   rB   rB   rC   r   <  s     Nc                 S   s   g | ]\}}|| qS rB   rB   )r   _widthpadrB   rB   rC   r   G  s     )r6   rU   _get_padding_widthrx   r_   anyzipr   r   iterr   rF   next_collapse_widthsr   rs   r5   min)rA   rz   r   r6   rU   Zwidth_rangesr   r   ratiosZfixed_widthsZflex_minimumZflexible_widthZflex_widthsZiter_flex_widthsr{   r   r   excess_width
_max_widthZ
pad_widthsrB   )rz   r   r   rA   rC   r     sf    


zTable._calculate_column_widths)r   wrapabler6   r>   c           
         s   t |}|| }t|r|r|dkrtdd t||D  t fddt||D } | } fddt||D }t|r|sqt||gt| }	t|||	|}t |}|| }q|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   rB   r   r4   Z
allow_wraprB   rB   rC   r   ]  s     z)Table._collapse_widths.<locals>.<genexpr>c                 3   s&   | ]\}}|r| kr|nd V  qdS )r   NrB   r   Z
max_columnrB   rC   r   `  s   c                    s$   g | ]\}}| kr|rd ndqS )r   r   rB   r   r   rB   rC   r   e  s   z*Table._collapse_widths.<locals>.<listcomp>)r   r   maxr   r   rs   r   )
ru   r   r   r6   total_widthr   Zsecond_max_columnZcolumn_differencer   Z
max_reducerB   r   rC   r   K  s*    

zTable._collapse_widths)rz   column_indexr   r>   c                 #   st  | j | j| jt}|dk|t| jd ki  tttttttf d fdd}g }|j	}|j
}| jr|| jpd||j }	||	|jf ||jpd}
|jD ]}||
|f q| jr|| jpd||j }|||jf |rBt}t|D ]:\}}\}}t||||||t|ddp6|jV  qn.|D ](\}}t||t|ddpf|jV  qFdS )	z3Get all the cells with padding and optional header.r   r   )	first_rowlast_rowr>   c                    s     | |f}|r|S \}}}}rJs8td|| }|sJtd|| }snrVd}r^d}| rfd}|rnd}||||f}| | |f< |S )Nr   )getr   )r   r   cachedr0   rightbottomr.   rm   Z_padding_cacher]   Zfirst_columnZlast_columnr^   r\   rB   rC   get_padding  s*    z%Table._get_cells.<locals>.get_paddingr(   r1   N)r]   r^   r\   r   rs   rU   rM   r   rL   ro   r}   r`   r+   r)   r-   rE   ra   r,   r*   r   r   rR   getattrr1   )rA   rz   r   r   Zany_paddingr   Z	raw_cells_appendr}   r+   Z
cell_stylecellr,   Z_Paddingfirstlastr-   rS   rB   r   rC   
_get_cellsr  sL    ,
zTable._get_cells)r   r>   c                 C   s2   | j \}}}}| jr*|dkr*td|| }|| S )zGet extra width from padding.r   )r\   r]   r   )rA   r   r   	pad_rightpad_leftrB   rB   rC   r     s
    zTable._get_padding_width)rz   r   r   r>   c                 C   s   |j }|dk rtddS | |j}|jdk	rJt|j| |j| |S g }g }|j}|j}	tj}
| ||j|D ]&}|
|||j	\}}|| |	| qtt|rt
|nd|rt
|n||}||jdkrdn|j| |j dkrdn|j | }|S )z0Get the minimum and maximum width of the column.r   r   N)r6   r   r   r:   r4   with_maximumro   r   r   rS   r   r   r5   )rA   rz   r   r   r6   padding_widthZ
min_widthsZ
max_widthsZ
append_minZ
append_maxZget_render_widthr   _min_maxr   rB   rB   rC   r     s>    

 
zTable._measure_column)rz   r   r   r>   c           %   
   #   s   	jpd}| 	jpd }	fddt	jD }tt| }	jrj	jj|t		j
j
dnd }|r	js| n|}t }		j}
	j}	j}	j}	j}	j}t |r> |j| |j| |j|f |j| |j| |j|f |j| |j| |j|fg}|rB |||V  |	V  ng }	j}j tt|D ]\}\}}}|or||o||ss	j||  nd }dg }srt ! n||r|d n|t|||
D ]^\}}}|j"||j#|j$|j%d |j&d}j'|j(||j d}t)t*||+| qt)dd |D t,t,t  d	t-t t,t,t  d
 fdd fddt||||
D |d d < |r|r|r |j.|d|d|V  |	V  ||rdn|rdnd \}}}|j/0 r|n |j/j1|j } t2D ]R}!|r>|V  t3|D ]$\}"}#|#|! E d H  |"sF| V  qF|rx|V  |	V  q.n0t2D ]&}!|D ]}#|#|! E d H  q|	V  q|r|r|r |j.|d|d|V  |	V  |o|j4}$|rZ|s|s|$rZ|sZ|r&|t*|d ksZ|r2sZ|rV |j.|d|d| |V  n |j.|d|d|V  |	V  qZ|r|r |5||V  |	V  d S )Nr(   c                 3   s    | ]\}}  ||V  qd S r   )r   )r   r   r   )rz   rA   rB   rC   r     s   z Table._render.<locals>.<genexpr>)safer   )r4   r/   r8   r3   r   r9   r-   c                 s   s   | ]}t |V  qd S r   )rs   )r   r   rB   rB   rC   r   E  s     r   )r   r1   r4   r-   r>   c                    sR   r
d}nrd}|dkr*  | ||S |dkrB | ||S  | ||S )Nr   r0   middle)	align_topalign_middlealign_bottom)r   r1   r4   r-   )_Segment
footer_row
header_row
row_heightrB   rC   
align_cellG  s    z!Table._render.<locals>.align_cellc              
      s8   g | ]0\}}}}  ||j||j |qS rB   )	set_shaper1   r-   )r   r4   Z_cellr   r   )r   r   r}   
max_heightr~   rB   rC   r   X  s   
z!Table._render.<locals>.<listcomp>foot)edger   rw   headmidrow)6r}   r-   rf   r   rU   rN   r   r   
substituter   r[   r`   get_plain_headed_boxr   linera   rb   rc   rd   	head_left
head_righthead_verticalmid_left	mid_rightmid_vertical	foot_left
foot_rightfoot_verticalget_topr   r   rV   r   r|   r   r/   r8   r3   r9   render_linesrS   r   rs   ro   r   rL   get_rowr   stripbackground_styleranger   rQ   
get_bottom)%rA   rz   r   r   Ztable_stylerf   Z_column_cellsZ	row_cells_boxnew_linerU   r`   ra   rb   rc   rd   Zbox_segmentsr   r{   r   r   Zrow_cellr   rE   r4   r   r   r   linesr.   r   Z_dividerZdividerline_noZ	last_cellZrendered_cellrQ   rB   )
r   r   rz   r   r}   r   r   r   r~   rA   rC   r     s     













 " 


  
zTable._render)r(   r(   ),rG   rH   rI   rJ   r   r'   rK   rP   r   
HEAVY_HEADr   rq   r
   r    rL   BoxrM   r   r   r   rt   classmethodrv   rO   r_   setterrx   ry   r   r   r   r   r\   rr   r   r   r   r   r   rR   r   r   r   r   rB   rB   rB   rC   rT      s<  


@
 	 !  =/ 0 @  '  I
)  rT   __main__)r!   )ReprHighlighter)rT   )timerzTable renderzStar Wars MovieszRich example tabler   )rY   rZ   rj   ZReleasedbright_cyancyanT)r+   r-   r8   Z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,889N)r   r>   c                 C   s"   t   t t|  t   d S r   )rz   printruler9   )r   rB   rB   rC   r)     s    r)   zExample TablerX   r   zexpand=True2   zwidth=50FdimrW   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   Z_ratior   r   alignr   jupyterr   measurer   r\   r   r   protocolr   segmentr   r-   r   r   r   r   r    rz   r!   r"   r#   r$   r%   r&   r'   rP   rR   rT   rG   pip._vendor.rich.consolepip._vendor.rich.highlighterr	  pip._vendor.rich.tableZ_timerr
  tablerr   r   rq   r)   r9   r  r_   r4   re   rd   rc   rB   rB   rB   rC   <module>   s   , 
]
      
   



