
    d_                     0   d Z ddlZddlZddlZddlZddlZ	ddl
mZ g dZddddd	d
Zddddd	dZdddZd Zd Zd Z G d d          Zd Z G d d          Z eeeeeee ed          h          Zd Z ddZ!d Z"e#dk    r e!             dS dS )a/  Support to pretty-print lists, tuples, & dictionaries recursively.

Very simple, but useful, especially in debugging data structures.

Classes
-------

PrettyPrinter()
    Handle pretty-printing operations onto a stream using a configured
    set of formatting parameters.

Functions
---------

pformat()
    Format a Python object into a pretty-printed representation.

pprint()
    Pretty-print a Python object to a stream [default is sys.stdout].

saferepr()
    Generate a 'standard' repr()-like value, but protect against recursive
    data structures.

    N)StringIO)pprintpformat
isreadableisrecursivesafereprPrettyPrinterpp   P   FTcompact
sort_dictsunderscore_numbersc          	      \    t          |||||||          }|                    |            dS )zAPretty-print a Python object to a stream [default is sys.stdout].)streamindentwidthdepthr   r   r   N)r	   r   )	objectr   r   r   r   r   r   r   printers	              /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/pprint.pyr   r   0   sC     fEJ-/ / /G NN6    c                R    t          ||||||                              |           S )z<Format a Python object into a pretty-printed representation.)r   r   r   r   r   r   )r	   r   )r   r   r   r   r   r   r   s          r   r   r   9   s8     e5!(Z,>@ @ @@GPr   )r   c                *    t          | g|R d|i| dS )zPretty-print a Python objectr   N)r   )r   r   argskwargss       r   r
   r
   @   s+    
6:D:::Z:6:::::r   c                 V    t                                          | i dd          d         S )z=Version of repr() which can handle recursive data structures.Nr   r	   
_safe_reprr   s    r   r   r   D   %    ??%%fb$::1==r   c                 V    t                                          | i dd          d         S )z4Determine if saferepr(object) is readable by eval().Nr   r   r   r!   s    r   r   r   H   r"   r   c                 V    t                                          | i dd          d         S )z8Determine if object requires a recursive representation.Nr      r   r!   s    r   r   r   L   r"   r   c                   $    e Zd ZdZdgZd Zd ZdS )	_safe_keyaU  Helper function for key functions when sorting unorderable objects.

    The wrapped-object will fallback to a Py2.x style comparison for
    unorderable types (sorting first comparing the type name and then by
    the obj ids).  Does not work recursively, so dict.items() must have
    _safe_key applied to both the key and the value.

    objc                     || _         d S N)r(   )selfr(   s     r   __init__z_safe_key.__init__\   s    r   c                    	 | j         |j         k     S # t          $ ro t          t          | j                             t	          | j                   ft          t          |j                             t	          |j                   fk     cY S w xY wr*   )r(   	TypeErrorstrtypeid)r+   others     r   __lt__z_safe_key.__lt___   s    	;8ei'' 	; 	; 	;dh(("TX,,7ei))2ei==9: ; ; ;	;s    A6B
BN)__name__
__module____qualname____doc__	__slots__r,   r3    r   r   r'   r'   P   sE          I  ; ; ; ; ;r   r'   c                 V    t          | d                   t          | d                   fS )z&Helper function for comparing 2-tuplesr   r   )r'   )ts    r   _safe_tupler<   f   s!    QqT??IadOO++r   c                      e Zd Zd%dddddZd Zd	 Zd
 Zd Zd Zd Z	i Z
