File: D:/Python311/Lib/site-packages/pip/_vendor/rich/__pycache__/traceback.cpython-311.pyc
�
�mi� � # � � d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZ d dl m
Z
d dlmZm
Z
d dlmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZmZmZm Z m!Z!m"Z" d d lm#Z$ d d
lm%Z% d dl&m'Z' dd
l(m)Z) ddl*m+Z+m,Z, ddl-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZBmCZC dd lDm#Z# ddlEmFZF ejG dk ZHdZIdZJdeCdeCdeeeKeKeKf fd�ZLddd d!dd"d"eIeJd#dd#d$dd%�d&ee0 d'eeK d(eeK d)eKd*eeM d+eNd,eNd-eKd.eKd/eNd0eeN d1eNd2eeeMef d3eKdeeeO eOee
gef fd4�ZPe G d5� d6� � � � ZQe G d7� d8� � � � ZRe G d9� d:� � � � ZSe G d;� d<� � � � ZT G d=� d>e9� � ZU G d?� d@� � ZVeWdAk r0 ePd#�B� � d dlZdCeddfdD�ZXdCeddfdE�ZYdGdF�ZZ eZ� � dS dS )H� 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�Group�RenderResult�group)� Constrain)�RegexHighlighter�ReprHighlighter)�Panel)�render_scope)�Style)�Syntax�SyntaxPosition)�Theme�win32�
�P �start�end�returnc # � K � | \ }}|\ }}||k r |||fV � dS t t ||dz � � � � D ]!\ }}}|r||dfV � �|r|d|fV � �|ddfV � �"dS )z�Yield start and end positions per line.
Args:
start: Start position.
end: End position.
Returns:
Iterable of (LINE, COLUMN1, COLUMN2).
r ���r N)r �range) r5 r6 �line1�column1�line2�column2�first�last�line_nos �<D:\Python311\Lib\site-packages\pip/_vendor/rich/traceback.py�_iter_syntax_linesrC 7 s� � � � � �N�E�7��N�E�7���~� %��W�g�%�%�%�%�%�%�$3�E�%����4K�4K�$L�$L� %� %� �E�4���
%��w��*�*�*�*�*��
%��q�'�)�)�)�)�)��q�"�n�$�$�$�$�
%� %� �d �X � FT� )�console�width�
code_width�extra_lines�theme� word_wrap�show_locals�locals_max_length�locals_max_string�locals_hide_dunder�locals_hide_sunder�
indent_guides�suppress�
max_framesrI rJ rK rL rM rN rO rP rQ rR rS rT rU rV c � ��������� �
���
��� | �t d�� � n| ��j r�
�dn�
�
dt t dt dt t
ddf���� �
���
������fd��d t ddf�fd
�} t � � } ||� � t j S # t $ r t j }�t _ |cY S w xY w)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_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.
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� tracebackr7 c � �� t � | ||������� �
�t �� � ��
��� � }�� |� � d S )N�
rJ rK rL rM rN rO rP rQ rR rS rT rU rV )� Traceback�from_exception�bool�print)rY rZ r[ �exception_tracebackrK rL rT rR rS rP rQ rV rO rU rM �traceback_consolerJ rN s ��������������rB �
excepthookzinstall.<locals>.excepthook� sv �� �
(�6�6�����!�#���#�/�/�1�#�$6�7�7�'��!�! 7�
�
��$ ��� 3�4�4�4�4�4rD �ipc �� �� ���� i �� j �dt dt dd f��fd�}dd�dt dt dt dd f�� �fd���� _ |� _ �fd �� _ d S )
N�args�kwargsr7 c � �� |� �| i |�� dS )zEwrap the default ip.showtraceback to store info for ip._showtracebackNrH )rg rh �default_showtraceback�tb_datas ��rB �ipy_show_tracebackzCinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_show_traceback� s&