
    ֤i0                         d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZmZmZmZmZmZmZmZ ddlmZ ddlmZmZ dd	lmZmZmZmZ dd
lmZ  ddlm!Z!m"Z"m#Z#  G d de$      Z%y)    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                      e Zd Z	 	 	 	 	 	 	 	 	 	 	 d*dededee   dee   dededed	ed
ededefdZe	de
fd       Z	 	 	 	 	 d+dededededee   f
dZe	 	 	 	 	 d+dededededeed      f
d       Ze	 	 	 	 	 d,dededededed   defd       Z	 	 	 	 	 d+dededededeeeef      deedef   fdZ	 	 	 	 	 d+dededededee   f
dZ	 	 	 	 	 d+dededededee   f
dZ	 	 	 	 	 	 	 	 	 d-dededeeeef      deeeef      dee   dedededee   fd Z	 	 	 	 d.ded!ededee   fd"Zd#eeef   fd$Zd#efd%Zed/defd&       Zd/defd'Z	 	 	 	 d0deded(ee   dededee   fd)Zy)1PrinterNprettyno_printcolorsiconsline_max	animationanimation_asciihide_animationignore_warnings
env_prefix	timestampc                 <   t        j                  dj                  |
      d      }t        j                  dj                  |
      d      }t               | _        |xr | | _        || _        t               xr | | _        |xs || _	        |	| _
        || _        t        t              | _        t        t              | _        || _        |r| j                  j%                  |       |r| j                   j%                  |       t'        |      r|| _        y|| _        y)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                 _/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/wasabi/printer.py__init__zPrinter.__init__   s    < 99%6%=%=j%I5Q		."7"7
"CUK '	2]!2 '/B2B.B,@0@. 6l%[
"KKv&JJe$!+I!6I	O	    returnc                     | j                   S )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+   )r0   s    r3   countszPrinter.countsD   s    
 ||r5   titletextshowspacedexitsc                 L    | j                  ||t        j                  |||      S )a  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r0   r9   r:   r;   r<   r=   s         r3   goodzPrinter.goodK   +    " }}4x}}4e  
 	
r5   )r   Fc                      y N rC   s         r3   failzPrinter.fail`        	r5   )r   Tc                      y rG   rH   rC   s         r3   rI   zPrinter.failk   rJ   r5   c                 L    | j                  ||t        j                  |||      S )a  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.
        r?   )rA   r   FAILrC   s         r3   rI   zPrinter.failv   rE   r5   c                 L    | j                  ||t        j                  |||      S )a  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.
        r?   )rA   r   WARNrC   s         r3   warnzPrinter.warn   rE   r5   c                 L    | j                  ||t        j                  |||      S )a  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.
        r?   )rA   r   INFOrC   s         r3   infozPrinter.info   rE   r5   r   bg_coloriconc
                    |sy| j                   r| j                  j                  t        t        |      |      }| j                  j                  t        t        |      |      }| j
                  j                  t        t        |            }|r)t        dj                  ||            j                         }| j                  rt        |||      }t        |d      }|rdj                  |t        |d            }| j                  r?t        j                  j                         j                  d      }
dj                  |
|      }|	|rd	j                  |      }| j                   s|st#        |       |	~t$        j&                  j)                          t$        j*                  j)                          | j                   s|r|	dk7  r	 t-        |j                               t%        j8                  |	       | j                   s|r|S y# t.        $ rF}d
j1                  t3        j4                         dd       }t7        dj                  ||            d}~ww xY w)a  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)r0   r9   r:   r   rT   rU   r<   r;   r   r=   rb   etbs                r3   r:   zPrinter.text   s   2 ;;KKOODe$4e<E{{tC':HEH::>>$sD/2D%gnnT5&ABHHJu8<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   	H 	IAIIcharc           	         |syt        |      dk7  rt        dj                  |            | j                  r| j                  j                  t        t        |            }|r)t        dj                  ||            j                         }|t        t        | j                  t        |      z
        dz        dz
  z  }|rdj                  |      nd}t        dj                  ||	      d
      }t        |      | j                  k  r||| j                  t        |      z
  z  z   }| j                  r|S t        |       y)ag  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: {}rW      z {}  z
{deco}{text}{deco})decor:   T)bold)len
ValueErrorr*   r   r   r]   r   r^   r   r_   introundr    r`   r   rd   )r0   r:   rr   r;   rU   rv   s         r3   dividerzPrinter.divider   s    t9>%vd|  ;;::>>$sD/2D$W^^D$%?@FFH3udmmc$i&?AAEFJKD*.6==&BD&--4d-C$D 4y4==(ddmmc$i&?@@==Kdr5   datac                     |j                  dd      }t        |fi |}|r| j                  |       | j                  r|S t	        |       y)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.
        r9   N)popr   r|   r   rd   )r0   r}   kwargsr9   r:   s        r3   r   zPrinter.table  sE     

7D)T$V$LL==Kdr5   c                 N    t        |fi |}| j                  r|S t        |       y)zPrint a table row.

        data (Collection): The individual columns to format.
        kwargs: Row settings. See tables.row for details.
        N)r   r   rd   )r0   r}   r   r:   s       r3   r   zPrinter.row$  s&     4"6"==Kdr5   c              #     K   | j                   rd  y | j                  rt        |       d  y t        j                  j                          t        | j                  |f      }|j                          	 d  |j                          t        j                  j                  d       t        j                  j                          y # t        $ r6}|j                          t        j                  j                  d       |d }~ww xY ww)N)targetargsr[   z[2K)r   r#   rd   re   rf   rg   r   _spinnerstartrj   	terminatewrite)r0   r:   trp   s       r3   loadingzPrinter.loading/  s     ==  $KJJt}}D7;AGGI KKMJJ[)JJ  

  &		s+   A4D7C	 ;AD		D1DDDc                    t        j                  | j                        D ]d  }t        j                  j                  dj                  ||             t        j                  j                          t        j                  d       f y )Nz{} {}g?)
	itertoolscycler/   re   rf   r   r*   rg   timesleep)r0   r:   rr   s      r3   r   zPrinter._spinnerE  sX    OODII. 	DJJY--dD9:JJJJsO	r5   r@   c           	          | j                   r|t        j                  k(  rd}| j                  |xx   dz  cc<   | j	                  |||||||      S )NFr   )r   rU   r;   r<   r=   )r$   r   rO   r+   r:   )r0   r9   r:   r@   r;   r<   r=   s          r3   rA   zPrinter._get_msgK  sW     EX]]$:DUq yy4u5tFRW  
 	
r5   )TFNNP   u   ⠙⠹⠸⠼⠴⠦⠧⠇⠏z|/-\FFWASABIF)ru   ru   TFN)ru   ru   TFT)	ru   ru   NNNFTFN)ru   =TN)z
Loading...)NFFN)__name__
__module____qualname__boolr
   r   rz   r^   r4   propertyr   r8   r   rD   r   r   rI   r	   r   rP   rS   r:   r|   r   r   r   r   r   r   rA   rH   r5   r3   r   r      sJ    !% $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   $#

 
 }	

 
 
 }
r5   r   )&ra   r   r(   re   r   rl   collectionsr   
contextlibr   multiprocessingr   typingr   r   r   r	   r
   r   r   r   compatr   tablesr   r   utilr   r   r   r   r   r`   r   r   r   objectr   rH   r5   r3   <module>r      sL      	 
    % # S S S   5 5 ! 4 4F
f F
r5   