
    Mh=              
          d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
 d dlZd dlmZ d dlmZ d dl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mZ dZdeej                  dede!dee         def
dZ" G d de          Z#dS )    N)Sequence)TracebackType)AnyCallableOptional)Terminal256Formatter)Token)ThemeTokenStreamtheme_table)get_terminal_size   )	FrameInfoTBTools_safe_string_tokens_filenameeqreprget_line_number_of_framenullrepr   linestheme
has_colors
lvals_toksreturnc                    t           dz
  }t          dfg}| D ]^}|t          j        u r%t          j        dfg}|                    |           6|j        }|                    |                              d          dz   }	|j	        rR|t          t          |                    z
  }
t          j        |                    d          ft          dft          |	fg}nt          dft          dft          |	fg}|                    |           |rk|j	        rd|D ]W}|                    t          dt           z  f           |                    |           |                    t          df           X|dd	         }`|S )
z
    Format tracebacks lines with pointing arrow, leading numbers,
    this assumes the stack have been extracted using stackdata.


    Parameters
    ----------
    lines : list[Line]
    r   
z   (...))	pygmented    z...N)INDENT_SIZEr	   
stack_dataLINE_GAPLinenoEmextendlinenorenderrstrip
is_currentlenstrPrompt
make_arrowappend)r   r   r   r   numbers_widthtokens
stack_linetoksr'   linepadlvs               R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/core/doctb.py_format_traceback_linesr8      s     !OM!4=/F  !  !
,,,^Z01DMM$"  : 66==dCCdJ  	#c&kk"2"22Cu//223DD 	D 	d 	!*/ 	!  - -ucK&78999b!!!udm,,,,CRC[FM    c                       e Zd ZU dZdZdZeed<   eed<   eed<   e	ed<   	 	 	 	 	 	 	 	 d%de	dede
dedededeg d
f         d
z  ded
z  f fdZdede	fdZde	de	fdZde
de
de
fdZdedee         dee         dedee         deee	                  fdZdededede
fdZ	 	 	 d&dedee         dee         dee         dedee	         fdZd'd edd
fd!Zd(d"ee
e
e
f         d
z  dd
fd#Zd)de
de
de
dd
fd$Z xZS )*DocTBzx

    A stripped down version of Verbose TB, simplified to not have too much information when
    running doctests

     default	tb_offsetlong_headerinclude_vars_modelinuxFNr   T
theme_namecall_pdbostreamcheck_cachedebugger_clsc	                     t          |t                    sJ t                                          ||||           || _        || _        || _        |t          j        }|| _	        d| _
        dS )aW  Specify traceback offset, headers and color scheme.

        Define how many frames to drop from the tracebacks. Calling it with
        tb_offset=1 allows use of this handler in interpreters which will have
        their own code at the top of the traceback (VerboseTB will first
        remove that frame before printing the traceback info).)rC   rD   rE   rG   NT)
isinstancer,   super__init__r>   r?   r@   	linecache
checkcacherF   skip_hidden)
selfrC   rD   rE   r>   r?   r@   rF   rG   	__class__s
            r7   rK   zDocTB.__init__c   s    $ *c*****!%	 	 	
 	
 	
 #&( #.K&r9   
frame_infor   c           
      :   t          |t                    sJ t          |j        t          j                  rJt
          | j                                     t          dft          j	        d|j
        z  ft          dfg          S dt          z  }t          |j        t                    sJ t          j        |j                  \  }}}}|j        |j                                        }nd}|dk    rd}n| j        rt(          nt*          }		 t          j        |||||		          }
t          |
t.                    sJ t
          | j                                     t          d
ft          j        |ft          j        |
fg          }nW# t4          $ rJ t
          | j                                     t          d
ft          j        |ft          j        dfg          }Y nw xY wg }| j        r	 |j        }|D ]X}|                    t          |j        ft          dft          j        dft          j        t=          |j                  fg           Yn-# t@          $ r  |                    t          dfg           Y nw xY w|j        J t
          | j                                     tC          d|j"        |j                            }||rdndz  }|| dz  }|t
          | j                                     tG          |j$        t
          | j                 | j%        |                    z  }|S )zFormat a single stack frame    z![... skipping similar frames: %s]r   r    N?z<module>r<   )formatvaluezin z"(***failed resolving arguments***)z= z<Exception trying to inspect frame. No more locals available.T)r'   z, )&rI   r   _sdr#   RepeatedFramesr   _theme_nameformatr	   ExcNamedescriptionr"   r'   intinspectgetargvaluesframe	executingcode_qualnamer@   r   r   formatargvaluesr,   VNameValEmKeyErrorvariables_in_executing_piecer/   namereprvalue	Exceptionr   filenamer8   r   r   )rO   rQ   indentargsvarargsvarkwlocals_funccallvar_reprscoper   fibpvarresults                  r7   format_recordzDocTB.format_record   sn   *i00000jnj&?@@ 
	t/077FO;j>TT DM	 	 	 K'*+S11111(/(<Z=M(N(N%gug+'5577DDD:DD "&!2@vvH/'5'x   "%-----"4#34;;U^ek4%85;:NO     " #4#34;;d+&JK #2 )+
 	 ">  C%%"CH-"CL"[$/"[$sy//:	       !! "Z     ~)))T-.55T:#6z?PQQQ
 
 	$&$$B&T++++d./66# D,-	 
 
 	
 s'   A7E? ?AGG A"I 'I-,I-etypec                     t          dt                      d                   }t          | j                                     t
          dft
          dfg          }|S )NK   r   z"Traceback (most recent call last):r    )minr   r   rX   rY   r	   )rO   ry   widthheads       r7   prepare_headerzDocTB.prepare_header   s\    B)++A.//4+,33 8 
 
 r9   evaluec                     	 t          t          ||f          \  }}nC#  t          t          j                    d d         }}t          t          ||f          \  }}Y nxY wt	          |dg           }t          |t                    rt          |t          t          f          rt          |dt                    g}t           j                                     t          j        |ft          dft          |fg          g fd|D             S )N   	__notes__)rq   z: c              3      K   | ]?}t           j                                     t          t	          |d           fg          V  @dS )noteN)r   rX   rY   r	   r   ).0nrO   s     r7   	<genexpr>z)DocTB.format_exception.<locals>.<genexpr>  s_         D,-44ul1f>U>U6V5WXX     r9   )mapr,   sysexc_infogetattrrI   r   bytesr   rh   r   rX   rY   r	   rZ   )rO   ry   r   	etype_str
evalue_strnotess   `     r7   format_exceptionzDocTB.format_exception   s   	>$'eV_$=$=!Izz	>!36E$'eV_$=$=!Izzz R00%** 	Bje.M.M 	B!%4@@@AE ()00-+eT]UJ<OP 
     	
 	
s	    >Aetbcontextc           
         |}	 |j         }n# t          $ r Y nw xY w|| j        n|}t          |t                    sJ |                     t          |                    }|dk    s
