HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_vendor/rich/__pycache__/traceback.cpython-310.pyc
o

@%NeOe�@s�ddlmZddlZddlZddlZddlmZmZddlm	Z	ddl
mZmZddl
mZmZmZmZmZmZmZmZmZddlmZddlmZmZmZmZmZmZdd	lm Z!dd
lm"Z"ddl#m$Z$dd
l%m&Z&m'Z'ddl(m)Z)ddl*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1ddl2m3Z3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:ddl;m<Z<dd	l=m Z ddl>m?Z?e�@�dkZAdZBdZCdddddddddd�	d ee+d!eeDd"eDd#eeEd$eFd%eFd&eFd'eeeEefd(eDd)eeeGeGeegeffd*d+�ZHeGd,d-�d-��ZIeGd.d/�d/��ZJeGd0d1�d1��ZKeGd2d3�d3��ZLGd4d5�d5e3�ZMGd6d7�d7�ZNeOd8k�rZdd9l*m+Z+e+�Z*ddlZd:ed)dfd;d<�ZPd:ed)dfd=d>�ZQdAd?d@�ZReR�dSdS)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_framesr2r3r4r5r6r7r8r9r:�returnc	
s�|dur
ttjd�n|�dttdtdttddf���������	f	dd��d	tddf�fd
d�}	zt�}
|	|
�tj	WSt
yNtj	}�t_	|YSw)a8Install 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;cs*��tj|||��������d��dS)N)r3r4r5r6r7r8r9r:)�print�	Traceback�from_exception)r=r>r?)	r4r8r:r7r9r5�traceback_consoler3r6r1�</usr/lib/python3/dist-packages/pip/_vendor/rich/traceback.py�
excepthookEs��zinstall.<locals>.excepthook�ipc	sli��j�dtdtddf��fdd�}dd�dtdtdtddf���fd	d
����_|�_�fdd��_dS)
N�args�kwargsr;cs|��|i|��dS)zEwrap the default ip.showtraceback to store info for ip._showtracebackNr1�rGrH)�default_showtraceback�tb_datar1rD�ipy_show_traceback^szCinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_show_tracebackF)�	is_syntaxrMcst���}|rdn|d}��dd�}��d|rdnd�}t|�D]}|dur(n|j}q �|d|d|�i�dS)z2Internally called traceback from ip._showtracebackN��running_compiled_codeF�	tb_offsetrr)�
_get_exc_info�get�range�tb_next)rMrGrH�	exc_tuple�tb�compiledrP�_)rErFrKr1rD�ipy_display_tracebackdszFinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_display_tracebackcs�|ddi|��S)NrMTr1rI)rYr1rD�<lambda>s���z9install.<locals>.ipy_excepthook_closure.<locals>.<lambda>)�
showtracebackr�bool�_showtraceback�showsyntaxerror)rFrL)rE)rJrFrYrKrD�ipy_excepthook_closureZs �����z'install.<locals>.ipy_excepthook_closure)r�sys�stderrr�
BaseExceptionr
rr�get_ipythonrE�	Exception)r2r3r4r5r6r7r8r9r:r_rF�old_excepthookr1)
rEr4r8r:r7r9r5rCr3r6rD�install#s( ����)�rfc@sLeZdZUeed<eed<eed<dZeed<dZee	ee
jfed<dS)�Frame�filename�lineno�name��lineN�locals)�__name__�
__module__�__qualname__�str�__annotations__�intrlrmr
r
r�Noder1r1r1rDrg�s
rgc@s6eZdZUeed<eed<eed<eed<eed<dS)�_SyntaxError�offsetrhrlri�msgN)rnrorprsrrrqr1r1r1rDru�s
ruc@sPeZdZUeed<eed<dZeeed<dZe	ed<e
ed�Ze
eed<dS)	�Stack�exc_type�	exc_valueN�syntax_errorF�is_cause)�default_factory�frames)rnrorprqrrr{r
rur|r\r�listr~rrgr1r1r1rDrx�s
rxc@seZdZUeeed<dS)�Trace�stacksN)rnrorprrxrrr1r1r1rDr��s
r�c@seZdZdgZdS)�PathHighlighterz(?P<dim>.*/)(?P<bold>.+)N)rnrorp�
highlightsr1r1r1rDr��s
r�c@s�eZdZdZdddddd�Zddd	dd
d
deeddfd
eedee	de	dee
dededede	de	dee
e
efde	fdd�Zedd	dd
d
deeddf
deededeedee	de	dee
dededede	de	dee
e
efde	ddfdd��Zed
eefdeededeedede	de	defd d!��Zd"ed#edefd$d%�Ze�d&edefd'd(��Zed)e
d*e
de
fd+d,��Ze�d-edefd.d/��Z dS)0rAa�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)rkz.pyz.pxdz.pyxz.pxiNr/r0FTr1�tracer3r4r5r6r7r8�locals_max_length�locals_max_stringr9r:cCs|dur$t��\}}
}|dus|
dus|durtd��|j||
||d�}||_||_||_t�|p2d�|_	||_
||_||_||_
|	|_g|_|
D]-}t|t�sd|jdus\J|�d���tj�|j�}n|}tj�tj�|��}|j�|�qI|dkr�td|�|_dSd|_dS)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�r3r4r*�	get_themer5r6r7r8r�r�r9�
isinstancerq�__file__�os�path�dirname�normpath�abspath�append�maxr:)�selfr�r3r4r5r6r7r8r�r�r9r:ryrzr?�suppress_entityr�r1r1rD�__init__�s:��
�"zTraceback.__init__ryrzr?r;c
Cs0|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�)
r3r4r5r6r7r8r�r�r9r:)r�)�clsryrzr?r3r4r5r6r7r8r�r�r9r:�rich_tracebackr1r1rDrB�s &��zTraceback.from_exceptioncs�g}d}ddlm}	dtdtfdd�}
	t|