d Zee
ej        <   d Zee
ej        j        <   d Zee
ej        <   d Zee
ej        <   d Zee
ej        <   ee
ej        <   d Zee
ej        <   d Zee
ej        <   d Zee
ej        <   d Zee
ej         j        <   d Z!e!e
ej"        j        <   d Z#d Z$d Z%d Z&d Z'd Z(e(e
ej)        j        <   d Z*e*e
ej+        j        <   d Z,e,e
ej-        j        <   d  Z.e.e
ej/        j        <   d! Z0e0e
ej1        j        <   d" Z2e2e
ej3        j        <   d# Z4e4e
ej5        j        <   d$ Z6dS )&r	   r   r   NFTr   c                `   t          |          }t          |          }|dk     rt          d          ||dk    rt          d          |st          d          || _        || _        || _        ||| _        nt          j        | _        t          |          | _	        || _
        || _        dS )a  Handle pretty printing operations onto a stream using a set of
        configured parameters.

        indent
            Number of spaces to indent for each level of nesting.

        width
            Attempted maximum number of columns in the output.

        depth
            The maximum depth to print out nested structures.

        stream
            The desired output stream.  If omitted (or false), the standard
            output stream available at construction will be used.

        compact
            If true, several items will be combined in one line.

        sort_dicts
            If true, dict keys are sorted.

        r   zindent must be >= 0Nzdepth must be > 0zwidth must be != 0)int
ValueError_depth_indent_per_level_width_stream_sysstdoutbool_compact_sort_dicts_underscore_numbers)r+   r   r   r   r   r   r   r   s           r   r,   zPrettyPrinter.__init__k   s    2 VE

A::2333!0111 	31222!'!DLL;DLW%#5   r   c                     | j         ;|                     || j         ddi d           | j                             d           d S d S )Nr   
)rD   _formatwriter+   r   s     r   r   zPrettyPrinter.pprint   sL    <#LLq!R;;;Lt$$$$$ $#r   c                 z    t                      }|                     ||ddi d           |                                S Nr   )	_StringIOrM   getvalue)r+   r   sios      r   r   zPrettyPrinter.pformat   s5    kkVS!QA...||~~r   c                 >    |                      |i dd          d         S )Nr   r%   formatrO   s     r   r   zPrettyPrinter.isrecursive   s    {{62q!,,Q//r   c                 D    |                      |i dd          \  }}}|o| S rQ   rV   )r+   r   sreadable	recursives        r   r   zPrettyPrinter.isreadable   s-    !%VRA!>!>8Y)	M)r   c           
         t          |          }||v r2|                    t          |                     d| _        d| _        d S |                     |||          }| j        |z
  |z
  }	t          |          |	k    r| j        	                    t          |          j        d           }
|
d||<    |
| ||||||dz              ||= d S t          j        |          rpt          |t                    s[|j        j        rOt#          |j        d          r:d|j        j        j        v r'd||<   |                     ||||||dz              ||= d S |                    |           d S )NTFr   __wrapped____create_fn__)r1   rN   
_recursion
_recursive	_readable_reprrC   len	_dispatchgetr0   __repr___dataclassesis_dataclass
isinstance__dataclass_params__reprhasattrr]   r6   _pprint_dataclass)r+   r   r   r   	allowancecontextlevelobjidrep	max_widthps              r   rM   zPrettyPrinter._format   s   6

GLLF++,,,"DO"DNFjj%00K&(94	s88i""4<<#8$??A}!"$	7EAINNNEN+F33 	 ..	-2	 &/=99		
 "V_%@%MMM!"&&vvvy'SX[\S\]]]ENSr   c                    j         j        }|t          |          dz   z  }fdt          j                  D             }|                    |dz              |                     ||||||           |                    d           d S )Nr   c                 V    g | ]%}|j         	|j        t          |j                  f&S r9   )rk   namegetattr).0fr   s     r   
<listcomp>z3PrettyPrinter._pprint_dataclass.<locals>.<listcomp>   s5    bbbq[\[ab!&'&!&112bbbr   ())	__class__r4   rc   rg   fieldsrN   _format_namespace_items	r+   r   r   r   rn   ro   rp   cls_nameitemss	    `       r   rm   zPrettyPrinter._pprint_dataclass   s    #,#h--!##bbbbL<OPV<W<WbbbX^$$$$$UFFIwPUVVVSr   c                 f   |j         } |d           | j        dk    r || j        dz
  dz             t          |          }|ra| j        r)t	          |                                t                    }	n|                                }	|                     |	|||dz   ||            |d           d S )N{r    key})rN   rB   rc   rI   sortedr   r<   _format_dict_items)
r+   r   r   r   rn   ro   rp   rN   lengthr   s
             r   _pprint_dictzPrettyPrinter._pprint_dict   s    c


!A%%E4)A-4555V 	4 'v||~~;???##E669q=$+U4 4 4c




r   c                    t          |          s$|                    t          |                     d S |j        }|                    |j        dz              |                     t          |                                          ||t          |j                  z   dz   |dz   ||           |                    d           d S )Nr|   r   r}   )rc   rN   rk   r~   r4   rM   listr   )r+   r   r   r   rn   ro   rp   clss           r   _pprint_ordered_dictz"PrettyPrinter._pprint_ordered_dict   s    6{{ 	LLf&&&FS\C'(((T&,,..))6c#,///!3Y]e	% 	% 	% 	Sr   c                     |                     d           |                     ||||dz   ||           |                     d           d S )N[r   ])rN   _format_itemsr+   r   r   r   rn   ro   rp   s          r   _pprint_listzPrettyPrinter._pprint_list   sU    S6669q="E	+ 	+ 	+Sr   c           	          |                     d           t          |          dk    rdnd}|                     ||||t          |          z   ||           |                     |           d S )Nr|   r   z,)r}   )rN   rc   r   )r+   r   r   r   rn   ro   rp   endchars           r   _pprint_tuplezPrettyPrinter._pprint_tuple   su    Sf++**$$6669s7||3K"E	+ 	+ 	+Wr   c           	         t          |          s$|                    t          |                     d S |j        }|t          u r|                    d           d}n9|                    |j        dz              d}|t          |j                  dz   z  }t          |t                    }|                     ||||t          |          z   ||           |                    |           d S )Nr   r   ({})r   r   )	rc   rN   rk   r~   setr4   r   r'   r   )	r+   r   r   r   rn   ro   rp   typr   s	            r   _pprint_setzPrettyPrinter._pprint_set   s    6{{ 	LLf&&&F#::LLGGLL,---Gc#,''!++FI...6669s7||3K"E	+ 	+ 	+Wr   c                 |   |j         }t          |          s |t          |                     d S g }|                    d          }	|dk    r
|dz  }|dz  }| j        |z
  x}
}t          |	          D ]L\  }}t          |          }|t          |	          dz
  k    r|
|z  }
t          |          |
k    r|                    |           Yt          j        d|          }|sJ |d         rJ |	                                 |}d}t          |          D ]\  }}||z   }|t          |          dz
  k    r|t          |	          dz
  k    r||z  }t          t          |                    |k    r'|r"|                    t          |                     |}|}|r"|                    t          |                     Nt          |          dk    r ||           d S |dk    r |d           t          |          D ]'\  }}|dk    r |dd	|z  z               ||           (|dk    r |d
           d S d S )NTr   z\S*\s* r|   r   rL   r   r}   )
