a
    3ge                     @   s  d dl mZ d dlZd dlZd dlZd dl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mZmZmZmZmZ d dlmZ d dl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l)m*Z* ddl+m,Z,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= dd	l>m Z  ddl?m@Z@ eA dkZBdZCdZDdddddddddd 	ee, eeE eEeeF eGeGeGeeeFef  eEeeeH eHee gef d!
d"d#ZIeG d$d% d%ZJeG d&d' d'ZKeG d(d) d)ZLeG d*d+ d+ZMG d,d- d-e4ZNG d.d/ d/ZOePd0krdd1l+m,Z, e, Z+d dlZedd2d3d4ZQedd2d5d6ZRdd7d8d9ZSeS  dS ):    )absolute_importN)	dataclassfield)walk_tb)
ModuleTypeTracebackType)	AnyCallableDictIterableListOptionalSequenceTypeUnion)guess_lexer_for_filename)CommentKeywordNameNumberOperatorString)Text)Token)ClassNotFound   )pretty)	loop_last)Columns)ConsoleConsoleOptionsConsoleRenderableRenderResultgroup)	Constrain)RegexHighlighterReprHighlighter)Panel)render_scope)Style)Syntax)ThemeWindows
   P   d      FT )	consolewidthextra_linestheme	word_wrapshow_localsindent_guidessuppress
max_frames)
r2   r3   r4   r5   r6   r7   r8   r9   r:   returnc        	      
      s   | du rt tjdn| tt ttt dd	f	dd tdd fdd}	zt }
|	|
 tj	W S  t
y   tj	} t_	| Y S 0 dS )	a8  Install a rich traceback handler.

    Once installed, any tracebacks will be printed with syntax highlighting and rich formatting.


    Args:
        console (Optional[Console], optional): Console to write exception to. Default uses internal Console instance.
        width (Optional[int], optional): Width (in characters) of traceback. Defaults to 100.
        extra_lines (int, optional): Extra lines of code. Defaults to 3.
        theme (Optional[str], optional): Pygments theme to use in traceback. Defaults to ``None`` which will pick
            a theme appropriate for the platform.
        word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.
        show_locals (bool, optional): Enable display of local variables. Defaults to False.
        indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.
        suppress (Sequence[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback.

    Returns:
        Callable: The previous exception handler that was replaced.

    N)file)type_value	tracebackr;   c                    s*    tj| || d d S )N)r3   r4   r5   r6   r7   r8   r9   r:   )print	Tracebackfrom_exception)r=   r>   r?   )	r4   r8   r:   r7   r9   r5   traceback_consoler3   r6   r1   h/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/pip/_vendor/rich/traceback.py
excepthookF   s    zinstall.<locals>.excepthook)ipr;   c                    sb   i j  ttd d fdd}ddtttd dfdd_|_ fd	d
_d S )N)argskwargsr;   c                     s   | | i | dS )zEwrap the default ip.showtraceback to store info for ip._showtracebackNr1   rG   rH   )default_showtracebacktb_datar1   rD   ipy_show_traceback_   s    zCinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_show_tracebackF)	is_syntax)rG   rM   rH   r;   c                    st     }| rdn|d }dd}d|r2dnd}t|D ]}|du rP qX|j}q@ |d |d | i dS )z2Internally called traceback from ip._showtracebackN   running_compiled_codeF	tb_offsetr   r   )_get_exc_infogetrangetb_next)rM   rG   rH   	exc_tupletbcompiledrP   _)rE   rF   rK   r1   rD   ipy_display_tracebacke   s    zFinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_display_tracebackc                     s    | ddi|S )NrM   Tr1   rI   )rY   r1   rD   <lambda>   s   z9install.<locals>.ipy_excepthook_closure.<locals>.<lambda>)showtracebackr   bool_showtracebackshowsyntaxerror)rF   rL   )rE   )rJ   rF   rY   rK   rD   ipy_excepthook_closure[   s    z'install.<locals>.ipy_excepthook_closure)r   sysstderrr   BaseExceptionr   r   r   get_ipythonrE   	Exception)r2   r3   r4   r5   r6   r7   r8   r9   r:   r_   rF   old_excepthookr1   )
rE   r4   r8   r:   r7   r9   r5   rC   r3   r6   rD   install$   s      )rf   c                   @   sL   e Zd ZU eed< eed< eed< dZeed< dZee	ee
jf  ed< dS )Framefilenamelinenoname lineNlocals)__name__
__module____qualname__str__annotations__intrl   rm   r   r
   r   Noder1   r1   r1   rD   rg      s
   
rg   c                   @   s6   e Zd ZU eed< eed< eed< eed< eed< dS )_SyntaxErroroffsetrh   rl   ri   msgN)rn   ro   rp   rs   rr   rq   r1   r1   r1   rD   ru      s
   
ru   c                   @   sP   e Zd ZU eed< eed< dZee ed< dZe	ed< e
edZee ed< dS )	Stackexc_type	exc_valueNsyntax_errorFis_cause)default_factoryframes)rn   ro   rp   rq   rr   r{   r   ru   r|   r\   r   listr~   r   rg   r1   r1   r1   rD   rx      s
   
rx   c                   @   s   e Zd ZU ee ed< dS )TracestacksN)rn   ro   rp   r   rx   rr   r1   r1   r1   rD   r      s   
r   c                   @   s   e Zd ZdgZdS )PathHighlighterz(?P<dim>.*/)(?P<bold>.+)N)rn   ro   rp   
highlightsr1   r1   r1   rD   r      s   r   c                   @   sR  e Zd ZdZddddddZddd	dd
d
deeddfee ee	 e	ee
 eeee	e	eee
ef  e	dddZedd	dd
d
deeddf
ee eee ee	 e	ee
 eeee	e	eee
ef  e	d dddZed
eefee eee ee	e	edddZeeedddZe eedddZee
e
e
dddZe eedd d!Z dS )"rA   a  A Console renderable that renders a traceback.

    Args:
        trace (Trace, optional): A `Trace` object produced from `extract`. Defaults to None, which uses
            the last exception.
        width (Optional[int], optional): Number of characters used to traceback. Defaults to 100.
        extra_lines (int, optional): Additional lines of code to render. Defaults to 3.
        theme (str, optional): Override pygments theme used in traceback.
        word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.
        show_locals (bool, optional): Enable display of local variables. Defaults to False.
        indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.
        locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
            Defaults to 10.
        locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
        suppress (Sequence[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback.
        max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.

    textpythoncythonpyrex)rk   z.pyz.pxdz.pyxz.pxiNr/   r0   FTr1   )tracer3   r4   r5   r6   r7   r8   locals_max_lengthlocals_max_stringr9   r:   c                 C   s  |d u rHt  \}}}|d u s.|d u s.|d u r6td| j||||d}|| _|| _|| _t|pdd| _	|| _
|| _|| _|| _|	| _g | _|
D ]Z}t|ts|jd usJ |dtj|j}n|}tjtj|}| j| q|dkrtd|nd| _d S )Nz9Value for 'trace' required if not called in except: blockr7   	ansi_darkz+ must be a module with '__file__' attributer      )r`   exc_info
ValueErrorextractr   r3   r4   r*   	get_themer5   r6   r7   r8   r   r   r9   
isinstancerq   __file__ospathdirnamenormpathabspathappendmaxr:   )selfr   r3   r4   r5   r6   r7   r8   r   r   r9   r:   ry   rz   r?   suppress_entityr   r1   r1   rD   __init__   s<    
zTraceback.__init__)ry   rz   r?   r3   r4   r5   r6   r7   r8   r   r   r9   r:   r;   c                 C   s0   | j ||||d}| |||||||	|
|||dS )a  Create a traceback from exception info

        Args:
            exc_type (Type[BaseException]): Exception type.
            exc_value (BaseException): Exception value.
            traceback (TracebackType): Python Traceback object.
            width (Optional[int], optional): Number of characters used to traceback. Defaults to 100.
            extra_lines (int, optional): Additional lines of code to render. Defaults to 3.
            theme (str, optional): Override pygments theme used in traceback.
            word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.
            show_locals (bool, optional): Enable display of local variables. Defaults to False.
            indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.
            locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
                Defaults to 10.
            locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
            suppress (Iterable[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback.
            max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.

        Returns:
            Traceback: A Traceback instance that may be printed.
        r   )
r3   r4   r5   r6   r7   r8   r   r   r9   r:   )r   )clsry   rz   r?   r3   r4   r5   r6   r7   r8   r   r   r9   r:   rich_tracebackr1   r1   rD   rB      s     &zTraceback.from_exception)ry   rz   r?   r7   r   r   r;   c                    s  g }d}ddl m}	 ttddd}
t|
|j|
||d}t|trtt|j	pPd|j
pXd|jp`d|jphd	|jd
|_|| |jj}t|D ]\}}|jj}|r|dstj|stj|	|}|jddrqt|pd||jj|r fdd|j D ndd}|| |jddr|jdd= qt|dd}|rZ|j}|}|j }d}q$|j!}|rt|dds|j}|}|j }d}q$qq$t"|d}|S )a  Extract traceback information.

        Args:
            exc_type (Type[BaseException]): Exception type.
            exc_value (BaseException): Exception value.
            traceback (TracebackType): Python Traceback object.
            show_locals (bool, optional): Enable display of local variables. Defaults to False.
            locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
                Defaults to 10.
            locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.

        Returns:
            Trace: A Trace instance which you can use to construct a `Traceback`.
        Fr   )_IMPORT_CWD)_objectr;   c                 S   s$   z
t | W S  ty   Y dS 0 dS )z1Don't allow exceptions from __str__ to propagate.z<exception str() failed>N)rq   rd   )r   r1   r1   rD   safe_strS  s    
z#Traceback.extract.<locals>.safe_str)ry   rz   r|   ?rk   )rv   rh   ri   rl   rw   <_rich_traceback_omitc                    s"   i | ]\}}|t j| d qS ))
max_length
max_string)r   traverse).0keyr>   r   r   r1   rD   
<dictcomp>x  s   z%Traceback.extract.<locals>.<dictcomp>N)rh   ri   rj   rm   _rich_traceback_guard	__cause__T__suppress_context__)r   )#pip._vendor.richr   r   rq   rx   rn   r   SyntaxErrorru   rv   rh   ri   r   rw   r{   r   r~   r   f_codeco_filename
startswithr   r   isabsjoinf_localsrR   rg   co_nameitemsgetattr	__class____traceback____context__r   )r   ry   rz   r?   r7   r   r   r   r|   r   r   stackr   frame_summaryline_norh   framecauser   r1   r   rD   r   5  sp    

		
zTraceback.extract)r2   optionsr;   c                 c   s  | j }| }|j}t|t|t|t|tj|t	|t
tdd |t|ttdd |t	|tj|tj|tj|tj|t|t|tjtdd ddd}t }tt| jjD ]P\}}	|	jr,t| |	d|ddd	d
}
t|
| j}
|| |
V  W d    n1 s"0    Y  |	jd ur||8 tt| |	j|ddd	| jd| jV  W d    n1 s0    Y  t|	j ddf||	jj V  n>|	j!rt|	j ddf||	j!V  nt|	j dfV  |s|	j"rt#dV  qt#dV  qd S )NT)dim)bold)r   pygments.textpygments.stringpygments.functionpygments.numberzrepr.indentzrepr.strz
repr.bracezrepr.numberzrepr.bool_truezrepr.bool_falsez	repr.nonezscope.borderzscope.equalsz	scope.keyzscope.key.specialF)inheritz7[traceback.title]Traceback [dim](most recent call last)ztraceback.border)r   r   )titlestyleborder_styleexpandpaddingztraceback.border.syntax_error)r   r   r   r   r3   z: ztraceback.exc_typezI
[i]The above exception was the direct cause of the following exception:
zH
[i]During handling of the above exception, another exception occurred:
)$r5   get_background_styleget_style_for_tokenr+   	TextTokenr   r   r   Functionr   r   r)   r   Constant	Delimiterr   r&   r   reversedr   r   r~   r'   _render_stackr$   r3   	use_themer{   _render_syntax_errorr   assemblery   rw   rz   r|   from_markup)r   r2   r   r5   background_styletoken_styletraceback_themehighlighterlastr   stack_renderabler1   r1   rD   __rich_console__  s    &
&
zTraceback.__rich_console__)r{   r;   c                 c   s   t  }t }|jdkrHtjd|j dfdt|jdfdd}||V  ||j }d|_	t
|jd	 t|}|d
|| |tjdd|  d dd7 }|V  d S )Nz<stdin> r   :r   r   r   r   Tr   zbold underline
u   [traceback.offset]▲[/])r&   r   rh   r   r   rq   ri   rl   rstripno_wrapminrv   lenstylizer   )r   r{   r   path_highlighterr   syntax_error_textrv   r1   r1   rD   r     s&    

zTraceback._render_syntax_error)rh   coder;   c                 C   s   t j|d }|sP|d}|dkr2|d | n|}|drPd| v rPdS z| j|pht||j	W S  t
y~   Y dS 0 d S )Nr   z#!r   r   )r   r   splitextindexr   lowerLEXERSrR   r   rj   r   )r   rh   r   extnew_line_index
first_liner1   r1   rD   _guess_lexer  s    
zTraceback._guess_lexer)r   r;   c                 #   s"  t  }j}i  ttd fdd}ttt dfdd}d }jdkrjtjd t|j	jd  }d	}t
|j	D ]\}}	|r||v rd
}qx|r|d usJ tdt| ddddV  d	}|dk}
|	jtfddjD }tj|t|	jdddt|	jdfd|	jdfdd}|	jds8|
s8dV  |V  |	jdr\||	E d H  qx|sxzZ||	j}|	j|}t|||d
|	jj |	jj f|	jhjdjd	d
}dV  W n< ty } z"td| dfV  W Y d }~qxd }~0 0 |	jrt|g||	ddn|V  qxd S ) N)rh   r;   c                    sV     | }|du rRt| dddd}| }W d   n1 s@0    Y  | | < |S )zRead files, and cache results on filename.

            Args:
                filename (str): Filename to read

            Returns:
                str: Contents of file
            Nrtzutf-8replace)encodingerrors)rR   openread)rh   r   	code_file)
