�
]�g� � # � � d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZ d dl m
Z
d dlmZm
Z
d dlmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZmZmZmZm 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.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZAmBZB dd lCm"Z" ddlDmEZE ejF dk ZGdZHdZIdeBdeBdeeeJeJeJf fd�ZKddd d!dd"d"eHeId#dd#d$dd%�d&ee/ d'eeJ d(eeJ d)eJd*eeL d+eMd,eMd-eJd.eJd/eMd0eeM d1eMd2eeeLef d3eJdeeeN eNee
gef fd4�ZOe G d5� d6� � � � ZPe G d7� d8� � � � ZQe G d9� d:� � � � ZRe G d;� d<� � � � ZS G d=� d>e8� � ZT G d?� d@� � ZUeVdAk r0 eOd#�B� � d dlZdCeddfdD�ZWdCeddfdE�ZXdGdF�ZY eY� � dS dS )H� N)� dataclass�field)�islice)�walk_tb)�
ModuleType�
TracebackType)
�Any�Callable�Dict�Iterable�List�Optional�Sequence�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) r4 r5 �line1�column1�line2�column2�first�last�line_nos �^/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/rich/traceback.py�_iter_syntax_linesrB 6 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_framesrH rI rJ rK rL rM rN rO rP rQ rR rS rT rU 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� tracebackr6 c � �� t � | ||������� �
�t �� � ��
��� � }�� |� � d S )N�
rI rJ rK rL rM rN rO rP rQ rR rS rT rU )� Traceback�from_exception�bool�print)rX rY rZ �exception_tracebackrJ rK rS rQ rR rO rP rU rN rT rL �traceback_consolerI rM s ��������������rA �
excepthookzinstall.<locals>.excepthook� sv �� �
(�6�6�����!�#���#�/�/�1�#�$6�7�7�'��!�! 7�
�
��$ ��� 3�4�4�4�4�4rC �ipc �� �� ���� i �� j �dt dt dd f��fd�}dd�dt dt dt dd f�� �fd���� _ |� _ �fd �� _ d S )
N�args�kwargsr6 c � �� |� �| i |�� dS )zEwrap the default ip.showtraceback to store info for ip._showtracebackNrG )rf rg �default_showtraceback�tb_datas ��rA �ipy_show_tracebackzCinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_show_traceback� s&