
    hu                        S SK r S SKJr  S SKJrJrJrJrJrJ	r	J
r
  S SKJr  SSKJr  SSKJr  SSKJr  SS	KJr  S
SSS.r            S!S\
\\4   S\\   S\\   S\S\
\\   \S   4   S\S\S\\
\\S      \S   4      S\S\S\\   S\\   S\\   S\4S jjr      S"S\S\
\	\   \\S   4   S\S\\
\	\S      \4      S\S\\	   S\\	   S\4S jjrS  rg)#    N)zip_longest)
CollectionDictIterableListOptionalSequenceUnion)cast   )Literal)COLORS)color)supports_ansi<>^)lrcautodataheaderfooterdividerwidthsmax_colspacingaligns)r   r   r   	multiline
env_prefixcolor_values	fg_colors	bg_colorsreturnc           
         Uc  Ubi  [        [        5      nU
b  UR                  U
5        Ub   U Vs/ s H  oR                  X5      PM     nnUb   U Vs/ s H  oR                  X5      PM     nn[	        U [         5      (       a  [        U R                  5       5      n U(       a  / n[        U 5       H  u  nnU Vs/ s H#  n[	        U[
        [        45      (       a  UOU/PM%     nnUR                  [        [        USS065      5        U[        U 5      S-
  :  d  Mm  UR                  [        U Vs/ s H  nSPM     sn5      5        M     Un US:X  a  [        XX%5      nUUUU	UUS.n[        U Vs/ s H  nSU-  PM
     sn40 UD6n/ nU(       a3  UR                  [        U40 UD65        U(       a  UR                  U5        [        U 5       H!  u  nnUR                  [        U40 UD65        M#     U(       a3  U(       a  UR                  U5        UR                  [        U40 UD65        SR                  SR!                  U5      5      $ s  snf s  snf s  snf s  snf s  snf )	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.
	fillvalue r   r   )r   r   r   r!   r#   r$   -z
{}

)dictr   updateget
isinstancelistitems	enumeratetupleextendr   lenappend_get_max_widthsrowformatjoin)r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   colorsfg_colorbg_colorzipped_dataiitemvvalssettingswidthdivider_rowrowss                            G/home/james-whalen/.local/lib/python3.13/site-packages/wasabi/tables.pytablerG      s$   T 	 5f#MM,' HQR	HH7	IR HQR	HH7	IR$DJJL! GAtHLM1Ae}55AA3>DMtK$D$DEF3t9q= ""5d);d"d);#<=	 '
  v? H 7usU{7D8DKDC+(+,KK$T?4C))* #KK$C+(+,??499T?++G SR N *< 8s   II<*I3I 4I%c                    [         R                  " SR                  U5      S5      n[        5       =(       a    U(       + =(       a    USL=(       d    USLn/ n	[	        U[
        5      (       a  U  V
s/ s H  oPM     sn
O[        [        [
           U5      n[        US5      (       d?  US:w  a9  [        [        [           [        [        U 5      5       V
s/ s H  oPM     sn
5      n[        U 5       H  u  p[        R                  U(       a  U[        U5      :  a  X   OS5      nUS:X  a  [        U5      O[        [        [           U5      U   nSX4-  nUR                  [        U5      5      nU(       a  Ub  X\   OSnUb  Xl   OSn[        UUUS9nU	R!                  U5        M     S	U-  R#                  U	5      $ s  sn
f s  sn
f )
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_FRIENDLYFN__iter__r   r   z{:%s%d})fgbg )osgetenvr8   r   r.   strr   r   hasattrintranger4   r1   	ALIGN_MAPr-   _colorr5   r9   )r   r   r   r   r!   r#   r$   env_log_friendlyshow_colorscols__alignsr>   colalign	col_widthtplrJ   rK   s                      rF   r7   r7   c   s   6 yy!2!9!9*!EuM 	=  	=d";it&; 
 D",VS"9"9AtDIv?V  6:&&6V+;d3i%D	2B!C2BQ&2B!CDD/GCL8HgjcR && 0CHd49f6Ma6P	5,,jjS"!*!6DB!*!6DB+CC " 'M%% 	 "Ds   0F<G
c                 n   [        U 5      nU(       a  UR                  U5        U(       a  UR                  U5        U VVs/ s H'  oU Vs/ s H  n[        [        U5      5      PM     snPM)     nnn[        [	        U6 5       Vs/ s H  n[        [        U5      U5      PM     sn$ s  snf s  snnf s  snf )N)r/   r5   r4   rO   zipminmax)	r   r   r   r   all_datar?   rZ   r   ws	            rF   r6   r6      s    DzH:BC($-s3s8}-(FC*.sF|*<=*<QCA *<== .C=s   	B,
B'(B,B2'B,)NNFr         NFWASABINNN)r   re   Nrf   NN)rM   	itertoolsr   typingr   r   r   r   r   r	   r
   r   compatr   utilr   r   rT   r   rS   boolrQ   rO   rG   r7   r6        rF   <module>rn      s   	 ! N N N    ! Cc*	 "&!%4:X\#'$($(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,n :@EI$($(1&
1&(3-gfo561& 1& U8GM$:;S@AB	1&
 1& !1& !1& 	1&h>rm   