AlkantarClanX12

Your IP : 18.116.85.204


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/pprint.cpython-310.opt-1.pyc

o

6��f|_�	@s�dZddlZddlZddlZddlZddlZ	ddl
mZgd�Z
d$dddd	�d
d�Zd%dddd	�dd
�Zdd�dd�Zdd�Zdd�Zdd�ZGdd�d�Zdd�ZGdd�d�Zeeeeeeeed�h�Zdd�Z d&dd �Z!d!d"�Z"e#d#kr|e!�dSdS)'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��PFT��compact�
sort_dicts�underscore_numbersc		Cs$t|||||||d�}|�|�dS)zAPretty-print a Python object to a stream [default is sys.stdout].)�stream�indent�width�depthr
rrN)rr)	�objectrrrrr
rrZprinter�r�-/opt/alt/python310/lib64/python3.10/pprint.pyr0s�rcCst||||||d��|�S)z<Format a Python object into a pretty-printed representation.)rrrr
rr)rr)rrrrr
rrrrrr9s��r)rcOst|g|�Rd|i|��dS)zPretty-print a Python objectrN)r)rr�args�kwargsrrrr	@sr	cCst��|idd�dS)z=Version of repr() which can handle recursive data structures.Nr�r�
_safe_repr�rrrrrD�rcC�t��|idd�dS)z4Determine if saferepr(object) is readable by eval().Nrr
rrrrrrHrrcCr)z8Determine if object requires a recursive representation.Nr�rrrrrrLrrc@s&eZdZdZdgZdd�Zdd�ZdS)�	_safe_keyaUHelper 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.

    �objcCs
||_dS�N)r )�selfr rrr�__init__\s
z_safe_key.__init__cCsRz|j|jkWSty(tt|j��t|j�ftt|j��t|j�fkYSwr!)r �	TypeError�str�type�id)r"�otherrrr�__lt___s��z_safe_key.__lt__N)�__name__�
__module__�__qualname__�__doc__�	__slots__r#r)rrrrrPs
	rcCst|d�t|d�fS)z&Helper function for comparing 2-tuplesrr
)r)�trrr�_safe_tuplefsr0c@s�eZdZdCdddd�dd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Z	iZ
dd�Zee
ej
<dd�Zee
ejj
<dd�Zee
ej
<dd�Zee
ej
<dd�Zee
ej
<ee
ej
<dd �Zee
ej
<d!d"�Zee
ej
<d#d$�Zee
ej
<d%d&�Zee
ej j
<d'd(�Z!e!e
ej"j
<d)d*�Z#d+d,�Z$d-d.�Z%d/d0�Z&d1d2�Z'd3d4�Z(e(e
ej)j
<d5d6�Z*e*e
ej+j
<d7d8�Z,e,e
ej-j
<d9d:�Z.e.e
ej/j
<d;d<�Z0e0e
ej1j
<d=d>�Z2e2e
ej3j
<d?d@�Z4e4e
ej5j
<dAdB�Z6dS)Drr
rNFTrcCs�t|�}t|�}|dkrtd��|dur|dkrtd��|s"td��||_||_||_|dur3||_ntj|_t|�|_	||_
||_dS)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.

        rzindent must be >= 0Nzdepth must be > 0zwidth must be != 0)�int�
ValueError�_depth�_indent_per_level�_width�_stream�_sys�stdout�bool�_compact�_sort_dicts�_underscore_numbers)r"rrrrr
rrrrrr#ks"