|j�|
|�|d	�}t|t�r<t|j	p*d|j
p.d
|jp2d|jp6d|j
d�|_|�|�|jj}t|�D]F\}
}|
jj}|re|�d
�setj�|�setj�|	|�}t|pid
||
jj|r|��fdd�|
j��D�ndd�}||�d|
jvr�|jdd�=qIt|dd�}|r�|jr�|j}|}|j}|r�d}q|j }|r�|jr�t|dd�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;cSs zt|�WStyYdSw)z1Don't allow exceptions from __str__ to propegate.z<exception str() failed>)rqrd)r�r1r1rD�safe_strRs

�z#Traceback.extract.<locals>.safe_strT)ryrzr|�?rk)rvrhrirlrw�<cs"i|]
\}}|tj|��d��qS))�
max_length�
max_string)r�traverse)�.0�keyr>�r�r�r1rD�
<dictcomp>us���z%Traceback.extract.<locals>.<dictcomp>N)rhrirjrm�_rich_traceback_guard�	__cause__�__suppress_context__)r�)"�pip._vendor.richr�rrqrxrnr��SyntaxErrorrurvrhrir�rwr{r�r~r�f_code�co_filename�
startswithr�r��isabs�joinrg�co_name�f_locals�items�getattr�
__traceback__�	__class__�__context__r�)r�ryrzr?r7r�r�r�r|r�r��stackr��
frame_summary�line_norh�frame�causer�r1r�rDr�4s~�
�
	��	�
�
��
�
zTraceback.extractr2�optionsccsR�|j}|��}|j}tid|t��d|t��d|t��d|tj��d|t	��d|t
�tdd��d	|t��d
|t�tdd��d|t	��d
|tj
��d|tj
��d|tj
��d|tj��d|t��d|t��d|tj
�tdd��dd�}t�}tt|jj��D]�\}}	|	jr�t|�|	�d|dddd�}
t|
|j�}
|�|��|
VWd�n1s�wY|	jdur�|�|��tt|�|	j�|ddd|jd�|j�VWd�n1s�wYt�|	j�d�df||	jj ��Vn|	j!�rt�|	j�d�df||	j!��Vn
t�|	j�df�V|�s&|	j"�r t�#d�Vq�t�#d�Vq�dS) Nr�
pygments.text�pygments.string�pygments.function�pygments.numberzrepr.indentT)�dimzrepr.strz
repr.brace)�boldzrepr.numberzrepr.bool_truezrepr.bool_falsez	repr.nonezscope.borderzscope.equalsz	scope.keyzscope.key.specialF)�inheritz7[traceback.title]Traceback [dim](most recent call last)ztraceback.border)rr)�title�style�border_style�expand�paddingztraceback.border.syntax_error)r�r�r�r�r3z: ztraceback.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+�	TextTokenrrr�Functionrrr)r�Constant�	Delimiterrr&r�reversedr�r�r~r'�
_render_stackr$r3�	use_themer{�_render_syntax_errorr�assembleryrwrzr|�from_markup)r�r2r�r5�background_style�token_style�traceback_theme�highlighter�lastr��stack_renderabler1r1rD�__rich_console__�s�����
�����	�

�
�
�

�������

���
������zTraceback.__rich_console__r{ccs��t�}t�}|jdkr%tjd|j��dfdt|j�dfdd�}||�V||j���}d|_	t
|jd	t|��}|�
d
||�|tjdd|ddd�7}|VdS)
Nz<stdin>� r���:r�r�r��r�Trzbold underline�
u[traceback.offset]▲[/])r&r�rhrr�rqrirl�rstrip�no_wrap�minrv�len�stylizer�)r�r{r��path_highlighterr��syntax_error_textrvr1r1rDr��s(�
�
�
zTraceback._render_syntax_errorrh�codecCsltj�|�d}|s(|�d�}|dkr|d|�n|}|�d�r(d|��vr(dS|j�|�p3t||�j	}|S)N���r�z#!r�)
r�r��splitext�indexr��lower�LEXERSrRrrj)r�rhr��ext�new_line_index�
first_line�
lexer_namer1r1rD�_guess_lexers
�zTraceback._guess_lexerr�c
#s �t�}�j}i�dtdtf�fdd�}dtdttf�fdd�}d}�jdkr8t�jd	t|j	��jd	�}d
}t
|j	�D]�\}}	|rL||vrLd}q?|rd|dusTJ�tdt|��d
�ddd�Vd
}|dk}
|	j�t
�fdd��jD��}tj|t|	jdd��dt|	j�dfd|	jdfdd�}|	j�d�s�|
s�dV|V|	j�d�r�||	�EdHq?|�s
z-||	j�}
��|	j|
�}t|
||d|	j�j|	j�jf|	jh�jd�jd
d�
}dVWnty�}zt�d|��df�VWYd}~q?d}~ww|	j�r
t|g||	��dd �n|Vq?dS)!Nrhr;csV��|�}|dur)t|dddd��}|��}Wd�n1s wY|�|<|S)z�Read files, and cache results on filename.

            Args:
                filename (str): Filename to read

            Returns:
                str: Contents of file
            N�rtzutf-8�replace)�encoding�errors)rR�open�read)rhr��	code_file)�
code_cacher1rD�	read_codes
	�
�z*Traceback._render_stack.<locals>.read_coder�c3s,�|jrt|jd�j�j�jd�VdSdS)Nrm)r�r8r�r�)rmr(r8r�r�)r�)r�r1rD�
render_locals+s���z.Traceback._render_stack.<locals>.render_localsrrNFTz
... z frames hidden ...�centerztraceback.error)�justifyr�rc3s�|]}��|�VqdS)N)r�)r�r�)�frame_filenamer1rD�	<genexpr>Ns�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�r5rqrgrr!r:rSr�r~�	enumeraterrh�anyr9r�rirjr�r�r*r4r6r8rdrmr)r�r�r�r5rr�exclude_frames�excluded�frame_indexr��first�
suppressedr�r�r��syntax�errorr1)rrr�rDr�s��

���


��
���
�������zTraceback._render_stack)!rnrorp�__doc__r��LOCALS_MAX_LENGTH�LOCALS_MAX_STRINGr
r�rsrqr\rrrr��classmethodrrrbrrBr�rr r"r�r#rur�r�rxr�r1r1r1rDrA�s��
��������	�
��
�.��������	�
���
���6��������j��
�NrA�__main__)r�acCsd}t||�dS)Nr)r@)r�oner1r1rD�bar�srcCsd}hd�dd�}t|�dS)NT>�Duncan Idaho�Thufir Hawat�
Paul Atreides�Vladimir Harkonnen)NFT)�
characters�atomic_types)r)rr��zedr1r1rD�foo�s
�	r%cCs>zztd�WWdStYWdStjdd�YdS)NrTr�)r%�slfkjsldkfjr2�print_exceptionr1r1r1rDr�sr)r;N)S�
__future__rr��platformr`�dataclassesrrr?r�typesrr�typingrr	r
rrr
rrr�pip._vendor.pygments.lexersr�pip._vendor.pygments.tokenrrrrrrrr�rrkr�_looprr�columnsrr2rr r!r"r#�	constrainr$r�r%r&�panelr'�scoper(r�r)rr*r�r5r+�system�WINDOWSrrrsrqr\rbrfrgrurxr�r�rArnrr%rr1r1r1rD�<module>s�, ��������	�
�
�l
T


