
    "Zju                     F   d dl Z d dlmZ d dlmZmZmZmZmZm	Z	m
Z
 d dlmZ ddlmZ ddlmZ ddlmZ dd	lmZ d
dddZ	 	 	 	 	 	 	 	 	 	 	 	 d%de
eef         dee         dee         dede
ee         ed         f         dededee
eed                  ed         f                  dededee         dee         d ee         d!efd"Z	 	 	 	 	 	 d&dede
e	e         eed         f         dedee
e	ed                  ef                  dedee	         d ee	         d!efd#Zd$ ZdS )'    N)zip_longest)
CollectionDictIterableListOptionalSequenceUnion)cast   )Literal)COLORS)color)supports_ansi<>^)lrcFauto      WASABIdataheaderfooterdividerwidthsmax_colspacingaligns)r   r   r   	multiline
env_prefixcolor_values	fg_colors	bg_colorsreturnc           
      J   ||Kt          t                    |
                    |
           |fd|D             }|fd|D             }t          | t                     r!t	          |                                           } |rg }t          |           D ]\  }}d |D             }|                    t	          t          |ddi                     |t          |           dz
  k     r,|
                    t          d |D                                  |} |d	k    rt          | |||          }||||	||d
}t          d |D             fi |}g }|r7|
                    t          |fi |           |r|
                    |           t          |           D ]%\  }}|
                    t          |fi |           &|r7|r|
                    |           |
                    t          |fi |           d                    d                    |                    S )a  Format tabular data.

    data (Union[Collection, Dict]): The data to render. Either a list of lists (one per
        row) or a dict for two-column tables.
    header (Optional[Iterable]): Optional header columns.
    footer (Optional[Iterable]): Optional footer columns.
    divider (bool): Show a divider line between header/footer and body.
    widths (Union[Iterable[int], Literal['auto']]): Column widths in order. If "auto", widths
        will be calculated automatically based on the largest value.
    max_col (int): Maximum column width.
    spacing (int): Spacing between columns, in spaces.
    aligns (Optional[Union[Iterable[str], str]]): Optional column alignments
        in order. 'l' (left, default), 'r' (right) or 'c' (center). If a string,
        value is used for all columns.
    multiline (bool): If a cell value is a list of a tuple, render it on
        multiple lines, with one value per line.
    env_prefix (str): Prefix for environment variables, e.g.
        WASABI_LOG_FRIENDLY.
    color_values (Optional[Dict]): Optional color values to add or overwrite, name mapped to value.
    fg_colors (Optional[Iterable]): Optional foreground colors, one per column. None can be specified
        for individual columns to retain the default foreground color.
    bg_colors (Optional[Iterable]): Optional background colors, one per column. None can be specified
        for individual columns to retain the default background color.
    RETURNS (str): The formatted table.
    Nc                 <    g | ]}                     ||          S  get).0fg_colorcolorss     Y/Users/jameslopez/projects/MentorCore/.venv/lib/python3.11/site-packages/wasabi/tables.py
<listcomp>ztable.<locals>.<listcomp>=   '    RRRHHh77RRR    c                 <    g | ]}                     ||          S r+   r,   )r.   bg_colorr0   s     r1   r2   ztable.<locals>.<listcomp>?   r3   r4   c                 P    g | ]#}t          |t          t          f          r|n|g$S r+   )
isinstancelisttuple)r.   vs     r1   r2   ztable.<locals>.<listcomp>E   s1    MMM1Ae}55>AAA3MMMr4   	fillvalue r   c                     g | ]}d S )r=   r+   )r.   is     r1   r2   ztable.<locals>.<listcomp>H   s    );););");););r4   r   )r   r!   r"   r$   r&   r'   c                     g | ]}d |z  S )-r+   )r.   widths     r1   r2   ztable.<locals>.<listcomp>T   s    777usU{777r4   z
{}

)dictr   updater8   r9   items	enumerateextendr   lenappendr:   _get_max_widthsrowformatjoin)r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   zipped_datar?   itemvalssettingsdivider_rowrowsr0   s                       @r1   tablerU      s   T 	 5f#MM,''' RRRR	RRRI RRRR	RRRI$ "DJJLL!!   	> 	>GAtMMMMMDtK$D$D$DEEFFF3t99q=  ""5););d);););#<#<=== vvw??  H 77777DD8DDKD %C++(++,,, 	%KK$$$T?? + +4C))))**** - 	%KK$$$C++(++,,,??499T??+++r4   c           	         t          j        d                    |          d          }t                      o
| o|dup|du}g }	t	          t
                    rfd| D             nt          t          t
                             }