zPrettyPrinter.__init__cCs&|�||jddid�|j�d�dS)Nr�
)�_formatr6�write�r"rrrrr�szPrettyPrinter.pprintcCs"t�}|�||ddid�|��S�Nr)�	_StringIOr>�getvalue)r"rZsiorrrr�szPrettyPrinter.pformatcCs|�|idd�dS)Nrr��formatr@rrrr�szPrettyPrinter.isrecursivecCs |�|idd�\}}}|o|SrArD)r"r�s�readable�	recursiverrrr�s
zPrettyPrinter.isreadablec	Cs
t|�}||vr|�t|��d|_d|_dS|�|||�}|j||}	t|�|	kr~|j�	t
|�jd�}
|
durNd||<|
|||||||d�||=dSt�
|�r~t|t
�s~|jjr~t|jd�r~d|jjjvr~d||<|�||||||d�||=dS|�|�dS)NTFr
�__wrapped__Z
__create_fn__)r'r?�
_recursion�
_recursive�	_readable�_reprr5�len�	_dispatch�getr&�__repr__�_dataclassesZis_dataclass�
isinstanceZ__dataclass_params__�repr�hasattrrIr,�_pprint_dataclass)r"rrr�	allowance�context�level�objid�rep�	max_width�prrrr>�s8
��
�zPrettyPrinter._formatc	s`�jj}|t|�d7}�fdd�t���D�}|�|d�|�||||||�|�d�dS)Nr
cs$g|]}|jr|jt�|j�f�qSr)rT�name�getattr)�.0�frrr�
<listcomp>�s$z3PrettyPrinter._pprint_dataclass.<locals>.<listcomp>�(�))�	__class__r*rNrRZfieldsr?�_format_namespace_items�	r"rrrrWrXrY�cls_name�itemsrrrrV�szPrettyPrinter._pprint_dataclassc
Csz|j}|d�|jdkr||jdd�t|�}|r7|jr't|��td�}	n|��}	|�|	|||d||�|d�dS)N�{r
� ��key�})r?r4rNr;�sortedrir0�_format_dict_items)
r"rrrrWrXrYr?Zlengthrirrr�_pprint_dict�s
�zPrettyPrinter._pprint_dictcCslt|�s
|�t|��dS|j}|�|jd�|�t|���||t|j�d|d||�|�d�dS)Nrcr
rd)rNr?rTrer*r>�listri)r"rrrrWrXrY�clsrrr�_pprint_ordered_dict�s�z"PrettyPrinter._pprint_ordered_dictcCs0|�d�|�||||d||�|�d�dS)N�[r
�])r?�
_format_items�r"rrrrWrXrYrrr�_pprint_list�s

�zPrettyPrinter._pprint_listcCsH|�d�t|�dkr
dnd}|�||||t|�||�|�|�dS)Nrcr
z,)rd)r?rNrw)r"rrrrWrXrY�endcharrrr�
_pprint_tuple�s
�zPrettyPrinter._pprint_tuplec	Cs�t|�s
|�t|��dS|j}|tur|�d�d}n|�|jd�d}|t|j�d7}t|td�}|�||||t|�||�|�|�dS)Nrjrn�({�})r
rl)	rNr?rTre�setr*rorrw)	r"rrrrWrXrY�typrzrrr�_pprint_set�s
�zPrettyPrinter._pprint_setcCs�|j}t|�s|t|��dSg}|�d�}	|dkr"|d7}|d7}|j|}
}t|	�D]n\}}
t|
�}|t|	�dkrA|
|8}
t|�|
krM|�|�q-t�d|
�}|�	�|}d}t|�D]2\}}||}|t|�dkr{|t|	�dkr{||8}tt|��|kr�|r�|�t|��|}q_|}q_|r�|�t|��q-t|�dkr�||�dS|dkr�|d�t|�D]\}}|dkr�|dd|�||�q�|dkr�|d	�dSdS)
NTr
z\S*\s*�rcrr=rkrd)
r?rNrT�
splitlinesr5�	enumerate�append�re�findall�pop)r"rrrrWrXrYr?Zchunks�linesZ
max_width1r\�i�liner[�partsZ
max_width2�current�j�part�	candidaterrr�_pprint_strsX
 �
�zPrettyPrinter._pprint_strcCs�|j}t|�dkr|t|��dS|dk}|r#|d7}|d7}|d�d}	t||j||�D]}
||	�||
�|	s@dd|}	q.|rI|d�dSdS)N�r
rcr�r=rkrd)r?rNrT�_wrap_bytes_reprr5)r"rrrrWrXrYr?Zparens�delimr[rrr�
_pprint_bytesCs&��zPrettyPrinter._pprint_bytesc	Cs>|j}|d�|�t|�||d|d||d�|d�dS)Nz
bytearray(�
r
rd)r?r��bytes)r"rrrrWrXrYr?rrr�_pprint_bytearrayXs�zPrettyPrinter._pprint_bytearraycCs8|�d�|�|��||d|d||�|�d�dS)Nz
mappingproxy(�
r
rd)r?r>�copyrxrrr�_pprint_mappingproxyas

�z"PrettyPrinter._pprint_mappingproxyc	Csft|�tjur
d}n|jj}|t|�d7}|j��}|�|d�|�	||||||�|�d�dS)N�	namespacer
rcrd)
r&�_types�SimpleNamespacerer*rN�__dict__rir?rfrgrrr�_pprint_simplenamespaceis
z%PrettyPrinter._pprint_simplenamespacec	Cs�|j}||j7}dd|}t|�d}	t|�D]3\}
\}}|
|	k}
|�|||�}||�|d�|�|||t|�d|
r@|nd||�|
sK||�qdS)N�,
rkr
z: r)r?r4rNr�rMr>)r"rirrrWrXrYr?�delimnl�
last_indexr�rm�ent�lastr[rrrrpxs"

���z PrettyPrinter._format_dict_itemsc	Cs�|j}dd|}t|�d}	t|�D]7\}
\}}|
|	k}
||�|d�t|�|vr0|d�n|�|||t|�d|
r?|nd||�|
sJ||�qdS)Nr�rkr
�=�...)r?rNr�r'r>)r"rirrrWrXrYr?r�r�r�rmr�r�rrrrf�s"

���z%PrettyPrinter._format_namespace_itemscCsF|j}||j7}|jdkr||jdd�dd|}d}	|j|d}
}t|�}zt|�}
Wn
ty;YdSwd}|s�|
}zt|�}
Wnty[d}||8}|
|8}
Ynw|jr�|�|||�}t|�d}|
|krv|}
|	rv|}	|
|kr�|
|8}
||	�d}	||�q>||	�|}	|�	||||r�|nd||�|r@dSdS)	Nr
rkr�r�FTr�, )
r?r4r5�iter�next�
StopIterationr:rMrNr>)r"rirrrWrXrYr?r�r�rr\�itZnext_entr�r�r[�wrrrrw�sV

��

��zPrettyPrinter._format_itemscCs4|�||��|j|�\}}}|sd|_|rd|_|S)NFT)rEr�r3rLrK)r"rrXrYrTrGrHrrrrM�s
�zPrettyPrinter._reprcCs|�||||�S)z�Format 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"rrX�	maxlevelsrYrrrrE�szPrettyPrinter.formatc	Cs�t|�s
|�t|��dS|�|j||�}|j}|t|j�d7}|�d|j|d|f�|�||||d||�|�d�dS)Nr
z	%s(%s,
%srkrd)rNr?rTrM�default_factoryrer*rq)	r"rrrrWrXrYZrdfrsrrr�_pprint_default_dict�sz"PrettyPrinter._pprint_default_dictc	Cs�t|�s
|�t|��dS|j}|�|jd�|jdkr'|�|jdd�|��}|�|||t|j�d|d||�|�d�dS)Nr|r
rkrr})rNr?rTrer*r4�most_commonrp)	r"rrrrWrXrYrsrirrr�_pprint_counter�s
�zPrettyPrinter._pprint_counterc
	Cs�t|j�s|�t|��dS|j}|�|jd�|t|j�d7}t|j�D]2\}}	|t|j�dkrF|�|	|||d||�|�d�q'|�|	||d||�|�dd|�q'dS)Nrcr
rdr�rk)rN�mapsr?rTrer*r�r>)
r"rrrrWrXrYrsr��mrrr�_pprint_chain_map�s
�zPrettyPrinter._pprint_chain_mapc	Cs�t|�s
|�t|��dS|j}|�|jd�|t|j�d7}|�d�|jdur>|�||||d||�|�d�dS|�|||d||�|�|j||�}|�dd||f�dS)Nrcr
rurz])z],
%smaxlen=%s)rk)rNr?rTrer*�maxlenrwrM)	r"rrrrWrXrYrsZrmlrrr�
_pprint_deques"

��zPrettyPrinter._pprint_dequec	C�|�|j|||||d�dS�Nr
�r>�datarxrrr�_pprint_user_dict�zPrettyPrinter._pprint_user_dictc	Cr�r�r�rxrrr�_pprint_user_listr�zPrettyPrinter._pprint_user_listc	Cr�r�r�rxrrr�_pprint_user_string!r�z!PrettyPrinter._pprint_user_stringcCs�t|�}|tvrt|�ddfSt|dd�}t|t�r0|tjur0|jr)|d�ddfSt|�ddfSt|t�r�|tjur�|s>dSt	|�}|rO||krOdd||vfS||vrZt
|�ddfSd||<d}d}	g}
|
j}|d7}|jrwt
|��td�}n|��}|D].\}
}|�|
|||�\}}}|�||||�\}}}|d	||f�|o�|o�|}|s�|r�d}	q}||=d
d�|
�||	fSt|t�r�|tjus�t|t��rF|tju�rFt|t�r�|s�dSd
}nt|�dkr�d}n|s�dSd}t	|�}|r�||kr�|dd||vfS||v�r	t
|�ddfSd||<d}d}	g}
|
j}|d7}|D]}|�||||�\}}}||�|�s2d}|�r7d}	�q||=|d�|
�||	fSt|�}||�oS|�d�dfS)NTFrQZ_d)z{}TFz{...}r
rlz%s: %sz{%s}r�)z[]TFz[%s]z(%s,))z()TFz(%s)r��<)r&�_builtin_scalarsrTr_�
issubclassr1rQr<�dictr'rJr�r;rorir0rE�joinrr�tuplerN�
startswith)r"rrXr�rYr�rrZrGrHZ
componentsr�ri�k�vZkreprZ	kreadableZkrecurZvreprZ	vreadableZvrecurrE�oZoreprZ	oreadableZorecurr[rrrr&s�
�
���


��zPrettyPrinter._safe_repr)r
rNN)7r*r+r,r#rrrrr>rVrOrqr�rQrt�_collections�OrderedDictryrrr{r�r�r~�	frozensetr�r%r�r�r��	bytearrayr�r��MappingProxyTyper�r�rprfrwrMrEr��defaultdictr��Counterr��ChainMapr��dequer��UserDictr��UserListr��
UserStringrrrrrrjsh�,





1


)	rcCsdt|�jt|�fS)Nz<Recursion on %s with id=%s>)r&r*r'rrrrrJzs�rJcCs�ddl}|durddddgddd�fgd	}t�}|��}|�|iddd
�|��}|�|�|��}td||�td||�dS)
Nr�string)r
r�r���)��i��Tz_safe_repr:zpformat:)�timer�perf_counterrr�print)rr�r]�t1�t2Zt3rrr�
_perfchecks
r�ccs��d}t|�dd}tdt|�d�D]*}|||d�}||}||kr)||8}tt|��|kr;|r8t|�V|}q|}q|rGt|�VdSdS)N�r�r)rN�rangerT)rrrWr�r�r�r�r�rrrr��s �
�r��__main__)Nr
rN)r
rNr!)$r-�collectionsr�ZdataclassesrRr��sysr7�typesr��iorrB�__all__rrr	rrrrr0rr�r%r�r��float�complexr9r&r�rJr�r�r*rrrr�<module>sD
�	��


