Hacked By AnonymousFox

Current Path : /opt/alt/python38/lib64/python3.8/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/__pycache__/pprint.cpython-38.opt-1.pyc

U

i�f�S�
@sdZddlZddlZddlZddlZddlm	Z
dddddd	d
gZd%d
dd�dd�Zd&d
dd�dd�Z
d
d�dd
�Zdd�Zdd�Zdd�ZGdd�d�Zdd�ZGdd	�d	�Zdd�Zeeeeeeeeed�h�Zdd�Z d'd d!�Z!d"d#�Z"e#d$k�r�e!�dS)(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_dictscCs"t||||||d�}|�|�dS)zAPretty-print a Python object to a stream [default is sys.stdout].)�stream�indent�width�depthr
rN)rr)�objectrrrrr
rZprinter�r�+/opt/alt/python38/lib64/python3.8/pprint.pyr/s�cCst|||||d��|�S)z<Format a Python object into a pretty-printed representation.)rrrr
r)rr)rrrrr
rrrrr7s��)rcOst|f|�d|i|��dS)zPretty-print a Python objectrN)r)rr�args�kwargsrrrr	=scCst|iddd�dS)z=Version of repr() which can handle recursive data structures.NrT��
_safe_repr�rrrrrAscCst|iddd�dS)z4Determine if saferepr(object) is readable by eval().NrTr
rrrrrrEscCst|iddd�dS)z8Determine if object requires a recursive representation.NrT�rrrrrrIsc@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)�selfrrrr�__init__Ysz_safe_key.__init__cCsXz|j|jkWStk
rRtt|j��t|j�ftt|j��t|j�fkYSXdSr)r�	TypeError�str�type�id)r�otherrrr�__lt__\s�z_safe_key.__lt__N)�__name__�
__module__�__qualname__�__doc__�	__slots__r r&rrrrrMs	rcCst|d�t|d�fS)z&Helper function for comparing 2-tuplesrr
)r)�trrr�_safe_tuplecsr-c@s�eZdZd;ddd�dd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�ZiZ	dd�Z
e
e	ej<dd�Z
e
e	ejj<dd�Zee	ej<dd�Zee	ej<dd�Zee	ej<ee	ej<dd�Zee	ej<dd �Zee	ej<d!d"�Zee	ej<d#d$�Zee	ejj<d%d&�Z d'd(�Z!d)d*�Z"d+d,�Z#d-d.�Z$e$e	ej%j<d/d0�Z&e&e	ej'j<d1d2�Z(e(e	ej)j<d3d4�Z*e*e	ej+j<d5d6�Z,e,e	ej-j<d7d8�Z.e.e	ej/j<d9d:�Z0e0e	ej1j<dS)<rr
rNFTrcCs�t|�}t|�}|dkr td��|dk	r8|dkr8td��|sDtd��||_||_||_|dk	rf||_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)rrrrrr
rrrrr hs 
zPrettyPrinter.__init__cCs&|�||jddid�|j�d�dS)Nr�
)�_formatr3�write�rrrrrr�szPrettyPrinter.pprintcCs"t�}|�||ddid�|��S�Nr)�	_StringIOr:�getvalue)rrZsiorrrr�szPrettyPrinter.pformatcCs|�|idd�dS)Nrr��formatr<rrrr�szPrettyPrinter.isrecursivecCs |�|idd�\}}}|o|Sr=r@)rr�s�readable�	recursiverrrr�szPrettyPrinter.isreadablec	Cs�t|�}||kr.|�t|��d|_d|_dS|�|||�}|j||}	t|�|	kr�|j�	t
|�jd�}
|
dk	r�d||<|
|||||||d�||=dSt|t
�r�d||<|�||||||d�||=dS|�|�dS)NTFr
)r$r;�
_recursion�
_recursive�	_readable�_reprr2�len�	_dispatch�getr#�__repr__�
isinstance�dict�_pprint_dict)rrrr�	allowance�context�level�objid�rep�	max_width�prrrr:�s0
�zPrettyPrinter._formatc
Csz|j}|d�|jdkr*||jdd�t|�}|rn|jrNt|��td�}	n|��}	|�|	|||d||�|d�dS)N�{r
� ��key�})r;r1rIr8�sorted�itemsr-�_format_dict_items)
rrrrrPrQrRr;Zlengthr]rrrrO�s
�zPrettyPrinter._pprint_dictcCslt|�s|�t|��dS|j}|�|jd�|�t|���||t|j�d|d||�|�d�dS)N�(r
�))rIr;�repr�	__class__r'r:�listr])rrrrrPrQrR�clsrrr�_pprint_ordered_dict�s�z"PrettyPrinter._pprint_ordered_dictcCs0|�d�|�||||d||�|�d�dS)N�[r
�])r;�
_format_items�rrrrrPrQrRrrr�_pprint_list�s
�zPrettyPrinter._pprint_listcCsH|�d�t|�dkrdnd}|�||||t|�||�|�|�dS)Nr_r
z,)r`)r;rIrh)rrrrrPrQrR�endcharrrr�
_pprint_tuple�s
�zPrettyPrinter._pprint_tuplec	Cs�t|�s|�t|��dS|j}|tkr8|�d�d}n&|�|jd�d}|t|j�d7}t|td�}|�||||t|�||�|�|�dS)NrWr[�({�})r
rY)	rIr;rarb�setr'r\rrh)	rrrrrPrQrR�typrkrrr�_pprint_set�s 
�zPrettyPrinter._pprint_setcCs�|j}t|�s|t|��dSg}|�d�}	|dkrD|d7}|d7}|j|}
}t|	�D]�\}}
t|
�}|t|	�dkr�|
|8}
t|�|
kr�|�|�qZt�d|
�}|�	�|}d}t|�D]h\}}||}|t|�dkr�|t|	�dkr�||8}tt|��|k�r"|�r|�t|��|}q�|}q�|rZ|�t|��qZt|�dk�rV||�dS|dk�rh|d�t|�D],\}}|dk�r�|dd|�||��qp|dk�r�|d	�dS)
NTr
z\S*\s*�r_rr9rXr`)
r;rIra�
splitlinesr2�	enumerate�append�re�findall�pop)rrrrrPrQrRr;Zchunks�linesZ
max_width1rU�i�linerT�partsZ
max_width2�current�j�part�	candidaterrr�_pprint_strsT
 


