
    Pi              '       >   d dl 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
 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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) ddl*m+Z+m,Z, ddl-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 ddl7m8Z8 ddl9m:Z:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZCmDZD dd	lEm#Z# ddlFmGZG ejH        dk    ZIdZJdZKdeDdeDdeeeLeLeLf                  fdZMddd d!dd"d"eJeKdd#ddd#d$dd%d&ee0         d'eeL         d(eeL         d)eLd*eeN         d+eOd,eOd-eLd.eLd/eeL         d0eOd1eeO         d2ee3         d3eOd4eeeNef                  d5eLdeeeP         ePee         gef         f"d6ZQe G d7 d8                      ZRe G d9 d:                      ZSe G d; d<                      ZTe G d= d>                      ZU G d? d@e:          ZV G dA dB          ZWeXdCk    r0 eQd#D           d dlZdEeddfdFZYdEeddfdGZZdIdHZ[ e[             dS dS )J    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              #      K   | \  }}|\  }}||k    r	|||fV  dS t          t          ||dz                       D ]!\  }}}|r||dfV  |r|d|fV  |ddfV  "dS )zYield start and end positions per line.

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

    Returns:
        Iterable of (LINE, COLUMN1, COLUMN2).
    r   r   N)r    range)	r6   r7   line1column1line2column2firstlastline_nos	            b/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/rich/traceback.py_iter_syntax_linesrD   8   s       NE7NE7~~Wg%%%%%%$3E%4K4K$L$L 	% 	% E4 %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_max_depthlocals_hide_dunderlocals_hide_sunderlocals_overflowindent_guidessuppress
max_framesrJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   c                   	
 | t          d          n| j        rdndt          t                   dt          dt          t
                   ddf
	fdd	t          ddffd
}	 t                      } ||           t          j	        S # t          $ r t          j	        }t          _	        |cY S w xY 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_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	tracebackr8   c                     t                               | ||
	t                              }                    |           d S )NrK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   )	Tracebackfrom_exceptionboolprint)r\   r]   r^   exception_tracebackrL   rM   rW   rT   rU   rS   rQ   rR   rV   rY   rP   rX   rN   traceback_consolerK   rO   s       rC   
excepthookzinstall.<locals>.excepthook   s|    
 (66!##//-1#$677+'!% 7 
 
( 	 344444rE   ipc           	           i  j         dt          dt          dd ffd}dddt          dt          dt          dd f fd _        | _         fd	 _        d S )
Nargskwargsr8   c                      | | i | dS )zEwrap the default ip.showtraceback to store info for ip._showtracebackNrI   )rj   rk   default_showtracebacktb_datas     rC   ipy_show_tracebackzCinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_show_traceback   s&     G!!42622222rE   F)	is_syntaxrp   c                    	                                 }| rdn|d         }
                    dd          }
                    d          }||rdnd}t          |          D ]}| n|j        } |d         |d         |           i 
dS )z2Internally called traceback from ip._showtracebackN   running_compiled_codeF	tb_offsetr   r   )_get_exc_infogetr;   tb_next)rp   rj   rk   	exc_tupletbcompiledrt   _rg   rh   rn   s           rC   ipy_display_tracebackzFinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_display_traceback   s    
 ((**I 3<*M$$1B {{#:EBBHK00I !)0AAq	9%%    :EZJy|Yq\2666GGGrE   c                       | ddi|S )Nrp   TrI   )rj   rk   r|   s     rC   <lambda>z9install.<locals>.ipy_excepthook_closure.<locals>.<lambda>   s(    5J5J6
!6
%+6
 6
 rE   )showtracebackr	   rc   _showtracebackshowsyntaxerror)rh   ro   rm   r|   rn   rg   s   ` @@@rC   ipy_excepthook_closurez'install.<locals>.ipy_excepthook_closure   s     " 0	3c 	3S 	3T 	3 	3 	3 	3 	3 	3 	3 +0	 	 		#'	;>		 	 	 	 	 	 	 	4 2-
 
 
 
rE   )r#   
is_jupyterr   BaseExceptionr   r   r	   get_ipythonsysrg   	Exception)rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   r   rh   old_excepthookrg   rf   s    ```````````````   @@rC   installr   T   sr   ^ 18t,,,,W (	 -?-G 	 5M"55 M*5 
	5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 56)
3 )
4 )
 )
 )
 )
 )
 )
V	]]r"""~   #	s   $B* *$CCc                       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Zeeeeef         eeef         f                  ed<   dS )	Framefilenamelinenoname lineNlocalslast_instruction)__name__
__module____qualname__str__annotations__intr   r   r   r   r   Noder   r   rI   rE   rC   r   r      s         MMMKKK
IIID#NNN/3FHT#v{*+,333JNhuU38_eCHo%EFGNNNNNrE   r   c                   p    e Zd ZU eed<   eed<   eed<   eed<   eed<    ee          Ze	e         ed<   dS )	_SyntaxErroroffsetr   r   r   msgdefault_factorynotesN)
r   r   r   r   r   r   r   listr   r   rI   rE   rC   r   r      s`         KKKMMM
IIIKKK	HHHuT222E4922222rE   r   c                       e Zd ZU eed<   eed<   dZee         ed<   dZe	ed<    e
e          Zee         ed<    e
e          Zee         ed	<   dZe	ed
<    e
e          Zed         ed<   dS )Stackexc_type	exc_valueNsyntax_errorFis_causer   framesr   is_groupTrace
exceptions)r   r   r   r   r   r   r   r   r   rc   r   r   r   r   r   r   r   r   rI   rE   rC   r   r      s         MMMNNN+/L(<(///Hd%555FDK555uT222E49222Hd %d ; ; ;JW;;;;;rE   r   c                   &    e Zd ZU ee         ed<   dS )r   stacksN)r   r   r   r   r   r   rI   rE   rC   r   r      s"         KrE   r   c                       e Zd ZdgZdS )PathHighlighterz(?P<dim>.*/)(?P<bold>.+)N)r   r   r   
highlightsrI   rE   rC   r   r     s        -.JJJrE   r   c            (          e Zd ZdZddddddZ	 d4dd	d
dddeedddddddddee         dee	         dee	         de	dee
         dedede	de	dee	         dededee         dedeee
ef                  de	f dZedd	d
dddeedddddddd d!ee         d"ed#ee         dee	         dee	         de	dee
         dedede	de	dee	         deded$ee         dedeee
ef                  de	d%d f&d&            Zedeeddddd'd!ee         d"ed#ee         dede	de	dee	         deded(eee                  d%efd)            Zd*ed+ed%efd,Z e            d-ed%efd.            Zed/e
d0e
d%e
fd1            Z  e            d2e!d%efd3            Z"dS )5ra   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.
        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pythoncythonpyrex)r   z.pyz.pxdz.pyxz.pxiNrF   rG   rH   FTrI   )rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   locals_overlowrW   rX   rY   tracerK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   r   rW   rX   rY   c                   |Et          j                    \  }}}|||t          d          |                     ||||          }|| _        || _        || _        || _        t          j	        |pd          | _
        || _        || _        || _        || _        |	| _        |
| _        || _        || _        || _        g | _        |D ]}t+          |t,                    s9|j        J |d            t0          j                            |j                  }n|}t0          j                            t0          j                            |                    }| j                            |           |dk    rt=          d|          nd| _        d S )Nz9Value for 'trace' required if not called in except: blockrP   	ansi_darkz+ must be a module with '__file__' attributer      ) r   exc_info
ValueErrorextractr   rK   rL   rM   r0   	get_themerN   rO   rP   rW   rQ   rR   rS   rT   rU   rV   rX   
isinstancer   __file__ospathdirnamenormpathabspathappendmaxrY   )selfr   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   r   rW   rX   rY   r   r   r^   suppress_entityr   s                         rC   __init__zTraceback.__init__'  s   ( =-0\^^*Hi9#4	8I O   LL)YK !  E 

$&%e&:{;;
"&*!2!2 0"4"4-')' 		' 		'Oos33 '#,88%TTT 988w'?@@&7##BGOOD$9$9::DM  &&&&0:Q#a,,,ArE   r`   r   r   r^   rV   r8   c                l    |                      ||||	|
||||	  	        } | |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.
        )rP   rQ   rR   rS   rT   rU   )rK   rL   rM   rN   rO   rP   rW   rQ   rR   rS   rT   rU   r   rX   rY   )r   )clsr   r   r^   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rich_tracebacks                       rC   rb   zTraceback.from_exception`  s    b #//-11 % 

 

 s
!##'//-11*!!
 
 
 	
rE   )rP   rQ   rR   rS   rT   rU   _visited_exceptionsr   c                  	 g }d}ddl m} t          |dd          pg }|
t                      n|
}dt          dt
          fd}	 t           ||j                   ||          ||
          }t          j	        dk    rt          |t          t          f          rwd	|_        |j        D ]h}||v r|                    |           |j                            t"                              t'          |          ||j        |	|                     it          |t*                    r;t-          |j        pd|j        pd|j        pd|j        pd|j        |          |_        |                    |           |j        j        }dt<          t>          t
          t@          f                  dt<          t>          t
          t@          f                  f	fd}tC          |          D ]q\  }}|j"        j#        }d}t          j	        dk    rY|j$        dz  }tK          tM          |j"        '                                ||dz                       }|\  }}}}|||
|||f||ff}|rT|(                    d          s?tR          j*        +                    |          s tR          j*        ,                    ||          }|j-        .                    dd          rt_          |pd||j"        j0        |r0fd ||j-        1                                          D             nd|          } ||           |j-        .                    dd          r
|j        dd= s|sYt          |dd          } | | |ur| j2        }| }| j        }d	}=|j3        } | %t          |dd          s| j2        }| }| j        }d}k	 ti          |          }!|!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_CWD	__notes__N_objectr8   c                 D    	 t          |           S # t          $ r Y dS w xY w)z1Don't allow exceptions from __str__ to propagate.z<exception str() failed>)r   r   )r   s    rC   safe_strz#Traceback.extract.<locals>.safe_str  s7    27||# 2 2 21112s    
T)r   r   r   r   )rH      )rP   rQ   rT   rU   r   ?r   )r   r   r   r   r   r   iter_localsc              3      K   ss
| E d{V  dS | D ];\  }}r|                     d          rr|                     d          r5||fV  <dS )z-Extract locals from an iterator of key pairs.N__r{   
startswith)r   keyr]   rT   rU   s      rC   
get_localsz%Traceback.extract.<locals>.get_locals  s       + .@ ********F"- % %JC) !cnnT.B.B ! ) !cnnS.A.A ! u*$$$$% %rE   rr   r   <_rich_traceback_omitc           	          i | ]F\  }}t          j        |          t          j        |          -|t          j        |           GS ))
max_length
max_string	max_depth)inspect
isfunctionisclassr   traverse).0r   r]   rS   rQ   rR   s      rC   
<dictcomp>z%Traceback.extract.<locals>.<dictcomp>D  sv     	 	 	 !+U$+$6u$=$=	 BIQVAWAW	 %+<+<*:	" " "	 	 	rE   )r   r   r   r   r   _rich_traceback_guard	__cause____suppress_context__)r   )5richr   getattrsetr	   r   r   r   r   version_infor   BaseExceptionGroupExceptionGroupr   r   addr   ra   r   type__traceback__SyntaxErrorr   r   r   r   r   r   r   r   r   r   objectr   f_codeco_filenamef_lastinextr   co_positionsr   r   r   isabsjoinf_localsrv   r   co_nameitems	__class____context__r   )"r   r   r   r^   rP   rQ   rR   rS   rT   rU   r   r   r   r   r   grouped_exceptionsr   stack	exceptionr   r   frame_summaryrB   r   r   instruction_indexinstruction_position
start_lineend_linestart_column
end_columnframecauser   s"        `````                        rC   r   zTraceback.extract  s   B !$$$$$$"9k4@@FB )0CEEE6I 		2c 	2c 	2 	2 	2 	2I	!("344"(9--!	  E 7**i*<n)MNN %)EN%.%9  	$(:::$*..y999(//%-- $Y ) ) 7,72C3E3E4F . 	 	    )[11 %1$+0q&/63$+0q"-2!& & &" MM%   \(F%%eCK&89%%V,-% % % % % % % +2)*<*< ;( ;(&w(/; $( #w..(5(=(B%+/)0==??--1 , ,( -" $" #.$0(4&2 (6%z2,(
  GH$7$7$<$< G7==22 G#%7<<X#F#F )--.DeLL %_"&-5 '" 	 	 	 	 	 	 /9j9O9U9U9W9W.X.X	 	 	 	 "%5%  ( u )--.EuMM (QQQ% 	;==$i)?)?$H %I !& 3I#H!-$W5u. .$  %H %I % 3I$HV$$$rE   rJ   optionsc              #   6   	
K    j         }|                                |j        }t          i d |t                    d |t
                    d |t                    d |t          j                  d |t                    d |t                    t          d          z   d	 |t                    d
 |t                    t          d          z   d |t                    d |t          j                  d |t          j                  d |t          j                  d |t          j                  d |t                    d |t                    d |t          j                  t          d          z   d          
t!                      t#                      dt$          dt&          dt(          f	 
fd            	t+          t-           j        j                            D ]\  }} 	||          V  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)inheritr  rA   r8   c              3     K   | j         rnt                              |           d	ddd          }t          |j                  }
                              5  |V  d d d            n# 1 swxY w Y   | j        
                              5  t          t                              | j                  	dddj                  j                  V  d d d            n# 1 swxY w Y   t          j	        | j
         dd	f | j        j                            V  nU| j        r0t          j	        | j
         dd	f | j                            V  nt          j	        | j
         d	f          V  | j        D ]"}t          j	        d
 |                    V  #| j        rt          | j        d          D ]u\  }}g }t#          |j                  D ]$\  }}|                     ||                     %dV  t          t          t)          | d| d          j                  V  v|s7| j        rt          j        d          V  d S t          j        d          V  d S d S )Nz7[traceback.title]Traceback [dim](most recent call last)ztraceback.borderT)r   r   )titlestyleborder_styleexpandpaddingztraceback.border.syntax_error)r  r  r  r  rK   z: ztraceback.exc_type)z[NOTE] ztraceback.noter   r   zSub-exception #ztraceback.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*   rK   	use_themer   _render_syntax_errorr   assembler   r   r   r   r   	enumerater   r!   r   r   r'   r   from_markup)r  rA   stack_renderablenotegroup_nogroup_exceptionr  
group_lastgroup_stackbackground_stylerJ   highlighterrender_stackr   traceback_themes            rC   r.  z0Traceback.__rich_console__.<locals>.render_stack  s     | +6;&&u--S*!3"7 7 7  $--=tz#J#J &&77 + +****+ + + + + + + + + + + + + + + !-&&77  # 55e6HII"2)H#'$*"&*   

 
 
 
 
               m***,@AK 2 677       Qm***,@AK00     
 m%8:N$OPPPPP V Vm$A;;tCTCTUUUUUU~ 1:5;KQ1O1O  -Ho68&3<_=S3T3T Y Y/
K*11,,{J2W2WXXXXHHH#!#56">H">">)A  
 
       > *e       *d       s%   A..A25A2AC))C-0C-)rN   get_background_styleget_style_for_tokenr2   	TextTokenr   r   r   Functionr   r   r/   r   Constant	Delimiterr   r,   r)   r   rc   r(   r!   reversedr   r   )r   rJ   r  rN   token_stylerA   r  r,  r-  r.  r/  s   ``     @@@@rC   __rich_console__zTraceback.__rich_console__r  s      
 5577/++i00U!3!3 ";;v#6#6 $[[%?%?	
 ";;v#6#6 {{733eoooE KK// kk)44u$7G7G7GG {{622 !++g.>"?"? ";;w/?#@#@ [[)9:: F,< = = H 5 5 [[..  $[[%?%?%D///%Q!$ '
 
 
, &''	A	 A	T A	l A	 A	 A	 A	 A	 A	 A	 A	 A	 A	 
A	F %Xdj.?%@%@AA 	, 	,KD%,ud++++++	, 	,rE   r   c              #   <  K   t                      }t                      }|j        dk    rgt          j                            |j                  rCt          j        d|j         dfdt          |j	                  dfd          } ||          V   ||j
                                                  }d|_        t          |j        d	z
  t          |                    }|                    d
||           |t          j        dd|z  z   dz   d          z  }|V  d S )Nz<stdin> r  :r  r  r  r  Tr   zbold underline
u   [traceback.offset]▲[/])r,   r   r   r   r   existsr   r#  r   r   r   rstripno_wrapminr   lenstylizer%  )r   r   r-  path_highlighterr   syntax_error_textr   s          rC   r"  zTraceback._render_syntax_error  sJ     %''*,, I--w~~l344 -}0.002CD*,--/@A)	   '&t,,,,,'K(9(@(@(B(BCC$(!\(1,c2C.D.DEE!!"2FFCCCT-3<"<<!
 
 
 	
  rE   r   codec                 z   t           j                            |          d         }|sT|                    d          }|dk    r
|d |         n|}|                    d          rd|                                v rdS 	 | j                            |          pt          ||          j	        S # t          $ r Y dS w xY w)Nr:   r>  z#!r   r   )r   r   splitextindexr   lowerLEXERSrv   r   r   r   )r   r   rG  extnew_line_index
first_lines         rC   _guess_lexerzTraceback._guess_lexer  s    gx((, 	  "ZZ--N2@B2F2Fo~o..DJ$$T**  x:;K;K;M;M/M/Mx	:>>#&&W*B8T*R*R*WW 	 	 	66	s   =.B, ,
B:9B:r  c              #   X   K   t                      } j        }dt          dt          t                   f fd}d } j        dk    r5t           j        dz  t          |j                   j        dz  z
            }d}t          |j                  D ]\  }}|r||v rd}|r+|J t          dt          |           d	d
d          V  d}|dk    }	|j        t          fd j        D                       }
t          j                            |j                  rSt          j         |t          |j        d                    dt%          |j                  dfd|j        dfd          }n4t          j        d|j        dfdt%          |j                  dfd          }|j                            d          s|	sdV  |V  |j                            d          r ||          E d {V  e|
s	 t-          j        |j                  }d                    |          }|s                     |j        |          }t5          |||d|j         j        z
  |j         j        z   f|j        h j         j         j        d
  
        }dV  |j        |j        \  }}tA          ||          D ]\  }}}	 |dk    r<||dz
           }t          |          t          |!                                          z
  }|dk    rt          ||dz
                     }n# tD          $ r Y tw xY w|#                    d||f||f           |j$        rtK          |g ||          d          n|V  # tL          $ r&}t          j        d| df          V  Y d }~d }~ww xY wd S )Nr  r8   c           	   3      K   | j         r8t          | j         dj        j        j        j        j                  V  d S d S )Nr   )r  rW   r   r   r   overflow)r   r.   rW   rQ   rR   rS   rV   )r  r   s    rC   render_localsz.Traceback._render_stack.<locals>.render_locals  sl      | 	"L""&"4#5#5"3!1       	 	rE   r   rr   FTz
... z frames hidden ...centerztraceback.error)justifyr  c              3   B   K   | ]}                     |          V  d S Nr   )r   r   frame_filenames     rC   	<genexpr>z*Traceback._render_stack.<locals>.<genexpr>(  s1      WW^66t<<WWWWWWrE   r  r=  r;  r  z in r  r  zin r   r   )rN   line_numbers
line_rangehighlight_linesrO   rL   rW   dedentr   r:   ztraceback.error_range)r  r6   r7   )r  r>  )'r   rN   r   r   r%   rY   r;   rC  r   r$  r   r   anyrX   r   r   r?  r#  r   r   r   r   	linecachegetlinesr   rP  r0   rM   rO   rL   rW   r   rD   lstrip
IndexErrorstylize_ranger   r"   r   )r   r  rE  rN   rT  exclude_framesexcludedframe_indexr  r@   
suppressedr   
code_linesrG  
lexer_namesyntaxr6   r7   r<   r=   r?   r   errorrY  s   `                      @rC   r   zTraceback._render_stack  s     *,,

	 
	84E+F 
	 
	 
	 
	 
	 
	 +/?a"1$EL!!DOq$88 N
 "+EL"9"9 g	 g	K +"?"? !%111DS00DDD$+     
 !1$E"^NWWWWWWWWWJw~~en-- }$$T%.@Q%R%R%RSS*&&(9:Z!45)   }Z!45*&&(9:)   >,,S11 % JJJ~((-- (=///////// >=!*!3EN!C!CJ77:..D ! !!%!2!25>4!H!HJ#"#%)!L4+;;!L4+;;$ */"&.#'?&*&8$  F HHH -9%*%;
s 8J%QT7U7U  3E7G	)#*a<<+5eai+@D.1$ii#dkkmm:L:L.LG#*b==.1*UQY2G.H.HG#- ) ) ) !))
 #00&=',g&6%*G$4 1     !<$ &!.u!5!5 %&    $
 
 
 
7 !   -%e'89         3>Sg	 g	s2   :0M5,A)M5=A L
L+*L+5
N%?N  N%rX  )#r   r   r   __doc__rL  LOCALS_MAX_LENGTHLOCALS_MAX_STRINGr   r   r   r   rc   r&   r   r   r   r   classmethodr   r	   r   r   rb   r   r   r#   r$   r(   r8  r)   r   r"  rP  r   r   rI   rE   rC   ra   ra     sz        2  F "&7F  #$&#!!2!2*.#'#(37"57%7F 7F 7F7F }	7F
 SM7F 7F }7F 7F 7F 7F 7F #3-7F !7F !7F !07F  !7F" 5j12#7F$ %7F 7F 7F 7Fr   #$&#!!2!2*.#'#(48"57)M
 M
 M
s)M
 !M
 M*	M
 }M
 SMM
 M
 }M
 M
 M
 M
 M
 #3-M
 !M
  !!M
" ".1#M
$ %M
& 5j12'M
( )M
* 
+M
 M
 M
 [M
^  "!2!2*.#'#(<@  }% ! M*	    #3- ! ! &c-&89 
   [Bd,d,)7d,	d, d, d, d,L UWW   ,       W , C s s    [ UWW5 \    W  rE   ra   __main__r   ac                 .    d}t          || z             d S )Nr   )rd   )rr  ones     rC   barru    s     cAgrE   c                 6    d}h ddd}t          |            d S )NT>   Duncan IdahoThufir HawatPaul AtreidesVladimir Harkonnen)NFT)
charactersatomic_types)ru  )rr  r   zeds      rC   foor~    s9     $   0
 
 	ArE   c                  $    t          d           d S )Nr   )r~  rI   rE   rC   rl  rl    s    ArE   )r8   N)\r   r`  r   r   dataclassesr   r   	itertoolsr   r^   r   typesr   r   typingr	   r
   r   r   r   r   r   r   r   r   r   pygments.lexersr   pygments.tokenr   r   r   r   r   r   r   r2  r   pygments.utilr   r   r   _loopr    r!   columnsr"   rJ   r#   r$   r%   r&   r'   r(   r)   	constrainr*   r-  r+   r,   panelr-   scoper.   r  r/   rk  r0   r1   r   rN   r2   platformWINDOWSrn  ro  r   rD   r   rc   r   r   r   r   r   r   r   ra   r   ru  r~  rl  rI   rE   rC   <module>r     s+        				 



 ( ( ( ( ( ( ( (             + + + + + + + +                          5 4 4 4 4 4 K K K K K K K K K K K K K K K K , , , , , ,             ' ' ' ' ' '       - - - - - - - -                        !           : : : : : : : :                   * * * * * * * *            
,'
!  %% .%eCcM"#% % % %< "& "..&*#)-0413#F F FgF C=F 	F
 F C=F F F F F smF F !F n-F F  uS*_-.!F" #F$ tM"M8M3JKSPQ%F F F FR O O O O O O O O 3 3 3 3 3 3 3 3 < < < < < < < <        / / / / /& / / /y	 y	 y	 y	 y	 y	 y	 y	x zGJJJ	   s t        
EGGGGG5 rE   