J |            |r|                     |||          ng }g }	d}
t          |          dz
  }|		                    | 
                    |d                              |rc|		                    t          | j                                     t          dft          dft          d|z  ft          dft          dfg                     |                     ||          }|g|	z   |z   gS )zFormats the header, traceback and exception message for a single exception.

        This may be called multiple times by Python 3 exception chaining
        (PEP 3134).
        Nr   r   r   rS   z[... %s skipped frames])__name__AttributeErrorr>   rI   r\   r   r,   get_recordsr+   r/   rx   r   rX   rY   r	   r   )rO   ry   r   r   r   r>   
orig_etyper~   recordsframesskippednskippedformatted_exceptions                r7   format_exception_as_a_wholez!DocTB.format_exception_as_a_whole  s    
	NEE 	 	 	D	 '0&7DNNY	)S)))))""3u::..!|||W|||?BJ$""3;;;w<<!#d((44555 	MMD,-44 9H DE 
 
 
 #33E6BB"5566s    
c                    |dk    s
J |            |J |dz
  }|dz  }||z
  }| j         rOt          | j                                                 }t	          j        || j                  }t          |          }nd }t	          j        |||          }	|}
d}g }|
	 t          j
        |
j                  }|,|j        }|                    d          ^}}|dk    r|
j        }
Jt          |
j                  }n# t           $ r d}Y nw xY wt#          ||          }|                    |
           t'          |
dd           }
|
t)          t          j                            ||		                    |d          }d
 |D             }|S )Nr   r   )style)beforeafterpygments_formatterr   .IPythontb_next)optionsc                 6    g | ]}t          j        |          S  )r   _from_stack_data_FrameInfo)r   rs     r7   
