
    hD                         S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SK	J
r
Jr  S SKJrJrJr  S SKJrJrJrJrJrJr  S SKJr  \R2                  " \5      r " S S	5      rg)
    N)Counter)escape)	FrameTypeTracebackType)UnionIterableList)style_with_executing_nodeOptionsLine	FrameInfoVariableRepeatedFrames)some_strc                   <   \ rS rSrSSSSSSSSSSSSSS.S jrSS	\\   4S
 jjrS\S	\4S jr	SS	\\   4S jjr
S\\\\4      S	\\   4S jrS\S	\4S jrS\\\\4   S	\4S jrS rS\S	\4S jrS\S	\\   4S jrS\S	\4S jrS rS	\4S jrS\S	\4S jrSrg) 
Serializer   NFTmonokaiz
bg:#005080)options	pygmentedshow_executing_nodepygments_formatter_clspygments_formatter_kwargspygments_styleexecuting_node_modifieruse_code_qualnamestrip_leading_indenthtmlchaincollapse_repeated_framesshow_variablesc                0   Uc
  [        5       nU(       aR  UR                  (       dA  U(       a  [        Xg5      nUc  U
(       a  SSKJn  OSSKJn  U" SSU0U=(       d    0 D6Ul        X l        Xl        Xl	        Xl
        Xl        Xl        Xl        Xl        g )Nr   )HtmlFormatter)Terminal256Formatterstyle )r   pygments_formatterr
   pygments.formatters.htmlr#   pygments.formatters.terminal256r$   r   r   r   r   r   r   r    r!   )selfr   r   r   r   r   r   r   r   r   r   r   r    r!   s                 iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\stack_data/serializing.py__init__Serializer.__init__   s    " ?iGW77"!:"" &- *@ *$*+1r*G&
 #!2$8!	
(@%,    returnc                    Uc  [         R                  " 5       S   n/ nU R                  (       a  UR                  b@  U R	                  UR                  5      n[
        R                  R                  5       US   S'   O]UR                  bP  UR                  (       d?  U R	                  UR                  5      n[
        R                  R                  5       US   S'   UR                  U R                  U5      5        U$ )N   tail)sysexc_infor   	__cause__format_exception	traceback_cause_messagestrip__context____suppress_context___context_messageappendformat_traceback_part)r*   eresults      r+   r7   Serializer.format_exceptionJ   s    9q!A::{{&..q{{;%.%=%=%C%C%Er
6"*13I3I..q}}=%.%?%?%E%E%Gr
6"d0034r.   r@   c           	          [        U R                  UR                  =(       d    [        R                  " 5       S   5      [        [        U5      R                  [        U5      S9SS9$ )N   )typemessage )frames	exceptionr3   )dictformat_stack__traceback__r4   r5   rE   __name__r   )r*   r@   s     r+   r?    Serializer.format_traceback_part[   sR    $$Q__%Iq8IJ!W%%  
 	
r.   c           
          Uc  [         R                  " 5       R                  n[        U R	                  [
        R                  " UU R                  U R                  S95      5      $ )N)r    )	inspectcurrentframef_backlistformat_stack_datar   
stack_datar   r    )r*   frame_or_tbs     r+   rK   Serializer.format_stacke   sX    !..077K""$$LL-1-J-J
 	
r.   stackc              #      #    U Hn  n[        U[        5      (       a8  U R                  U5      (       d  M0  [        SSS0U R	                  U5      D6v   MP  [        SSS0U R                  U5      D6v   Mp     g 7f)NrE   framerepeated_framesr&   )
isinstancer   should_include_framerJ   format_frameformat_repeated_frames)r*   rX   items      r+   rT   Serializer.format_stack_datas   sp      D$	**0066CC4+<+<T+BCCW 1WT5P5PQU5VWW s   A6A8r[   c                     [        [        UR                  5      R                  5       S S9n[	        U VVVs/ s H  u  u  p4n[	        UR
                  UUS9PM     snnnS9$ s  snnnf )Nc                 2    U S   * U S   S   R                   4$ )Nr1   r   )co_name)r`   s    r+   <lambda>3Serializer.format_repeated_frames.<locals>.<lambda>   s    tAwhQ
(:(:;r.   key)namelinenocount)rH   )sortedr   
frame_keysitemsrJ   rd   )r*   r[   countscoderj   rk   s         r+   r_   !Serializer.format_repeated_frames~   st    O../557;
  .4 .4)NTE !
 .4	
 		
s   $A#rZ   c           
         [        U[        5      (       d  [        XR                  5      n[        U R                  (       a  UR
                  R                  5       OUR                  R                  UR                  UR                  [        U R                  UR                  5      5      S9nU R                  (       a  [        U R                  U5      5      US'   U$ )N)ri   filenamerj   lines	variables)r\   r   r   rJ   r   	executingcode_qualnamerp   rd   rs   rj   rS   format_linesrt   r!   format_variables)r*   rZ   rA   s      r+   r^   Serializer.format_frame   s    %++e\\2E )) --/ZZ''^^<<t((56	
 "&t'<'<U'C"DF;r.   c              #      #    U HC  n[        U[        5      (       a   [        SSS0U R                  U5      D6v   M8  [        SS9v   ME     g 7f)NrE   lineline_gap)rE   r&   )r\   r   rJ   format_line)r*   rt   r|   s      r+   rx   Serializer.format_lines   sE     D$%%AA$*:*:4*@AA
++	 s   AAr|   c           
          [        UR                  UR                  UR                  U R                  U R
                  U R                  S9S9$ )N)r   escape_htmlr   )
is_currentrj   text)rJ   r   rj   renderr   r   r   )r*   r|   s     r+   r~   Serializer.format_line   sE    ;;.. II%)%>%>  
 	
r.   
frame_infoc              #      #     [        UR                  S S9 H  nU R                  U5      v   M     g ! [         a    [        R                  S5         g f = f7f)Nc                     U R                   $ N)ri   )vs    r+   re   -Serializer.format_variables.<locals>.<lambda>   s    !&&r.   rg   z Error in getting frame variables)rl   ru   format_variable	ExceptionlogrI   )r*   r   vars      r+   ry   Serializer.format_variables   sO     	>j228HI**3// J 	>MM<=	>s%   A/4 AAAAAr   c                     [        U R                  UR                  5      U R                  U R                  UR                  5      5      S9$ )N)ri   value)rJ   format_variable_partri   format_variable_valuer   )r*   r   s     r+   r   Serializer.format_variable   s>    **3884++D,F,Fsyy,QR
 	
r.   c                 >    U R                   (       a  [        U5      $ U$ r   )r   r   )r*   r   s     r+   r   Serializer.format_variable_part   s    99t$$Kr.   c                     [        U5      $ r   )repr)r*   r   s     r+   r    Serializer.format_variable_value   s    E{r.   c                     g)NTr&   )r*   r   s     r+   r]   Serializer.should_include_frame   s    r.   )r   r    r   r   r   r!   r   r   r   ) rM   
__module____qualname____firstlineno__r,   r	   rJ   r7   BaseExceptionr?   rK   r   r   r   r   rT   r_   r   r   r^   rx   r   r~   ry   r   r   r   strr   boolr]   __static_attributes__r&   r.   r+   r   r      s(     #"&  ,!!%0-d$t* "
} 
 

T
 
	XeI~$=>?	X	$	X
n 
 
 %	9m(K"L QU $,	
 	
 	
>9 >$ >
8 
 
c y T r.   r   )rP   loggingr4   r8   collectionsr   r   r   r   typesr   r   typingr   r   r	   rU   r
   r   r   r   r   r   stack_data.utilsr   	getLoggerrM   r   r   r&   r.   r+   <module>r      sK      
   & * ( (  &!r rr.   