HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/rich/__pycache__/traceback.cpython-310.pyc
o

;j���'@s4ddlZddlZddlZddlZddlmZmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZmZmZmZmZmZmZmZmZmZddlmZddlmZmZmZm Z m!Z!m"Z"dd	lm#Z$dd
lm%Z%ddl&m'Z'dd
l(m)Z)ddl*m+Z+m,Z,ddl-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6ddl7m8Z8ddl9m:Z:m;Z;ddl<m=Z=ddl>m?Z?ddl@mAZAddlBmCZCmDZDdd	lEm#Z#ddlFmGZGejHdkZIdZJdZKdeDdeDdeeeLeLeLffdd�ZMdd d!d"dd#d#eJeKdd$ddd$d%d d&�d'ee0d(eeLd)eeLd*eLd+eeNd,eOd-eOd.eLd/eLd0eeLd1eOd2eeOd3ee3d4eOd5eeeNefd6eLdeeePePee
geff"d7d8�ZQeGd9d:�d:��ZReGd;d<�d<��ZSeGd=d>�d>��ZTeGd?d@�d@��ZUGdAdB�dBe:�ZVGdCdD�dD�ZWeXdEk�r�eQd$dF�ddlZdGeddfdHdI�ZYdGeddfdJdK�ZZdNdLdM�Z[e[�dSdS)O�N)�	dataclass�field)�islice)�walk_tb)�
ModuleType�
TracebackType)�Any�Callable�Dict�Iterable�List�Optional�Sequence�Set�Tuple�Type�Union)�guess_lexer_for_filename)�Comment�Keyword�Name�Number�Operator�String)�Text)�Token)�
ClassNotFound�)�pretty)�loop_first_last�	loop_last)�Columns)�Console�ConsoleOptions�ConsoleRenderable�OverflowMethod�Group�RenderResult�group)�	Constrain)�RegexHighlighter�ReprHighlighter)�Panel)�render_scope)�Style)�Syntax�SyntaxPosition)�Theme�win32�
�P�start�end�returnc	cs|�|\}}|\}}||kr|||fVdStt||d��D]\}}}|r,||dfVq|r5|d|fVq|ddfVqdS)z�Yield start and end positions per line.

    Args:
        start: Start position.
        end: End position.

    Returns:
        Iterable of (LINE, COLUMN1, COLUMN2).
    r���rN)r�range)	r5r6�line1�column1Zline2�column2�first�last�line_no�r@�B/opt/saltstack/salt/lib/python3.10/site-packages/rich/traceback.py�_iter_syntax_lines8s�
�rB�d�X�FTr@)�console�width�
code_width�extra_lines�theme�	word_wrap�show_locals�locals_max_length�locals_max_string�locals_max_depth�locals_hide_dunder�locals_hide_sunder�locals_overflow�
indent_guides�suppress�
max_framesrFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrUcs�|dur	tdd�n|��jr�durdn��dttdtdttddf���������	�
���
���fdd	��d
tddf�fdd�}zt�}||�tj	WSt
y_tj	}�t_	|YSw)
a�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.
        code_width (Optional[int], optional): Code width (in characters) of traceback. Defaults to 88.
        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.
        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.
        locals_max_depth (int, optional): Maximum depths of locals before truncating, or None to disable. Defaults to None.
        locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
        locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.
        locals_overflow (OverflowMethod, optional): How to handle overflowing locals, or None to disable. Defaults to None.
        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.

    NT)�stderr�type_�value�	tracebackr7csDtj|||f������
