o
    Ëý°jOe  ã                   @   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&m'Z' ddl(m)Z) ddl*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< dd	l=m Z  ddl>m?Z? e @¡ dkZAdZBdZCddddddddddœ	d ee+ d!eeD d"eDd#eeE d$eFd%eFd&eFd'eeeEef  d(eDd)eeeG eGee gef fd*d+„ZHeG d,d-„ d-ƒƒZIeG d.d/„ d/ƒƒZJeG d0d1„ d1ƒƒZKeG d2d3„ d3ƒƒZLG d4d5„ d5e3ƒZMG d6d7„ d7ƒZNeOd8k�rZdd9l*m+Z+ e+ƒ Z*d dlZd:ed)dfd;d<„ZPd:ed)dfd=d>„ZQdAd?d@„ZReRƒ  dS dS )Bé    )Ú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é   )Úpretty)Ú
loop_firstÚ	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_framesr2   r3   r4   r5   r6   r7   r8   r9   r:   Úreturnc        	      
      sž   | du r
t tjd�n| ‰dtt dtdtt ddf‡‡‡‡‡‡‡‡‡	f	dd„‰ d	tddf‡ fd
d„}	ztƒ }
|	|
ƒ tj	W S  t
yN   tj	}ˆ t_	| Y S w )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   ú�/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_vendor/rich/traceback.pyÚ
excepthookE   s   õÿzinstall.<locals>.excepthookÚipc              	      sl   i ‰ˆj ‰ dtdtdd f‡ ‡fdd„}ddœdtdtdtdd f‡‡‡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_syntaxrM   c                    st   ˆ  ¡ }| rdn|d }ˆ dd¡}ˆ d|rdnd¡}t|ƒD ]}|du r( n|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_tracebackd   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_closureZ   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                   @   s˜  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dee dee	 de	dee
 dededede	de	deee
ef  de	fdd„Zedd	dd
d
deeddf
dee dedee dee	 de	dee
 dededede	de	deee
ef  de	dd fdd„ƒZed
eefdee dedee dede	de	defd d!„ƒZd"ed#edefd$d%„Zeƒ d&edefd'd(„ƒZed)e
d*e
de
fd+d,„ƒZeƒ d-edefd.d/„ƒZ dS )0rA   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 r$t  ¡ \}}}|d u s|d u s|d u rtdƒ‚| j||||d�}|| _|| _|| _t |p2d¡| _	|| _
|| _|| _|| _|	| _g | _|
D ]-}t|tƒsd|jd us\J |›d�ƒ‚tj |j¡}n|}tj tj |¡¡}| j |¡ qI|dkrƒtd|ƒ| _d S 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?   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_exceptionc                    s–  g }d}ddl m}	 dtdtfdd„}
	 t|
|jƒ|
|ƒ|d	�}t|tƒr<t|j	p*d|j
p.d
|jp2d|jp6d|jd�|_| |¡ |jj}t|ƒD ]F\}}|jj}|re| d¡setj |¡setj |	|¡}t|pid
||jj|r|‡ ‡fdd„|j ¡ D ƒndd�}||ƒ d|jv r�|jdd…= qIt|ddƒ}|r¨|jr¨|j}|}|j}|r¨d}q|j }|rÃ|jrÃt|ddƒsÃ|j}|}|j}|rÃd}q	 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 w )z1Don't allow exceptions from __str__ to propegate.z<exception str() failed>)rq   rd   )r¡   r1   r1   rD   Úsafe_strR  s
   
ÿz#Traceback.extract.<locals>.safe_strT)ry   rz   r|   ú?rk   )rv   rh   ri   rl   rw   ú<c                    s"   i | ]\}}|t j|ˆ ˆd �“qS ))Ú
max_lengthÚ
max_string)r   Útraverse)Ú.0Úkeyr>   ©r‰   rŠ   r1   rD   Ú
<dictcomp>u  s    ûýÿz%Traceback.extract.<locals>.<dictcomp>N)rh   ri   rj   rm   Ú_rich_traceback_guardÚ	__cause__Ú__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Újoinrg   Úco_nameÚf_localsÚitemsÚgetattrÚ__traceback__Ú	__class__Ú__context__r€   )rž   ry   rz   r?   r7   r‰   rŠ   r�   r|   r    r¢   Ústackr™   Úframe_summaryÚline_norh   ÚframeÚcauserˆ   r1   rª   rD   r�   4  s~   ý
û
	øú	ó
€
ÿþ
ý
zTraceback.extractr2   Úoptionsc                 c   sR  � | j }| ¡ }|j}ti d|tƒ“d|tƒ“d|tƒ“d|tjƒ“d|t	ƒ“d|t
ƒtdd� “d	|tƒ“d
|tƒtdd� “d|t	ƒ“d|tjƒ“d|tjƒ“d|tjƒ“d|tjƒ“d|tƒ“d|tƒ“d|tjƒtdd� “dd�}tƒ }tt| jjƒƒD ]¥\}}	|	jr³t|  |	¡d|dddd�}
t|
| jƒ}
| |¡� |
V  W d   ƒ n1 s®w   Y  |	jd uró| |¡� tt|  |	j¡|ddd| jd�| jƒV  W d   ƒ n1 sÜw   Y  t |	j› d�df||	jj ƒ¡V  n|	j!�rt |	j› d�df||	j!ƒ¡V  n
t |	j› df¡V  |�s&|	j"�r t #d¡V  q�t #d¡V  q�d S ) Nr   úpygments.textúpygments.stringúpygments.functionúpygments.numberzrepr.indentT)Údimzrepr.strz
repr.brace)Úboldz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{   c                 c   s¨   � t ƒ }tƒ }|jdkr%t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_errorrh   Úcodec                 C   sl   t j |¡d }|s(| d¡}|dkr|d |… n|}| d¡r(d| ¡ v r(dS | j |¡p3t||ƒj	}|S )Néÿÿÿÿræ   z#!r…   )
r”   r•   ÚsplitextÚindexr³   ÚlowerÚLEXERSrR   r   rj   )rž   rh   rî   ÚextÚnew_line_indexÚ
first_lineÚ
lexer_namer1   r1   rD   Ú_guess_lexer  s   
ÿzTraceback._guess_lexerr½   c                 #   s   � t ƒ }ˆj}i ‰ dtdtf‡ fdd„}dtdtt f‡fdd„}d }ˆjdkr8tˆjd	 t|j	ƒˆjd	  ƒ}d
}t
|j	ƒD ]Î\}}	|rL||v rLd}q?|rd|d usTJ ‚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¡sœ|
sœdV  |V  |	j d¡r­||	ƒE d H  q?|�sz-||	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 }~q?d }~ww |	j�r
t|g||	ƒ¢dd �n|V  q?d S )!Nrh   r;   c                    sV   ˆ   | ¡}|du r)t| dddd��}| ¡ }W d  ƒ n1 s w   Y  |ˆ | < |S )z·Read 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_coderÀ   c                 3   s,   � | j rt| j dˆ jˆ jˆ jd�V  d S 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Ë   r   c                 3   s   � | ]}ˆ   |¡V  qd S )N)r³   )r¨   r•   )Úframe_filenamer1   rD   Ú	<genexpr>N  s   € 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‚   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î   r÷   Ú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ùþýüûúùøjÿÿ
þNrA   Ú__main__)r   Úac                 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>   úDuncan IdahoúThufir HawatúPaul AtreidesúVladimir Harkonnen)NFT)Ú
charactersÚatomic_types)r  )r  r¬   Úzedr1   r1   rD   Úfoo�  s
   ù	r%  c                   C   s>   zzt dƒ W W d S    t Y W d S    tjdd� Y d S )Nr   Tr‹   )r%  Úslfkjsldkfjr2   Úprint_exceptionr1   r1   r1   rD   r  œ  s   r  )r;   N)SÚ
__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   rk   r   Ú_loopr   r   Ú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   
T


Þ