rN   rc   rk   
splitlinesrC   	enumerateappendrefindallpop)r+   r   r   r   rn   ro   rp   rN   chunkslines
max_width1rs   ilinerr   parts
max_width2currentjpart	candidates                        r   _pprint_strzPrettyPrinter._pprint_str  s   6{{ 	E$v,,F!!$''A::aKFNI!%v!55
Y '' 	1 	1GAtt**CCJJN""i'
3xx:%%c"""" 
9d33 9$$$		&
(// 	, 	,GAt '$ICJJN**qCJJN/B/B"i/
4	??++j88" 9"MM$w--888"&"+ 1MM$w--000v;;!E#JJJFA::E#JJJ'' 	 	FAs1uudSZ'(((E#JJJJA::E#JJJJJ :r   c                 B   |j         }t          |          dk    r |t          |                     d S |dk    }|r|dz  }|dz  } |d           d}	t          || j        |z
  |          D ]"}
 ||	            ||
           |	sdd|z  z   }	#|r |d           d S d S )N   r   r|   r   rL   r   r}   )rN   rc   rk   _wrap_bytes_reprrC   )r+   r   r   r   rn   ro   rp   rN   parensdelimrr   s              r   _pprint_byteszPrettyPrinter._pprint_bytesD  s    v;;!E$v,,F! 	aKFNIE#JJJ#FDK&,@)LL 	* 	*CE%LLLE#JJJ *s6z) 	E#JJJJJ	 	r   c           	          |j         } |d           |                     t          |          ||dz   |dz   ||dz               |d           d S )Nz
bytearray(
   r   r}   )rN   r   bytes)r+   r   r   r   rn   ro   rp   rN   s           r   _pprint_bytearrayzPrettyPrinter._pprint_bytearrayY  sa    l5==&&2+$q='519	> 	> 	>c




r   c                     |                     d           |                     |                                ||dz   |dz   ||           |                     d           d S )Nzmappingproxy(   r   r}   )rN   rM   copyr   s          r   _pprint_mappingproxyz"PrettyPrinter._pprint_mappingproxyb  s_    _%%%V[[]]FFRKQe	% 	% 	%Sr   c                 D   t          |          t          j        u rd}n|j        j        }|t          |          dz   z  }|j                                        }|                    |dz              | 	                    ||||||           |                    d           d S )N	namespacer   r|   r}   )
r0   _typesSimpleNamespacer~   r4   rc   __dict__r   rN   r   r   s	            r   _pprint_simplenamespacez%PrettyPrinter._pprint_simplenamespacej  s    <<6111 #HH'0H#h--!##%%''X^$$$$$UFFIwPUVVVSr   c           	      n   |j         }|| j        z  }dd|z  z   }t          |          dz
  }	t          |          D ]y\  }
\  }}|
|	k    }|                     |||          } ||            |d           |                     |||t          |          z   dz   |r|nd||           |s ||           zd S )N,
r   r   : r%   )rN   rB   rc   r   rb   rM   )r+   r   r   r   rn   ro   rp   rN   delimnl
last_indexr   r   entlastrr   s                  r   r   z PrettyPrinter._format_dict_itemsy  s    $((#,&ZZ!^
&u-- 		 		MAzS
?D**S'511CE#JJJE$KKKLLffs3xx&7!&;&*1 %) ) )  g		 		r   c           	      f   |j         }dd|z  z   }t          |          dz
  }	t          |          D ]\  }
\  }}|
|	k    } ||            |d           t          |          |v r |d           n1|                     |||t          |          z   dz   |r|nd||           |s ||           d S )Nr   r   r   =...)rN   rc   r   r1   rM   )r+   r   r   r   rn   ro   rp   rN   r   r   r   r   r   r   s                 r   r   z%PrettyPrinter._format_namespace_items  s    #,&ZZ!^
&u-- 	 	MAzS
?DE#JJJE#JJJ#ww'!! eS&&3s88*;a*?*.5YYA$e- - -  g	 	r   c                    |j         }|| j        z  }| j        dk    r || j        dz
  dz             dd|z  z   }d}	| j        |z
  dz   x}
}t          |          }	 t	          |          }n# t
          $ r Y d S w xY wd}|s|}	 t	          |          }n# t
          $ r d}||z  }|
|z  }
Y nw xY w| j        rY|                     |||          }t          |          dz   }|
|k     r|}
|	r|}	|
|k    r|
|z  }
 ||	           d}	 ||            ||	           |}	| 	                    ||||r|nd||           |d S d S )	Nr   r   r   r   FTr%   , )
rN   rB   rC   iternextStopIterationrH   rb   rc   rM   )r+   r   r   r   rn   ro   rp   rN   r   r   r   rs   itnext_entr   r   rr   ws                     r   r   zPrettyPrinter._format_items  s   $((!A%%E4)A-4555#,& K&0144	%[[	BxxHH 	 	 	FF	 	)C#88  # # #Y&	"# } jjgu55HHqL199%E ( 'A::QJEE%LLL EE#JJJE%LLLELLff&*1 %) ) )/  	) 	) 	) 	) 	)s$   A, ,
A:9A:B B-,B-c                     |                      ||                                | j        |          \  }}}|sd| _        |rd| _        |S )NFT)rW   r   rA   ra   r`   )r+   r   ro   rp   rk   rZ   r[   s          r   rb   zPrettyPrinter._repr  sT    $(KK04U%D %D!h	 	#"DN 	#"DOr   c                 2    |                      ||||          S )zFormat object for a specific context, returning a string
        and flags indicating whether the representation is 'readable'
        and whether the object represents a recursive construct.
        )r    )r+   r   ro   	maxlevelsrp   s        r   rW   zPrettyPrinter.format  s    
 vw	5AAAr   c                    t          |          s$|                    t          |                     d S |                     |j        ||          }|j        }|t          |j                  dz   z  }|                    |j        d|dd|z             |                     ||||dz   ||           |                    d           d S )Nr   r|   r   r   r}   )rc   rN   rk   rb   default_factoryr~   r4   r   )	r+   r   r   r   rn   ro   rp   rdfr   s	            r   _pprint_default_dictz"PrettyPrinter._pprint_default_dict  s    6{{ 	LLf&&&Fjj/%@@#cl##a''S\\\333fEFFF&&&)a-%PPPSr   c                    t          |          s$|                    t          |                     d S |j        }|                    |j        dz              | j        dk    r |                    | j        dz
  dz             |                                }|                     |||t          |j                  z   dz   |dz   ||           |                    d           d S )Nr   r   r   r%   r   )rc   rN   rk   r~   r4   rB   most_commonr   )	r+   r   r   r   rn   ro   rp   r   r   s	            r   _pprint_counterzPrettyPrinter._pprint_counter  s    6{{ 	LLf&&&FS\D()))!A%%LL$014;<<<""$$v &S\):): :Q >	A '	0 	0 	0 	Tr   c           	      ,   t          |j                  s$|                    t          |                     d S |j        }|                    |j        dz              |t          |j                  dz   z  }t          |j                  D ]\  }}	|t          |j                  dz
  k    r3|                     |	|||dz   ||           |                    d           S|                     |	||d||           |                    dd|z  z              d S )Nr|   r   r}   r   r   )rc   mapsrN   rk   r~   r4   r   rM   )
r+   r   r   r   rn   ro   rp   r   r   ms
             r   _pprint_chain_mapzPrettyPrinter._pprint_chain_map  s   6; 	LLf&&&FS\C'(((#cl##a''fk** 	3 	3DAqC$$q(((Q	AwNNNS!!!!Q7EBBBUS6\12222	3 	3r   c                 2   t          |          s$|                    t          |                     d S |j        }|                    |j        dz              |t          |j                  dz   z  }|                    d           |j        4|                     ||||dz   ||           |                    d           d S |                     |||d||           |                     |j        ||          }|                    dd|z  d|d	           d S )
Nr|   r   r   r%   z])z],
r   zmaxlen=r}   )rc   rN   rk   r~   r4   maxlenr   rb   )	r+   r   r   r   rn   ro   rp   r   rmls	            r   _pprint_dequezPrettyPrinter._pprint_deque  s)   6{{ 	LLf&&&FS\C'(((#cl##a''S= vvvy1}&/ / /LLvvvq&/ / /**V]GU;;CLLLsV|||SSSABBBBBr   c           	      J    |                      |j        |||||dz
             d S Nr   rM   datar   s          r   _pprint_user_dictzPrettyPrinter._pprint_user_dict  *    V[&&)WeaiPPPPPr   c           	      J    |                      |j        |||||dz
             d S r   r   r   s          r   _pprint_user_listzPrettyPrinter._pprint_user_list  r   r   c           	      J    |                      |j        |||||dz
             d S r   r   r   s          r   _pprint_user_stringz!PrettyPrinter._pprint_user_string"  r   r   c                    t          |          }|t          v rt          |          ddfS t          |dd           }t	          |t
                    r.|t
          j        u r | j        r|dddfS t          |          ddfS t	          |t                    r|t          j        u r|sdS t          |          }|r||k    rdd||v fS ||v rt          |          ddfS d||<   d}d}	g }
|
j        }|dz  }| j        r)t          |                                t                    }n|                                }|D ]Y\  }}|                     ||||          \  }}}|                     ||||          \  }}} ||d	|           |o|o|}|s|rd}	Z||= d
d                    |
          z  ||	fS t	          |t$                    r|t$          j        u s#t	          |t&                    r|t&          j        u rt	          |t$                    r|sdS d}nt)          |          dk    rd}n|sdS d}t          |          }|r||k    r
|dz  d||v fS ||v rt          |          ddfS d||<   d}d}	g }
|
j        }|dz  }|D ]1}|                     ||||          \  }}} ||           |sd}|rd}	2||= |d                    |
          z  ||	fS t          |          }||o|                    d           dfS )NTFrf   _d)z{}TFz{...}r   r   r   z{%s}r   )z[]TFz[%s]z(%s,))z()TFz(%s)r   <)r0   _builtin_scalarsrk   rx   
issubclassr?   rf   rJ   dictr1   r_   r   rI   r   r   r<   rW   joinr   tuplerc   
startswith)r+   r   ro   r   rp   r   rrq   rZ   r[   
componentsr   r   kvkrepr	kreadablekrecurvrepr	vreadablevrecurrW   oorepr	oreadableorecurrr   s                              r   r    zPrettyPrinter._safe_repr'  s   6ll"""<<u,,CT**c3 	1A$5$5' 1 ~~tU22F||T500c4   	GQ$-%7%7 )((vJJE 8Ui//u'777!&))5$66GENHIJ&FQJE 'v||~~;??? % %1+/;;w	5,2 ,2(y&+/;;w	5,2 ,2(y&555%%0111#?	?i %V % $IDIIj1118YFFsD!!  	Ga4=&8&8sE"" '9'(EN':':#t$$ 	  -,,V!!  -,,vJJE ?Ui//~uew.>>>!&))5$66GENHIJ&FQJE % %+/;;w	5,2 ,2(y&u  %$H % $IDIIj1118YFF6llS4!4!44u<<r   )r   r   NN)7r4   r5   r6   r,   r   r   r   r   rM   rm   rd   r   r   rf   r   _collectionsOrderedDictr   r   r   r   r   r   	frozensetr   r/   r   r   r   	bytearrayr   r   MappingProxyTyper   r   r   r   r   rb   rW   r   defaultdictr   Counterr   ChainMapr   dequer   UserDictr   UserListr   
UserStringr    r9   r   r   r	   r	   j   s6       *64E*6 *6 *6 *6 *6X% % %
  
0 0 0* * *  8   I    ,Idm	 	 	 4HIl&/0    ,Idm   !.Ien  " *Icl$/Ii !/ / /b *Icl  & !.Ien   %6Ii !   3GIf%./   2IIf$-.  "  &') ') ')R  B B B	 	 	 4HIl&/0   0?Il"+,3 3 3 1BIl#,-C C C$ .;Il )*Q Q Q 1BIl#,-Q Q Q 1BIl#,-Q Q Q 3FIl%./O= O= O= O= O=r   r	   c                 R    dt          |           j        dt          |           dS )Nz<Recursion on z	 with id=>)r0   r4   r1   r!   s    r   r_   r_   {  s,     F||$$$bjjjj2 3r   c                 l   dd l }| ddddgdddfgd	z  } t                      }|                                }|                    | i d dd
           |                                }|                    |            |                                }t          d||z
             t          d||z
             d S )Nr   string)r   r%      r         )      i Tz_safe_repr:zpformat:)timer	   perf_counterr    r   print)r   r$  rt   t1t2t3s         r   
_perfcheckr*    s    KKK~VaVq\\:;fDA					BLLT1d+++					BIIf					B	-b!!!	*b2gr   c              #   N  K   d}t          |           dz  dz  }t          dt          |           d          D ]W}| ||dz            }||z   }||k    r||z  }t          t          |                    |k    r|rt          |          V  |}U|}X|rt          |          V  d S d S )Nr   r   r   )rc   rangerk   )r   r   rn   r   r   r   r   r   s           r   r   r     s      Gv;;!aD1c&kk1%% 
  
 a1f~dN	99YEtI%'' $7mm###GGGG 7mm r   __main__)Nr   r   N)r   r   Nr*   )$r7   collectionsr  dataclassesrg   r   sysrE   typesr   ior   rR   __all__r   r   r
   r   r   r   r'   r<   r	   r  r/   r   r  floatcomplexrG   r0   r   r_   r*  r   r4   r9   r   r   <module>r6     s   4 # " " " " " " " 				         $ $ $ $ $ $" " "Te    PduP P P P P "' ; ; ; ; ;> > >> > >> > >; ; ; ; ; ; ; ;,, , ,L= L= L= L= L= L= L= L=\ 9c5)UG"DDJJ0 1 1 3 3 3
     " zJLLLLL r   