
    h0                         S SK r S SKrS SKrS SKrS SKrS SKrS SKJr  S SKJ	r	  S SK
Jr  S SKJrJrJrJrJrJrJrJr  SSKJr  SSKJrJr  SS	KJrJrJrJr  SS
KJr   SSKJ!r!J"r"J#r#   " S S\$5      r%g)    N)Counter)contextmanager)Process)Any
CollectionDictNoReturnOptionalUnioncastoverload   )Literal)rowtable)COLORSICONSMESSAGES
can_render)color)locale_escapesupports_ansiwrapc                      \ rS rSr           S,S\S\S\\   S\\   S\S\S	\S
\S\S\S\4S jjr	\
S\4S j5       r     S-S\S\S\S\S\\   4
S jjr\     S-S\S\S\S\S\\S      4
S jj5       r\     S.S\S\S\S\S\S   S\4S jj5       r     S-S\S\S\S\S\\\\4      S\\S\4   4S jjr     S-S\S\S\S\S\\   4
S jjr     S-S\S\S\S\S\\   4
S jjr         S/S\S\S\\\\4      S\\\\4      S \\   S\S\S\S\\   4S! jjr    S0S\S"\S\S \\   4S# jjrS$\\\4   4S% jrS$\4S& jr\S1S\4S' jj5       rS1S\4S( jjr    S2S\S\S)\\   S\S\S\\   4S* jjrS+rg)3Printer   Nprettyno_printcolorsiconsline_max	animationanimation_asciihide_animationignore_warnings
env_prefix	timestampc                    [         R                  " SR                  U
5      S5      n[         R                  " SR                  U
5      S5      n[        5       U l        U=(       a    U(       + U l        X l        [        5       =(       a    U(       + U l        U=(       d    UU l	        Xl
        XPl        [        [        5      U l        [        [        5      U l        Xl        U(       a  U R                  R%                  U5        U(       a  U R                   R%                  U5        ['        U5      (       a  X`l        gUU l        g)a/  Initialize the command-line printer.

pretty (bool): Pretty-print output (colors, icons).
no_print (bool): Don't actually print, just return.
colors (Optional[Dict]): Optional color values to add or overwrite, name mapped to value.
icons (Optional[Dict]): Optional icons to add or overwrite. Name mapped to unicode icon.
line_max (int): Maximum line length (for divider).
animation (str): Steps of loading animation for loading() method.
animation_ascii (str): Alternative animation for ASCII terminals.
hide_animation (bool): Don't display animation, e.g. for logs.
ignore_warnings (bool): Do not output messages of type MESSAGE.WARN.
env_prefix (str): Prefix for environment variables, e.g.
    WASABI_LOG_FRIENDLY.
timestamp (bool): Print a timestamp (default False).
RETURNS (Printer): The initialized printer.
z{}_LOG_FRIENDLYFz{}_NO_PRETTYN)osgetenvformatr   _countsr   r   r   
show_colorr$   r%   r!   dictr   r   r   r    r'   updater   anim)selfr   r   r   r    r!   r"   r#   r$   r%   r&   r'   env_log_friendlyenv_no_prettys                 H/home/james-whalen/.local/lib/python3.13/site-packages/wasabi/printer.py__init__Printer.__init__   s    < 99%6%=%=j%I5Q		."7"7
"CUK '	2]!2 '/B2B.B,@0@. 6l%[
"KKv&JJe$!+I!6!6I	O	    returnc                     U R                   $ )zGet the counts of how often the special printers were fired,
e.g. MESSAGES.GOOD. Can be used to print an overview like "X warnings".
)r,   )r1   s    r4   countsPrinter.countsD   s    
 ||r7   titletextshowspacedexitsc           	      B    U R                  X[        R                  X4US9$ )ao  Print a success message.

title (Any): The main text to print.
text (Any): Optional additional text to print.
show (bool): Whether to print or not. Can be used to only output
    messages under certain condition, e.g. if --verbose flag is set.
spaced (bool): Whether to add newlines around the output.
exits (Optional[int]): Optional toggle to perform a system exit.
styler>   r?   r@   )_get_msgr   GOODr1   r<   r=   r>   r?   r@   s         r4   goodPrinter.goodK   '    " }}x}}4e  
 	
r7   )r   Fc                     g N rF   s         r4   failPrinter.fail`        	r7   )r   Tc                     g rK   rL   rF   s         r4   rM   rN   k   rO   r7   c           	      B    U R                  X[        R                  X4US9$ )an  Print an error message.

title (Any): The main text to print.
text (Any): Optional additional text to print.
show (bool): Whether to print or not. Can be used to only output
    messages under certain condition, e.g. if --verbose flag is set.
spaced (bool): Whether to add newlines around the output.
exits (Optional[int]): Optional toggle to perform a system exit.
rB   )rD   r   FAILrF   s         r4   rM   rN   v   rI   r7   c           	      B    U R                  X[        R                  X4US9$ )ao  Print a warning message.

title (Any): The main text to print.
text (Any): Optional additional text to print.
show (bool): Whether to print or not. Can be used to only output
    messages under certain condition, e.g. if --verbose flag is set.
spaced (bool): Whether to add newlines around the output.
exits (Optional[int]): Optional toggle to perform a system exit.
rB   )rD   r   WARNrF   s         r4   warnPrinter.warn   rI   r7   c           	      B    U R                  X[        R                  X4US9$ )av  Print an informational message.

title (Any): The main text to print.
text (Any): Optional additional text to print.
show (bool): Whether to print or not. Can be used to only output
    messages under certain condition, e.g. if --verbose flag is set.
spaced (bool): Whether to add newlines around the output.
exits (Optional[int]): Optional toggle to perform a system exit.
rB   )rD   r   INFOrF   s         r4   infoPrinter.info   rI   r7   r   bg_coloriconc
                 (   U(       d  gU R                   (       a  U R                  R                  [        [        U5      U5      nU R                  R                  [        [        U5      U5      nU R
                  R                  [        [        U5      5      nU(       a(  [        SR                  XQ5      5      R                  5       nU R                  (       a
  [        XUS9n[        USS9nU(       a  SR                  U[        USS95      nU R                  (       a>  [        R                  R                  5       R                  S5      n
SR                  X5      nU	c  U(       a  S	R                  U5      nU R                   (       d  U(       d  [#        U5        U	b  [$        R&                  R)                  5         [$        R*                  R)                  5         U R                   (       d  U(       a   U	S:w  a   [-        UR                  5       5      e[$        R8                  " U	5        U R                   (       d  U(       a  U$ g! [.         aF  nS
R1                  [2        R4                  " 5       SS 5      n[7        SR                  X5      5      eSnAff = f)aE  Print a message.

title (Any): The main text to print.
text (Any): Optional additional text to print.
color (Optional[Union[str, int]]): Optional foreground color.
bg_color (Optional[Union[str, int]]): Optional background color.
icon (Optional[str]): Optional name of icon to add.
spaced (bool): Whether to add newlines around the output.
show (bool): Whether to print or not. Can be used to only output
    messages under certain condition, e.g. if --verbose flag is set.
no_print (bool): Don't actually print, just return.
exits (Optional[int]): Perform a system exit. Optional.
N{} {})fgbgr   )indentz{}
{}z%Y-%m-%d %H:%M:%Sz{}	{}z
{}

)r   r   getr   strr    r   r+   stripr-   _colorr   r'   datetimenowstrftimer   printsysstdoutflushstderrRuntimeError	Exceptionjoin	tracebackformat_stack
SystemExitexit)r1   r<   r=   r   r[   r\   r?   r>   r   r@   ri   etbs                r4   r=   Printer.text   s   2 ;;KKOODe$4e<E{{tC':HEH::>>$sD/2D%gnnT&ABHHJu8<q)EOOE4Q+?@E>>##'')223FGCOOC/EOOE*E}}X%LJJJJ}}UaZ=&u{{}55
 HHUO==HL % ! =9#9#9#;CR#@AB$X__R%;<<=s   7I 
JAJJcharc           	         U(       d  g[        U5      S:w  a  [        SR                  U5      5      eU R                  (       a  U R                  R                  [        [        U5      5      nU(       a(  [        SR                  XA5      5      R                  5       nU[        [        U R                  [        U5      -
  5      S-  5      S-
  -  nU(       a  SR                  U5      OSn[        SR                  XQS	9S
S9n[        U5      U R                  :  a  XU R                  [        U5      -
  -  -   nU R                  (       a  U$ [        U5        g)a7  Print a divider with a headline:
============================ Headline here ===========================

text (str): Headline text. If empty, only the line is printed.
char (str): Line character to repeat, e.g. =.
show (bool): Whether to print or not.
icon (Optional[str]): Optional icon to display with title.
Nr   z9Divider chars need to be one character long. Received: {}r^      z {}  z
{deco}{text}{deco})decor=   T)bold)len
ValueErrorr+   r   r    rd   r   re   r   rf   introundr!   rg   r   rk   )r1   r=   rz   r>   r\   r~   s         r4   dividerPrinter.divider   s	    t9>%vd|  ;;::>>$sD/2D$W^^D%?@FFH3udmmc$i&?AAEFJKD*.6==&BD&--4-C$D 4y4==(dmmc$i&?@@==Kdr7   datac                     UR                  SS5      n[        U40 UD6nU(       a  U R                  U5        U R                  (       a  U$ [	        U5        g)zPrint data as a table.

data (Union[Collection, Dict]): The data to render. Either a list of lists
    (one per row) or a dict for two-column tables.
kwargs: Table settings. See tables.table for details.
r<   N)popr   r   r   rk   )r1   r   kwargsr<   r=   s        r4   r   Printer.table  sE     

7D)T$V$LL==Kdr7   c                 X    [        U40 UD6nU R                  (       a  U$ [        U5        g)z{Print a table row.

data (Collection): The individual columns to format.
kwargs: Row settings. See tables.row for details.
N)r   r   rk   )r1   r   r   r=   s       r4   r   Printer.row$  s&     4"6"==Kdr7   c              #   *  #    U R                   (       a  S v   g U R                  (       a  [        U5        S v   g [        R                  R                  5         [        U R                  U4S9nUR                  5          S v   UR                  5         [        R                  R                  S5        [        R                  R                  5         g ! [         a6  nUR                  5         [        R                  R                  S5        UeS nAff = f7f)N)targetargsrb   z[2K)r   r$   rk   rl   rm   rn   r   _spinnerstartrq   	terminatewrite)r1   r=   trw   s       r4   loadingPrinter.loading/  s     ==  $KJJt}}D7;AGGI KKMJJ[)JJ  

  &		s+   A;D>C AD
D1DDDc                    [         R                  " U R                  5       He  n[        R                  R                  SR                  X!5      5        [        R                  R                  5         [        R                  " S5        Mg     g )Nz{} {}g?)
	itertoolscycler0   rl   rm   r   r+   rn   timesleep)r1   r=   rz   s      r4   r   Printer._spinnerE  sQ    OODII.DJJY--d9:JJJJsO /r7   rC   c           
          U R                   (       a  U[        R                  :X  a  SnU R                  U==   S-  ss'   U R	                  XX3XEUS9$ )NFr   )r   r\   r>   r?   r@   )r%   r   rT   r,   r=   )r1   r<   r=   rC   r>   r?   r@   s          r4   rD   Printer._get_msgK  sQ     EX]]$:DUq yyutRW  
 	
r7   )r,   r0   r   r$   r    r%   r!   r   r   r-   r'   )TFNNP   u   ⠙⠹⠸⠼⠴⠦⠧⠇⠏z|/-\FFWASABIF)r}   r}   TFN)r}   r}   TFT)	r}   r}   NNNFTFN)r}   =TN)z
Loading...)NFFN) __name__
__module____qualname____firstlineno__boolr
   r   r   re   r5   propertyr   r:   r   rG   r   r   rM   r	   r   rU   rY   r=   r   r   r   r   r   r   r   rD   __static_attributes__rL   r7   r4   r   r      sO    !% $6&$ %".L.L .L 	.L
 ~.L .L .L .L .L .L .L .L`    #

 
 	

 
 }
*  -1  	
  )*   "&  	
  w 
  ,0

 
 	

 
 c4i()
 
sD("	#
. #

 
 	

 
 }
. #

 
 	

 
 }
. +/.2"#99 9 c3h(	9
 5c?+9 sm9 9 9 9 }9z "## # 	#
 sm#J%
D 01 	
 	 C  *S   $#

 
 }	

 
 
 }
 
r7   r   )&rh   r   r)   rl   r   rs   collectionsr   
contextlibr   multiprocessingr   typingr   r   r   r	   r
   r   r   r   compatr   tablesr   r   utilr   r   r   r   r   rg   r   r   r   objectr   rL   r7   r4   <module>r      sL      	 
    % # S S S   5 5 ! 4 4F
f F
r7   