t          d          sLdk    rFt          t          t                   fdt          t          |                     D                       t          |           D ]\  }}t                              |
r|t          |
          k     r|
|         nd          }dk    rt          |          n%t          t          t                             |         }d	||fz  }|                    t          |                    }|r*|||         nd}|||         nd}t          |||
          }|	                    |           d|z                      |	          S )a;  Format data as a table row.

    data (Collection): The individual columns to format.
    widths (Union[Sequence[int], int, Literal['auto']]): Column widths, either one integer for all
        columns or an iterable of values. If "auto", widths will be calculated
        automatically based on the largest value.
    spacing (int): Spacing between columns, in spaces.
    aligns (Optional[Union[Sequence[Literal['r', 'c', 'l']], str]]): Optional column
        alignments in order. 'l' (left, default), 'r' (right) or 'c' (center).
        If a string, value is used for all columns.
    env_prefix (str): Prefix for environment variables, e.g.
        WASABI_LOG_FRIENDLY.
    fg_colors (Optional[Sequence]): Optional foreground colors for the columns, in order. None can be
        specified for individual columns to retain the default foreground color.
    bg_colors (Optional[Sequence]): Optional background colors for the columns, in order. None can be
        specified for individual columns to retain the default background color.
    RETURNS (str): The formatted row.
    z{}_LOG_FRIENDLYFNc                     g | ]}S r+   r+   )r.   _r"   s     r1   r2   zrow.<locals>.<listcomp>   s    Ar4   __iter__r   c                     g | ]}S r+   r+   )r.   rX   r   s     r1   r2   zrow.<locals>.<listcomp>   s    !C!C!CQ&!C!C!Cr4   r   z{:%s%d})fgbg )osgetenvrM   r   r8   strr   r   hasattrintrangerI   rG   	ALIGN_MAPr-   _colorrJ   rN   )r   r   r!   r"   r$   r&   r'   env_log_friendlyshow_colorscols_alignsr?   colalign	col_widthtplr[   r\   s    ` `              r1   rL   rL   c   s   6 y!2!9!9*!E!EuMM 	=  	=d";it&; 
 D",VS"9"9VtDIv?V?V  6:&& E6V+;+;d3i!C!C!C!C%D		2B2B!C!C!CDDD// 	 	3GQCLL8H8HgajjcRR && 0 0CHHHd49f6M6Ma6P	5),,jjS"" 	,!*!61DB!*!61DB+++CC'M%%%r4   c                     t          |           }|r|                    |           |r|                    |           d |D             }fdt          t          |           D             S )Nc                 &    g | ]}d  |D             S )c                 F    g | ]}t          t          |                    S r+   )rI   r`   )r.   rj   s     r1   r2   z._get_max_widths.<locals>.<listcomp>.<listcomp>   s$    ---s3s88}}---r4   r+   )r.   rP   s     r1   r2   z#_get_max_widths.<locals>.<listcomp>   s'    CCC$-----CCCr4   c                 J    g | ]}t          t          |                     S r+   )minmax)r.   wr    s     r1   r2   z#_get_max_widths.<locals>.<listcomp>   s)    ===QCA  ===r4   )r9   rJ   zip)r   r   r   r    all_datar   s      `  r1   rK   rK      s{    DzzH    CC(CCCF====$sF|*<*<====r4   )NNFr   r   r   NFr   NNN)r   r   Nr   NN)r^   	itertoolsr   typingr   r   r   r   r   r	   r
   r   compatr   utilr   r   re   r   rd   boolrb   r`   rU   rL   rK   r+   r4   r1   <module>r|      s   				 ! ! ! ! ! ! N N N N N N N N N N N N N N N N N N                   ! ! ! ! ! !      Cc**	 "&!%4:X\#'$($(R, R,

D 
!R, XR, X	R,
 R, (3-01R, R, R, U8GM$:;W]=SSTUR, R, R, 4.R, !R, !R,  	!R, R, R, R,n :@EI$($(1& 1&
1&(3-gfo561& 1& U8GM$:;S@AB	1&
 1& !1& !1& 	1& 1& 1& 1&h> > > > >r4   