
    ֤i                     n    d dl Z d dlmZmZmZ ddlmZmZmZ esdndZ	esdndZ
esd	nd
Z G d de      Zy)    N)OptionalTupleUnion   )NO_UTF8colorsupports_ansiu   └─z|_u   ├─z|__u   ──__c                       e Zd Zddddd e       ddfdeeef   d	eeef   d
eeef   dedee   dededefdZ	dedefdZ
d Zd Zd Zy)TracebackPrinterredblueyellow   Ncolor_errorcolor_tbcolor_highlightindenttb_base
tb_excludetb_range_starttb_range_endc	                 T   || _         || _        || _        d|z  | _        |dk(  r=dj	                  t        j                         t
        j                  j                        }n|dj	                  |      }|| _	        t        |      | _        || _        || _        t               | _        y)a  Initialize a traceback printer.

        color_error (Union[str, int]): Color name or code for errors.
        color_tb (Union[str, int]): Color name or code for traceback headline.
        color_highlight (Union[str, int]): Color name or code for highlights.
        indent (int): Indentation in spaces.
        tb_base (Optional[str]): Optional name of directory to use to show relative paths. For
            example, "thinc" will look for the last occurence of "/thinc/" in
            a path and only show path to the right of it.
        tb_exclude (tuple): List of filenames to exclude from traceback.
        tb_range_start (int): The starting index from a traceback to include.
        tb_range_end (int): The final index from a traceback to include. If None
            the traceback will continue until the last record.
        RETURNS (TracebackPrinter): The traceback printer.
         .z{}{}Nz/{}/)r   r   r   r   formatosgetcwdpathsepr   tupler   r   r   r	   )	selfr   r   r   r   r   r   r   r   s	            i/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/wasabi/traceback_printer.py__init__zTracebackPrinter.__init__   s    4 ' .Flc>mmBIIK=G mmG,G
+,(*_    titlereturnc                 n   |j                  dd      }|j                  dd      }| j                  rt        || j                  d      }|r/ddj	                  |D cg c]  }| j
                  |z    c}      z   nd}|r| j                  ||      nd}d	j                  | j
                  |||      }|S c c}w )
a  Output custom formatted tracebacks and errors.

        title (str): The message title.
        *texts (str): The texts to print (one per line).
        RETURNS (str): The formatted traceback. Can be printed or raised
            by custom exception.
        	highlightFtbNTfgbold
 z

{}{}{}{}
)getr	   r   r   joinr   _get_tracebackr   )	r$   r(   textssettingsr+   r,   textinfomsgs	            r%   __call__zTracebackPrinter.__call__4   s     LLe4	\\$%%D$4$44@EKPtdii Ft!3 FGGVX35T  Y/2%%dkk5$C
 !Gs   B2
c                 4   |D cg c]#  }|d   j                  | j                        r"|% }}| j                  || j                  | j                   n|| j                  d  }t	        |      D 	cg c]*  \  }\  }}}}	| j                  ||||	|t        |      |      , }
}}}}}	dj                  |
      j                         }d}| j                  rt        || j                  d      }dj                  ||| j                        S c c}w c c}	}}}}w )Nr   r0   z
Traceback:Tr-   z

{indent}{title}
{indent}{tb})r(   r,   r   )endswithr   r   r   	enumerate_format_tracebacklenr3   stripr	   r   r   r   r   )r$   r,   r+   recordtb_rangeir!   linefnr7   tb_listtb_datar(   s                r%   r4   zTracebackPrinter._get_tracebackE   s   #%QVAY-?-?-PfQQ   , t""T%6%67D'')* 	 .7x-@
 
))D$D ""4r4CM9U
 
 ))G$**,%DMM=E299GDKK : 
 	
 R
s   #DD4/Dc                 |   d}||dz
  k(  rt         nt        t        |z  z   }	| j                  r-| j                  |v r|j	                  | j                  d      d   }||dz
  k(  r| j                  |||      nd}| j                  rt        |d      }t        |d      }|j                  | j                  ||	|||      S )Nz1{base_indent}{indent} {fn} in {path}:{line}{text}r   r1   T)r/   )	underline)base_indentrD   r   r7   rE   r!   )
	LINE_EDGE	LINE_FORK	LINE_PATHr   rsplit_format_user_errorr	   r   r   r   )
r$   r!   rD   rE   r7   rC   countr+   templater   s
             r%   r>   z"TracebackPrinter._format_tracebackY   s    F EAI~)9	AM<<DLLD0;;t||Q/2D>?519nt&&tQ	:RTr%B.D  
 	
r'   c                     d|z  dz   }| j                   rt        || j                        }|r5| j                   r)t        || j                        }|j	                  ||      }dj                  | j                  ||      S )Nz  z >>>)r.   z

{}  {} {})r	   r   r   r   replacer   r   )r$   r7   rC   r+   spacingformatted_highlights         r%   rO   z#TracebackPrinter._format_user_errork   ss    (V#G(8(89G++"'	d6J6J"K<<	+>?D##DKK$??r'   )__name__
__module____qualname__r#   r   strintr   r   r&   r:   r4   r>   rO    r'   r%   r   r      s     (-$*+3!%!G &-38_&- S/&- sCx	&-
 &- #&- &- &- &-Pc # "
(
$@r'   r   )r   typingr   r   r   utilr   r   r	   rK   rL   rM   objectr   r[   r'   r%   <module>r_      s?    	 ) ) / /#H	#H	#H	g@v g@r'   