
    ֤iu                        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y)#    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           
      d   ||dt        t              }|
|j                  |
       ||D cg c]  }|j                  ||       }}||D cg c]  }|j                  ||       }}t	        | t               rt        | j                               } |rg }t        |       D ]  \  }}|D cg c]  }t	        |t
        t        f      r|n|g }}|j                  t        t        |ddi             |t        |       dz
  k  sc|j                  t        |D cg c]  }d c}              |} |dk(  rt        | |||      }||||	||d}t        |D cg c]  }d|z  	 c}fi |}g }|r.|j                  t        |fi |       |r|j                  |       t        |       D ]   \  }}|j                  t        |fi |       " |r.|r|j                  |       |j                  t        |fi |       dj                  dj!                  |            S c c}w c c}w c c}w c c}w c c}w )	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                            ^/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/wasabi/tables.pytablerG      s)   T 	 5f#MM,' HQRHHh7RIR HQRHHh7RIR$DJJL!  	>GAtHLM1Ae}5AA3>MDMtK$D$DEF3t9q= ""5d);");#<=		>
  vvw? H 7usU{7D8DKDC+(+,KK$T? +4C))*+KK$C+(+,??499T?++G SR N *< 8s   HH+"H#	H(H-c                 6   t        j                  dj                  |      d      }t               xr | xr
 |duxs |du}g }	t	        |t
              r| D 
cg c]  }
| c}
nt        t        t
           |      }t        |d      s<|dk7  r7t        t        t           t        t        |             D 
cg c]  }
| c}
      }t        |       D ]  \  }}t        j                  |r|t        |      k  r||   nd      }|dk(  rt        |      nt        t        t           |      |   }d||fz  }|j                  t        |            }|r |||   nd}|||   nd}t        |||      }|	j!                  |        d	|z  j#                  |	      S c c}
w c c}
w )
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AtDIv?V  6:&6V+;d3i%D	2B!CQ&!CDD/ 	3GCL8HgajcR && 0CHd49f6Ma6P	5),,jjS"!*!61DB!*!61DB+CC	 'M%% 	 "Ds   	F2	F
c                 J   t        |       }|r|j                  |       |r|j                  |       |D cg c]$  }|D cg c]  }t        t        |             c}& }}}t        t	        |       D cg c]  }t        t        |      |       c}S c c}w c c}}w c c}w )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}-CFC*.sF|*<=QCA == .C=s   	B BB6B 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   