code_cacher1   rD   	read_code  s    	
&z*Traceback._render_stack.<locals>.read_code)r   r;   c                 3   s&   | j r"t| j d j j jdV  d S )Nrm   )r   r8   r   r   )rm   r(   r8   r   r   )r   )r   r1   rD   render_locals*  s    z.Traceback._render_stack.<locals>.render_localsr   rN   FTz
... z frames hidden ...centerztraceback.error)justifyr   c                 3   s   | ]}  |V  qd S )N)r   )r   r   )frame_filenamer1   rD   	<genexpr>M      z*Traceback._render_stack.<locals>.<genexpr>r   r   r   r   z in r   r   r   rk   X   )r5   line_numbers
line_rangehighlight_linesr6   
code_widthr8   dedentr   r   )r   )r   r5   rq   rg   r   r!   r:   rS   r   r~   	enumerater   rh   anyr9   r   ri   rj   r   r   r*   r4   r6   r8   rd   rm   r   )r   r   r   r5   r  r  exclude_framesexcludedframe_indexr   first
suppressedr   r   
lexer_namesyntaxerrorr1   )r   r  r   rD   r     s    





zTraceback._render_stack)!rn   ro   rp   __doc__r   LOCALS_MAX_LENGTHLOCALS_MAX_STRINGr   r   rs   rq   r\   r   r   r   r   classmethodr   r   rb   r   rB   r   r   r    r"   r   r#   ru   r   r   rx   r   r1   r1   r1   rD   rA      s   
.6iNrA   __main__)r   )ar;   c                 C   s   d}t ||   d S )Nr   )r@   )r  oner1   r1   rD   bar  s    r  c                 C   s   d}h ddd}t |  d S )NT>   zDuncan IdahozPaul AtreideszVladimir HarkonnenzThufir Hawat)NFT)
charactersZatomic_types)r  )r  r   Zzedr1   r1   rD   foo  s
    	r!  )r;   c                   C   s@   z"zt d W n   t Y n0 W n   tjdd Y n0 d S )Nr   Tr   )r!  Zslfkjsldkfjr2   print_exceptionr1   r1   r1   rD   r    s    r  )T
__future__r   r   platformr`   dataclassesr   r   r?   r   typesr   r   typingr   r	   r
   r   r   r   r   r   r   pip._vendor.pygments.lexersr   pip._vendor.pygments.tokenr   r   r   r   r   r   r   r   r   pip._vendor.pygments.utilr   rk   r   _loopr   columnsr   r2   r   r    r!   r"   r#   	constrainr$   r   r%   r&   panelr'   scoper(   r   r)   r  r*   r   r5   r+   systemWINDOWSr  r  rs   rq   r\   rb   rf   rg   ru   rx   r   r   rA   rn   r  r!  r  r1   r1   r1   rD   <module>   s   , l   R