<listcomp>z%DocTB.get_records.<locals>.<listcomp>l  s#    EEEA	4Q77EEEr9   )r   r   rX   as_pygments_styler#   style_with_executing_nodetb_highlightr   Optionsr]   	getmoduletb_framer   splitr   r   OSErrormaxr/   r   listr   )rO   r   r   r>   r   r   
base_styler   	formatterr   cfmax_lentbsmodmod_name	root_name_resres2s                      r7   r   zDocTB.get_recordsD  s   !|||W|||A+15? 	$T%56HHJJJ8TEVWWE,5999III$(
 
 
 '*n'44?"|H$,NN3$7$7MI I--Z 22;??   '7++GJJrNNNY--B n" :'2232HHII)**UEEEEEs   AC8 #C8 8DDr   c                    |dk    sJ |dk    s
J |            |                      |||||          }t          dt                      d                   }t          | j                 }g }	d}
d}|                     |          }|r(|J ||                     |j                  z  }|\  }}}nd}t                      }|r||                      |||||
          z  }|                     |          }|rct          |d                   |vrL|
                    t          |d                              ||                     |j                  z  }|\  }}}nd}|t          |          D ]}|	|z  }	|	S )z5Return a nice text document describing the traceback.r   r   r{   r   N)r   r|   r   r   rX   get_parts_of_chained_exception!prepare_chained_exception_message	__cause__setidaddreversed)rO   ry   r   r   r>   r   formatted_exceptionstermsizer   structured_traceback_partschained_exceptions_tb_offsetlines_of_context	exceptionchained_exc_idsfxs                  r7   structured_tracebackzDocTB.structured_tracebacko  s    {{{{!|||W|||040P0P631
 1
 r,..q122D,-02"'($77??	 	%%% D$J$J % %   "+E633F%% 	 D$D$Dvs$46R% %   ;;FCCI 	R	!--_DD##y|$$   %(N(N$) ) $ &/"vss  	& /00 	- 	-B&",&&))r9   forcec                      t          d          )Nzcanot rundebugger in Docs mode)RuntimeError)rO   r   s     r7   debuggerzDocTB.debugger  s    ;<<<r9   infoc                 "   |pt          j                    \  }}}|| _        | j        }|                                 |                    |                     |||                     |                    d           |                                 d S )Nr   )r   r   tbrE   flushwritetext)rO   r   ry   r   r   rE   s         r7   handlerzDocTB.handler  sy    #5s|~~,diivs33444dr9   c                     ||                                   n|                      |||f           	 |                                  dS # t          $ r t          d           Y dS w xY w)z@This hook can replace sys.excepthook (for Python 2.1 or higher).Nz
KeyboardInterrupt)r   r   KeyboardInterruptprint)rO   ry   r   r   s       r7   __call__zDocTB.__call__  sx    ;LLNNNNLL%-...	)MMOOOOO  	) 	) 	)'((((((	)s   A A$#A$)rB   FNr   FTNN)NNr   )F)N)NNN)r   
__module____qualname____doc__r   tb_highlight_styler\   __annotations__boolr,   r   r   typerK   r   rx   r   r   r   BaseExceptionr   r   r   r   r   r   tupler   r   __classcell__)rP   s   @r7   r;   r;   S   s          L"NNNJJJ
 "!!15$(#  #  #  	# 
 #  #  #  #  b$h'$.#  Tk#  #  #  #  #  # Je	 ec e e e eNC C    
c 
3 
3 
 
 
 
2,7,7 ',7 m$	,7
 ,7 C=,7 
d3i,7 ,7 ,7 ,7\)} )s )s )s ) ) ) )^ (,#'4* 4*4* '4* m$	4*
 C=4* 4* 
c4* 4* 4* 4*l= =d =t = = = = E#sC-047 4    	) 	)c 	)# 	)3 	)RV 	) 	) 	) 	) 	) 	) 	) 	)r9   r;   )$r]   rL   r   collections.abcr   typesr   typingr   r   r   r#   pygments.formatters.terminal256r   pygments.tokenr	   IPython.utils.PyColorizer
   r   r   IPython.utils.terminalr   tbtoolsr   r   r   r   r   r   r   r"   r   Liner   r8   r;   r   r9   r7   <module>r      s        



 $ $ $ $ $ $       * * * * * * * * * *     @ @ @ @ @ @             D D D D D D D D D D 4 4 4 4 4 4                  4
 44 4 [!	4
 4 4 4 4ni) i) i) i) i)G i) i) i) i) i)r9   