AlkantarClanX12

Your IP : 18.116.86.160


Current Path : /lib64/python3.6/__pycache__/
Upload File :
Current File : //lib64/python3.6/__pycache__/pprint.cpython-36.pyc

3


 \|Q�
@s�dZddlZddlZddlZddlZddlm	Z
dddddd	gZd!dd
�dd�Zd"dd
�dd�Z
dd�Zdd�Zdd�ZGdd�d�Zdd�ZGdd	�d	�Zdd�Zeeeeeeeeed�h�Zdd�Zd#dd�Z dd�Z!e"d kr�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��PF)�compactcCs t|||||d�}|j|�dS)zAPretty-print a Python object to a stream [default is sys.stdout].)�stream�indent�width�depthrN)rr)�objectrr
rrrZprinter�r�/usr/lib64/python3.6/pprint.pyr/scCst||||d�j|�S)z<Format a Python object into a pretty-printed representation.)r
rrr)rr)rr
rrrrrrr7scCst|idd�dS)z=Version of repr() which can handle recursive data structures.Nr)�
_safe_repr)rrrrr<scCst|idd�dS)z4Determine if saferepr(object) is readable by eval().Nrr	)r)rrrrr@scCst|idd�dS)z8Determine if object requires a recursive representation.Nr�)r)rrrrrDsc@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__Tsz_safe_key.__init__cCsRy|j|jkStk
rLtt|j��t|j�ftt|j��t|j�fkSXdS)N)r�	TypeError�str�type�id)r�otherrrr�__lt__Ws
z_safe_key.__lt__N)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrrrHsrcCst|d�t|d�fS)z&Helper function for comparing 2-tuplesrr	)r)�trrr�_safe_tuple^sr%c@s�eZdZd:dd�dd�Zdd	�Zd
d�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.d/�Z&e&e	ej'j<d0d1�Z(e(e	ej)j<d2d3�Z*e*e	ej+j<d4d5�Z,e,e	ej-j<d6d7�Z.e.e	ej/j<d8d9�Z0e0e	ej1j<dS);rr	r
NF)rcCs|t|�}t|�}|dkr td��|dk	r8|dkr8td��|sDtd��||_||_||_|dk	rf||_ntj|_t|�|_	dS)aDHandle 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.

        rzindent must be >= 0Nzdepth must be > 0zwidth must be != 0)
�int�
ValueError�_depth�_indent_per_level�_width�_stream�_sys�stdout�bool�_compact)rr
rrrrrrrrcszPrettyPrinter.__init__cCs&|j||jddid�|jjd�dS)Nr�
)�_formatr+�write)rrrrrr�szPrettyPrinter.pprintcCs"t�}|j||ddid�|j�S)Nr)�	_StringIOr1�getvalue)rrZsiorrrr�szPrettyPrinter.pformatcCs|j|idd�dS)Nrr)�format)rrrrrr�szPrettyPrinter.isrecursivecCs |j|idd�\}}}|o|S)Nr)r5)rr�s�readable�	recursiverrrr�szPrettyPrinter.isreadablec	Cs�t|�}||kr.|jt|��d|_d|_dS|j|||�}|j||}	t|�|	kr�|jj	t
|�jd�}
|
dk	r�d||<|
|||||||d�||=dSt|t
�r�d||<|j||||||d�||=dS|j|�dS)NTFr	)rr2�
_recursion�
_recursive�	_readable�_reprr*�len�	_dispatch�getr�__repr__�
isinstance�dict�_pprint_dict)rrrr
�	allowance�context�level�objid�rep�	max_width�prrrr1�s,
zPrettyPrinter._formatc
Csj|j}|d�|jdkr*||jdd�t|�}|r^t|j�td�}	|j|	|||d||�|d�dS)N�{r	� )�key�})r2r)r=�sorted�itemsr%�_format_dict_items)
rrrr
rDrErFr2ZlengthrPrrrrC�s
zPrettyPrinter._pprint_dictcCslt|�s|jt|��dS|j}|j|jd�|jt|j��||t|j�d|d||�|jd�dS)N�(r	�))r=r2�repr�	__class__rr1�listrP)rrrr
rDrErF�clsrrr�_pprint_ordered_dict�sz"PrettyPrinter._pprint_ordered_dictcCs0|jd�|j||||d||�|jd�dS)N�[r	�])r2�
_format_items)rrrr
rDrErFrrr�_pprint_list�s
zPrettyPrinter._pprint_listcCsH|jd�t|�dkrdnd}|j||||t|�||�|j|�dS)NrRr	z,)rS)r2r=r[)rrrr
rDrErF�endcharrrr�
_pprint_tuple�s

zPrettyPrinter._pprint_tuplec	Cs�t|�s|jt|��dS|j}|tkr8|jd�d}n&|j|jd�d}|t|j�d7}t|td�}|j||||t|�||�|j|�dS)NrKrNz({z})r	)rM)	r=r2rTrU�setrrOrr[)	rrrr
rDrErF�typr]rrr�_pprint_set�s
zPrettyPrinter._pprint_setcCs�|j}t|�s|t|��dSg}|jd�}	|dkrD|d7}|d7}|j|}
}�xt|	�D�]�\}}
t|
�}|t|	�dkr�|
|8}
t|�|
kr�|j|�q^tjd|
�}|s�t	�|d
s�t	�|j
�|}d}xxt|�D]l\}}||}|t|�dk�r|t|	�dk�r||8}tt|��|k�rD|�r>|jt|��|}q�|}q�W|r^|jt|��q^Wt|�dk�r|||�dS|dk�r�|d�x8t|�D],\}}|dk�r�|dd|�||��q�W|dk�r�|d	�dS)NTr	z\S*\s*�rRrr0rLrS���)r2r=rT�
splitlinesr*�	enumerate�append�re�findall�AssertionError�pop)rrrr
rDrErFr2Zchunks�linesZ
max_width1rI�i�linerH�partsZ
max_width2�current�j�part�	candidaterrr�_pprint_str�sX
$


zPrettyPrinter._pprint_strcCs�|j}t|�dkr"|t|��dS|dk}|rF|d7}|d7}|d�d}	x:t||j||�D]$}
||	�||
�|	s^dd|}	q^W|r�|d�dS)N�r	rRrbr0rLrS)r2r=rT�_wrap_bytes_reprr*)rrrr
rDrErFr2Zparens�delimrHrrr�
_pprint_bytes's"zPrettyPrinter._pprint_bytescCs>|j}|d�|jt|�||d|d||d�|d�dS)Nz
bytearray(�
r	rS)r2rw�bytes)rrrr
rDrErFr2rrr�_pprint_bytearray<s
zPrettyPrinter._pprint_bytearraycCs8|jd�|j|j�||d|d||�|jd�dS)Nz
mappingproxy(�
r	rS)r2r1�copy)rrrr
rDrErFrrr�_pprint_mappingproxyEs
z"PrettyPrinter._pprint_mappingproxycCs�|j}||j7}dd|}t|�d}	xrt|�D]f\}
\}}|
|	k}
|j|||�}||�|d�|j|||t|�d|
r�|nd||�|
s2||�q2WdS)Nz,
rLr	z: r)r2r)r=rer<r1)rrPrr
rDrErFr2�delimnlZ
last_indexrlrM�ent�lastrHrrrrQMs

z PrettyPrinter._format_dict_itemscCsN|j}||j7}|jdkr,||jdd�dd|}d}	|j|d}
}t|�}yt|�}
Wntk
rvdSXd}x�|�sH|
}yt|�}
Wn(tk
r�d}||8}|
|8}
YnX|j�r|j|||�}t|�d}|
|kr�|}
|	r�|}	|
|k�r|
|8}
||	�d}	||�q~||	�|}	|j	||||�r<|nd||�q~WdS)	Nr	rLz,
rbFTrz, )
r2r)r*�iter�next�
StopIterationr/r<r=r1)rrPrr
rDrErFr2r~rvrrI�itZnext_entr�rrH�wrrrr[^sN



zPrettyPrinter._format_itemscCs4|j||j�|j|�\}}}|s&d|_|r0d|_|S)NFT)r5r|r(r;r:)rrrErFrTr7r8rrrr<�szPrettyPrinter._reprcCst||||�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)rrrE�	maxlevelsrFrrrr5�szPrettyPrinter.formatc	Cs�t|�s|jt|��dS|j|j||�}|j}|t|j�d7}|jd|j|d|f�|j||||d||�|jd�dS)Nr	z	%s(%s,
%srLrS)r=r2rTr<�default_factoryrUrrC)	rrrr
rDrErFZrdfrWrrr�_pprint_default_dict�sz"PrettyPrinter._pprint_default_dictc	Cs�t|�s|jt|��dS|j}|j|jd�|jdkrN|j|jdd�|j�}|j|||t|j�d|d||�|jd�dS)Nz({r	rLrz}))r=r2rTrUrr)�most_commonrQ)	rrrr
rDrErFrWrPrrr�_pprint_counter�s
zPrettyPrinter._pprint_counterc
Cs�t|j�s|jt|��dS|j}|j|jd�|t|j�d7}xrt|j�D]d\}}	|t|j�dkr�|j|	|||d||�|jd�qP|j|	||d||�|jdd|�qPWdS)NrRr	rSz,
rL)r=�mapsr2rTrUrrer1)
rrrr
rDrErFrWrl�mrrr�_pprint_chain_map�s
zPrettyPrinter._pprint_chain_mapc	Cs�t|�s|jt|��dS|j}|j|jd�|t|j�d7}|jd�|jdkrz|j||||d||�|jd�n:|j|||d||�|j|j||�}|jdd||f�dS)NrRr	rYrz])z],
%smaxlen=%s)rL)r=r2rTrUr�maxlenr[r<)	rrrr
rDrErFrWZrmlrrr�
_pprint_deque�s

zPrettyPrinter._pprint_dequecCs|j|j|||||d�dS)Nr	)r1�data)rrrr
rDrErFrrr�_pprint_user_dict�szPrettyPrinter._pprint_user_dictcCs|j|j|||||d�dS)Nr	)r1r�)rrrr
rDrErFrrr�_pprint_user_list�szPrettyPrinter._pprint_user_listcCs|j|j|||||d�dS)Nr	)r1r�)rrrr
rDrErFrrr�_pprint_user_string�sz!PrettyPrinter._pprint_user_string)r	r
NN)2rr r!rrrrrr1r>rCrBr@rX�_collections�OrderedDictr\rVr^�tuplerar_�	frozensetrsrrwryrz�	bytearrayr}�_types�MappingProxyTyperQr[r<r5r��defaultdictr��Counterr��ChainMapr��dequer��UserDictr��UserListr��
UserStringrrrrrbsZ&




1


)	cCs�t|�}|tkrt|�ddfSt|dd�}t|t�o<|tjk�r8|sHdSt|�}|rj||krjdd||kfS||kr�t|�ddfSd||<d}d}g}	|	j	}
|d7}t
}t|j�t
d�}xf|D]^\}
}||
|||�\}}}|||||�\}}}|
d||f�|�o
|�o
|}|�s|r�d}q�W||=d	d
j|	�||fSt|t��rP|tjk�sht|t��rd|tjk�rdt|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}x>|D]6}t
||||�\}}}|
|�|�s:d}|�rd}�qW||=|d
j|	�||fSt|�}||�o~|jd�dfS)NTFr@�{}z{...}r	)rMz%s: %sz{%s}z, �[]z[%s]z(%s,)�()z(%s)z...�<)r�TF)r�TF)r�TF)r�_builtin_scalarsrT�getattr�
issubclassrBr@rr9rfrrOrPr%�joinrVr�r=�
startswith)rrEr�rFr`�rrGr7r8Z
componentsrfrrP�k�vZkreprZ	kreadableZkrecurZvreprZ	vreadableZvrecurr5�oZoreprZ	oreadableZorecurrHrrrr�s|



rcCsdt|�jt|�fS)Nz<Recursion on %s with id=%s>)rrr)rrrrr91sr9cCs�ddl}|dkr,dd
ddgddd	�fgd
}t�}|j�}t|idd�|j�}|j|�|j�}td||�td||�dS)Nr�stringr	r�rt��)��i��z_safe_repr:zpformat:)r	r)�timerrr�print)rr�rJZt1Zt2Zt3rrr�
_perfcheck6s
r�ccs�d}t|�dd}xhtdt|�d�D]T}|||d�}||}||krR||8}tt|��|krv|rpt|�V|}q&|}q&W|r�t|�VdS)N�rtr)r=�rangerT)rrrDror�rlrqrrrrrruCs
ru�__main__)Nr	r
N)r	r
N)N)#r"�collectionsr�rg�sysr,�typesr��iorr3�__all__rrrrrrr%rrr�rryr�r&�float�complexr.rr�r9r�rurrrrr�<module>#s6
D