����t������	d��}�
�|�dS)N�rGrHrIrJrKrLrMrNrOrPrQrRrSrTrU)�	Traceback�from_exception�bool�print)rWrXrYZexception_traceback)rHrIrSrPrQrOrMrNrRrUrLrTrJ�traceback_consolerGrKr@rA�
excepthook�s,��zinstall.<locals>.excepthook�ipc	sli��j�dtdtddf��fdd�}dd�dtdtdtddf���fd	d
����_|�_�fdd��_dS)
N�args�kwargsr7cs|��|i|��dS)zEwrap the default ip.showtraceback to store info for ip._showtracebackNr@�rbrc)�default_showtraceback�tb_datar@rA�ipy_show_traceback�szCinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_show_tracebackF)�	is_syntaxrhcs~���}|rdn|d}��dd�}��d�}|dur!|rdnd}t|�D]}|dur-n|j}q%�|d|d|�i�dS)z2Internally called traceback from ip._showtracebackN�Zrunning_compiled_codeF�	tb_offsetrr)Z
_get_exc_info�getr9�tb_next)rhrbrcZ	exc_tuple�tbZcompiledrj�_)r`rarfr@rA�ipy_display_traceback�s
zFinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_display_tracebackcs�|ddi|��S)NrhTr@rd)ror@rA�<lambda>�s���z9install.<locals>.ipy_excepthook_closure.<locals>.<lambda>)Z
showtracebackrr]Z_showtracebackZshowsyntaxerror)rarg)r`)rerarorfrA�ipy_excepthook_closure�s �����z'install.<locals>.ipy_excepthook_closure)r"Z
is_jupyterr�
BaseExceptionr
rrZget_ipython�sysr`�	Exception)rFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrUrqra�old_excepthookr@)rHr`rIrSrPrQrOrMrNrRrUrLrTrJr_rGrKrA�installTs4/������,�+�rvc@steZdZUeed<eed<eed<dZeed<dZee	ee
jfed<dZee
e
eefe
eeffed<dS)	�Frame�filename�lineno�name��lineN�locals�last_instruction)�__name__�
__module__�__qualname__�str�__annotations__�intr|r}r
r
rZNoder~rr@r@r@rArw�s
,rwc@sLeZdZUeed<eed<eed<eed<eed<eed�Ze	eed<dS)	�_SyntaxError�offsetrxr|ry�msg��default_factory�notesN)
rr�r�r�r�r�r�listr�rr@r@r@rAr��s
r�c@s�eZdZUeed<eed<dZeeed<dZe	ed<e
ed�Ze
eed<e
ed�Ze
eed	<dZe	ed
<e
ed�Ze
ded<dS)
�Stack�exc_type�	exc_valueN�syntax_errorF�is_causer��framesr��is_group�Trace�
exceptions)rr�r�r�r�r�r
r�r�r]rr�r�rrwr�r�r�r@r@r@rAr��s
r�c@seZdZUeeed<dS)r��stacksN)rr�r�rr�r�r@r@r@rAr��s
r�c@seZdZdgZdS)�PathHighlighterz(?P<dim>.*/)(?P<bold>.+)N)rr�r�Z
highlightsr@r@r@rAr�s
r�c(@seZdZdZdddddd�Z	d;dd	d
dddeedddddd
dd�deedee	dee	de	dee
dedede	de	dee	dededeedede
ee
efde	f dd �Zedd	d
dddeedddddd
dd!�d"eed#ed$eedee	dee	de	dee
dedede	de	dee	deded%eedede
ee
efde	d&df&d'd(��Zedeeddddd)�d"eed#ed$eedede	de	dee	deded*eeed&efd+d,��Zd-ed.ed&efd/d0�Ze�d1ed&efd2d3��Zed4e
d5e
d&e
fd6d7��Z e�d8e!d&efd9d:��Z"dS)<r[aA 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.
        code_width (Optional[int], optional): Number of code characters used to traceback. Defaults to 88.
        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.
        locals_max_depth (int, optional): Maximum depths of locals before truncating, or None to disable. Defaults to None.
        locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
        locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.
        locals_overflow (OverflowMethod, optional): How to handle overflowing locals, or None to disable. Defaults to None.
        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�pythonZcythonZpyrex)r{z.pyz.pxdz.pyxz.pxiNrCrDrEFTr@)rGrHrIrJrKrLrMrNrOrPrQ�locals_overlowrSrTrU�tracerGrHrIrJrKrLrMrNrOrPrQr�rSrTrUcCs.|dur$t��\}}}|dus|dus|durtd��|j||||d�}||_||_||_||_t�	|p5d�|_