zPrettyPrinter._pprint_strcCs�|j}t|�dkr"|t|��dS|dk}|rF|d7}|d7}|d�d}	t||j||�D]$}
||	�||
�|	s\dd|}	q\|r�|d�dS)N�r
r_rrr9rXr`)r;rIra�_wrap_bytes_reprr2)rrrrrPrQrRr;Zparens�delimrTrrr�
_pprint_bytes3s"zPrettyPrinter._pprint_bytesc	Cs>|j}|d�|�t|�||d|d||d�|d�dS)Nz
bytearray(�
r
r`)r;r��bytes)rrrrrPrQrRr;rrr�_pprint_bytearrayHs�zPrettyPrinter._pprint_bytearraycCs8|�d�|�|��||d|d||�|�d�dS)Nz
mappingproxy(�
r
r`)r;r:�copyrirrr�_pprint_mappingproxyQs
�z"PrettyPrinter._pprint_mappingproxyc	Cs�|j}||j7}dd|}t|�d}	t|�D]f\}
\}}|
|	k}
|�|||�}||�|d�|�|||t|�d|
r�|nd||�|
s0||�q0dS)N�,
rXr
z: r)r;r1rIrtrHr:)rr]rrrPrQrRr;�delimnlZ
last_indexrzrZ�ent�lastrTrrrr^Ys 

�z PrettyPrinter._format_dict_itemscCsL|j}||j7}|jdkr,||jdd�dd|}d}	|j|d}
}t|�}zt|�}
Wntk
rxYdSXd}|�sH|
}zt|�}
Wn(tk
r�d}||8}|
|8}
YnX|j�r|�|||�}t|�d}|
|kr�|}
|	r�|}	|
|k�r|
|8}
||	�d}	||�q~||	�|}	|�	||||�r<|nd||�q~dS)	Nr
rXr�rrFTr�, )
r;r1r2�iter�next�
StopIterationr7rHrIr:)rr]rrrPrQrRr;r�r�rrU�itZnext_entr�r�rT�wrrrrhjsR



�zPrettyPrinter._format_itemscCs4|�||��|j|�\}}}|s&d|_|r0d|_|S)NFT)rAr�r0rGrF)rrrQrRrarCrDrrrrH�s�
zPrettyPrinter._reprcCst|||||j�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.
        )rr8)rrrQ�	maxlevelsrRrrrrA�szPrettyPrinter.formatc	Cs�t|�s|�t|��dS|�|j||�}|j}|t|j�d7}|�d|j|d|f�|�||||d||�|�d�dS)Nr
z	%s(%s,
%srXr`)rIr;rarH�default_factoryrbr'rO)	rrrrrPrQrRZrdfrdrrr�_pprint_default_dict�sz"PrettyPrinter._pprint_default_dictc	Cs�t|�s|�t|��dS|j}|�|jd�|jdkrN|�|jdd�|��}|�|||t|j�d|d||�|�d�dS)Nrmr
rXrrn)rIr;rarbr'r1�most_commonr^)	rrrrrPrQrRrdr]rrr�_pprint_counter�s
�zPrettyPrinter._pprint_counterc
	Cs�t|j�s|�t|��dS|j}|�|jd�|t|j�d7}t|j�D]d\}}	|t|j�dkr�|�|	|||d||�|�d�qN|�|	||d||�|�dd|�qNdS)Nr_r
r`r�rX)rI�mapsr;rarbr'rtr:)
rrrrrPrQrRrdrz�mrrr�_pprint_chain_map�s
zPrettyPrinter._pprint_chain_mapc	Cs�t|�s|�t|��dS|j}|�|jd�|t|j�d7}|�d�|jdkrz|�||||d||�|�d�n:|�|||d||�|�|j||�}|�dd||f�dS)Nr_r
rfrz])z],
%smaxlen=%s)rX)rIr;rarbr'�maxlenrhrH)	rrrrrPrQrRrdZrmlrrr�
_pprint_deque�s&

��zPrettyPrinter._pprint_dequec	Cs|�|j|||||d�dS�Nr
�r:�datarirrr�_pprint_user_dict�szPrettyPrinter._pprint_user_dictc	Cs|�|j|||||d�dSr�r�rirrr�_pprint_user_list�szPrettyPrinter._pprint_user_listc	Cs|�|j|||||d�dSr�r�rirrr�_pprint_user_string�sz!PrettyPrinter._pprint_user_string)r
rNN)2r'r(r)r rrrrr:rJrOrNrLre�_collections�OrderedDictrjrcrl�tuplerqro�	frozensetr�r"r�r�r��	bytearrayr��_types�MappingProxyTyper^rhrHrAr��defaultdictr��Counterr��ChainMapr��dequer��UserDictr��UserListr��
UserStringrrrrrgs^�+




1


)	cCs�t|�}|tkrt|�ddfSt|dd�}t|t��rD|tjk�rD|sJdSt|�}|rl||krldd||kfS||kr�t|�ddfSd||<d}d}	g}
|
j	}|d7}|r�t
|��td�}n|��}|D]b\}
}t
|
||||�\}}}t
|||||�\}}}|d||f�|�o|�o|}|�s$|r�d}	q�||=d	d
�|
�||	fSt|t��r\|tjk�stt|t��rn|tjk�rnt|t��r�|�s�dSd}n"t|�dk�r�d
}n|�s�dSd}t|�}|�r�||k�r�|dd||kfS||k�r�t|�ddfSd||<d}d}	g}
|
j	}|d7}|D]8}t
|||||�\}}}||�|�sFd}|�rd}	�q||=|d
�|
�||	fSt|�}||�o�|�d�dfS)NTFrL)z{}TFz{...}r
rYz%s: %sz{%s}r�)z[]TFz[%s]z(%s,))z()TFz(%s)z...�<)r#�_builtin_scalarsra�getattr�
issubclassrNrLr$rErur\r]r-r�joinrcr�rI�
startswith)rrQr�rRrrp�rrSrCrDZ
componentsrur]�k�vZkreprZ	kreadableZkrecurZvreprZ	vreadableZvrecurrA�oZoreprZ	oreadableZorecurrTrrrr�s�
��
rcCsdt|�jt|�fS)Nz<Recursion on %s with id=%s>)r#r'r$rrrrrE?s�rEcCs�ddl}|dkr,ddddgddd�fgd	}t�}|��}t|iddd
�|��}|�|�|��}td||�td||�dS)
Nr�string)r
r�r���)��i��Tz_safe_repr:zpformat:)�timer�perf_counterrr�print)rr�rV�t1�t2Zt3rrr�
_perfcheckDs
r�ccs�d}t|�dd}tdt|�d�D]T}|||d�}||}||krP||8}tt|��|krt|rnt|�V|}q$|}q$|r�t|�VdS)N�r�r)rI�rangera)rrrPr}r�rzrr�rrrr�Qs
r��__main__)Nr
rN)r
rN)N)$r*�collectionsr�rv�sysr4�typesr��iorr>�__all__rrr	rrrrr-rrr�r"r�r�r.�float�complexr6r#r�rEr�r�r'rrrr�<module>sJ
���F�




Hacked By AnonymousFox1.0, Coded By AnonymousFox