||_||_||_
||_|	|_|
|_||_||_|
|_g|_|D]-}t|t�ss|jduskJ|�d���tj�|j�}n|}tj�tj�|��}|j�|�qX|dkr�td|�|_dSd|_dS)Nz9Value for 'trace' required if not called in except: block�rLZ	ansi_darkz+ must be a module with '__file__' attributer�) rs�exc_info�
ValueError�extractr�rGrHrIr/Z	get_themerJrKrLrSrMrNrOrPrQrRrT�
isinstancer��__file__�os�path�dirname�normpath�abspath�append�maxrU)�selfr�rGrHrIrJrKrLrMrNrOrPrQr�rSrTrUr�r�rYZsuppress_entityr�r@r@rA�__init__'sD��
�"zTraceback.__init__rZr�r�rYrRr7cCsH|j||||	|
|||
|d�	}||f||||||	||
|||
||||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.
            code_width (Optional[int], optional): Number of code characters used to traceback. Defaults to 88.
            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_depth (int, optional): Maximum depths of locals before truncating, or None to disable. Defaults to None.
            locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
            locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
            locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.
            locals_overflow (OverflowMethod, optional): How to handle overflowing locals, or None to disable. Defaults to None.
            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.
        )rLrMrNrOrPrQ)rGrHrIrJrKrLrSrMrNrOrPrQr�rTrU)r�)�clsr�r�rYrGrHrIrJrKrLrMrNrOrPrQrRrSrTrUZrich_tracebackr@r@rAr\`s<1���zTraceback.from_exception)rLrMrNrOrPrQ�_visited_exceptionsr�c"
s�g}d}ddlm}
t|dd�pg}|
durt�n|
}dtdtfdd	�}	t||j�||�||d�}tj	dkret
|ttf�red
|_
|jD] }||vrKqD|�|�|j�tjt|�||j|���|d
��qDt
|t�r�t|jpod|jpsd|jpwd|jp{d|j|d�|_|�|�|jj}dtttt fdtttt ff��fdd�}t!|�D]�\}}|j"j#}d}tj	dkr�|j$d}t%t&|j"�'�||d��}|\}}}}|dur�|dur�|dur�|dur�||f||ff}|r�|�(d�s�t)j*�+|�s�t)j*�,|
|�}|j-�.dd��rq�t/|�pd||j"j0|�r���fdd�||j-�1��D�nd|d�}||�|j-�.dd��r6|jdd�=q�|�sot|dd�} | du�rU| |u�rU| j2}| }| j}d
}q$|j3} | du�rot|dd��so| j2}| }| j}d}q$	t4|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.
            locals_max_depth (int, optional): Maximum depths of locals before truncating, or None to disable. Defaults to None.
            locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
            locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.

        Returns:
            Trace: A Trace instance which you can use to construct a `Traceback`.
        Fr)�_IMPORT_CWDZ	__notes__N�_objectr7cSs zt|�WStyYdSw)z1Don't allow exceptions from __str__ to propagate.z<exception str() failed>)r�rt)r�r@r@rA�safe_str�s

�z#Traceback.extract.<locals>.safe_strT)r�r�r�r�)rE�)rLrMrPrQr��?r{)r�rxryr|r�r��iter_localsc3sT��s�s|EdHdS|D]\}}�r|�d�rq�r"|�d�r"q||fVqdS)z-Extract locals from an iterator of key pairs.N�__rn��
startswith)r��keyrX)rPrQr@rA�
get_localss�
�z%Traceback.extract.<locals>.get_localsrir�<Z_rich_traceback_omitc	s8i|]\}}t�|�st�|�s|tj|���d��qS))�
max_length�
max_string�	max_depth)�inspectZ
isfunctionZisclassrZtraverse)�.0r�rX)rOrMrNr@rA�
<dictcomp>Ds����z%Traceback.extract.<locals>.<dictcomp>)rxryrzr}r~�_rich_traceback_guard�	__cause__�__suppress_context__)r�)5Zrichr��getattr�setrr�r�rrs�version_infor�ZBaseExceptionGroupZExceptionGroupr�r��addr�r[r��type�
__traceback__�SyntaxErrorr�r�rxryr�r�r�r�rr�objectr�f_code�co_filename�f_lasti�nextrZco_positionsr�r�r��isabs�join�f_localsrkrw�co_name�items�	__class__�__context__r�)"r�r�r�rYrLrMrNrOrPrQr�r�r�r�r��grouped_exceptionsr��stack�	exceptionr�r�Z
frame_summaryr?rxr~Zinstruction_indexZinstruction_positionZ
start_lineZend_lineZstart_columnZ
end_column�frame�causer�r@)rPrQrOrMrNrAr��s�!��


��

�
	��

���������
zTraceback.extractrF�optionsc#sF��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��t�dtdtdtf������fdd���tt�jj��D]
\}}�||�Vq�dS)Nr�
pygments.text�pygments.string�pygments.function�pygments.numberzrepr.indentT)Zdimzrepr.strz
repr.brace)Zboldzrepr.numberzrepr.bool_truezrepr.bool_falsez	repr.nonezscope.borderzscope.equalsz	scope.keyzscope.key.specialF)Zinheritr�r>r7c	
3s��|jr/t��|�d�dddd�}t|�j�}�����|VWd�n1s*wY|jduro�����tt��|j��ddd�jd��j�VWd�n1sXwYt�	|j
�d�d	f�|jj��Vn|jr�t�	|j
�d�d	f�|j��Vn
t�	|j
�d	f�V|j
D]}t�	d
�|��Vq�|jr�t|jd�D],\}}g}t|j�D]\}}|��||��q�dVttt|�d
|��dd��j�Vq�|s�|jr�t�d�VdSt�d�VdSdS)Nz7[traceback.title]Traceback [dim](most recent call last)ztraceback.borderT)rr)�title�style�border_style�expand�paddingztraceback.border.syntax_error)r�r�r�r�rGz: ztraceback.exc_type)z[NOTE] ztraceback.noterr{zSub-exception #ztraceback.group.border)r�r�zI
[i]The above exception was the direct cause of the following exception:
zH
[i]During handling of the above exception, another exception occurred:
)r�r,�
_render_stackr)rGZ	use_themer��_render_syntax_errorr�assembler�r�r�r�r��	enumerater�r r�r�r&r��from_markup)	r�r>Zstack_renderableZnoteZgroup_noZgroup_exceptionr�Z
group_lastZgroup_stack�Zbackground_stylerF�highlighter�render_stackr�Ztraceback_themer@rAr��s~���

���
��
��	
�
��z0Traceback.__rich_console__.<locals>.render_stack)rJZget_background_styleZget_style_for_tokenr1�	TextTokenrrrZFunctionrrr.rZConstantZ	Delimiterrr+r(r�r]r'r �reversedr�r�)r�rFr�rJZtoken_styler>r�r@r�rA�__rich_console__rs\����
�����	�

�
�
�

�����&C�zTraceback.__rich_console__r�ccs��t�}t�}|jdkr,tj�|j�r,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�rxr�r��existsrr�r�ryr|�rstripZno_wrap�minr��lenZstylizer�)r�r�r��path_highlighterr�Zsyntax_error_textr�r@r@rAr��s*�
�
�
zTraceback._render_syntax_errorrx�codecCs�tj�|�d}|s(|�d�}|dkr|d|�n|}|�d�r(d|��vr(dSz
|j�|�p4t||�j	WSt
y?YdSw)Nr8r�z#!r�r�)r�r��splitext�indexr��lower�LEXERSrkrrzr)r�rxr��extZnew_line_index�
first_liner@r@rA�_guess_lexer�s
�zTraceback._guess_lexerr�c
#s��t�}�j}dtdttf�fdd�}d}�jdkr+t�jdt|j��jd�}d}t	|j�D�]G\}}|r@||vr@d}q2|rX|dusHJ�t
d	t|��d
�ddd
�Vd}|dk}	|j�t�fdd��j
D��}
tj�|j�r�t
j|t
|jdd��dt|j�dfd|jdfdd�}nt
jd|jdfdt|j�dfdd�}|j�d�s�|	s�dV|V|j�d�r�||�EdHq2|
�szz8t�|j�}d�|�}
|
s�Wq2��|j|
�}t|
||d|j�j|j�jf|jh�j�j�jdd�
}dVWnt�y}zt
�d|��df�VWYd}~q2d}~ww|j du�rh|j \}}t!||�D]B\}}}z$|dk�r@||d}t|�t|�"��}|dk�rMt||d�}Wnt#�yYY�q%w|j$d||f||fd��q%|j%�rwt&|g||��dd �n|Vq2dS)!Nr�r7c	3s4�|jrt|jd�j�j�j�j�jd�VdSdS)Nr})r�rSr�r�r�Zoverflow)r}r-rSrMrNrOrR)r�)r�r@rA�
render_localss���z.Traceback._render_stack.<locals>.render_localsrriFTz
... z frames hidden ...�centerztraceback.error)Zjustifyr�c3s�|]}��|�VqdS�Nr�)r�r�)�frame_filenamer@rA�	<genexpr>(s�z*Traceback._render_stack.<locals>.<genexpr>r�r�r�r�z in r�r�zin r�r{)rJZline_numbersZ
line_rangeZhighlight_linesrKrHrS�dedentr�rr8ztraceback.error_range)r�r5r6)r�)'r�rJrwrr$rUr9r�r�r�rrx�anyrTr�r�r�r�r�ryrzr��	linecache�getlinesr�rr/rIrKrHrSrtr~rB�lstrip�
IndexErrorZ
stylize_ranger}r!)r�r�r�rJrZexclude_framesZexcludedZframe_indexr�r=Z
suppressedr�Z
code_linesr�Z
lexer_name�syntax�errorr5r6r:r;r<r|r@)rr�rAr��s��
���	�


��
���


��
�
�������zTraceback._render_stackr)#rr�r��__doc__r��LOCALS_MAX_LENGTH�LOCALS_MAX_STRINGr
r�r�r�r]r%rrrr��classmethodrrrrrr\rr�r"r#r'r�r(r�r�rr�r�r@r@r@rAr[s<�
��������	�
���
�����
�9�������	�
���
���������O�������	�
��
�
�B��
�fr[�__main__r��acCsd}t||�dS)Nr)r^)rZoner@r@rA�bar�srcCsd}hd�dd�}t|�dS)NT>z
Paul AtreideszVladimir HarkonnenzThufir HawatzDuncan Idaho)NFT)Z
charactersZatomic_types)r)rr�Zzedr@r@rA�foo�s
�	rcCstd�dS)Nr)rr@r@r@rAr
�sr
)r7N)\r�rr�rsZdataclassesrr�	itertoolsrrYr�typesrr�typingrr	r
rrr
rrrrrZpygments.lexersrZpygments.tokenrrrrrrrr�rZ
pygments.utilrr{rZ_looprr �columnsr!rFr"r#r$r%r&r'r(Z	constrainr)r�r*r+Zpanelr,Zscoper-r�r.rr/r0r�rJr1�platformZWINDOWSrrr�rBr�r]rrrvrwr�r�r�r�r[rrrr
r@r@r@rA�<module>s�4 $	
��
���������	�
���
�����
�
		

�
�

