Hacked By AnonymousFox

Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/pprint.cpython-35.opt-1.pyc



��Yf|Q�
@sadZddlZddlZddlZddlZddlm	Z
dddddd	gZdd
dddd
dd�Zd
dddd
dd�Z
dd�Zdd�Zdd�ZGdd�d�Zdd�ZGdd	�d	�Zdd�Zeeeeeeeeed�h�Zdd�Zddd�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��P�compactFcCs8td|d|d|d|d|�}|j|�dS)zAPretty-print a Python object to a stream [default is sys.stdout].�stream�indent�width�depthrN)rr)�objectrr
rrrZprinter�r�+/opt/alt/python35/lib64/python3.5/pprint.pyr/s	c	Cs(td|d|d|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@s7eZdZdZdgZdd�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__cCssy|j|jkSWnXtk
rntt|j��t|j�ftt|j��t|j�fkSYnXdS)N)r�	TypeError�str�type�id)r�otherrrr�__lt__Ws

!z_safe_key.__lt__N)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrrrHs	rcCst|d�t|d�fS)z&Helper function for comparing 2-tuplesrr	)r)�trrr�_safe_tuple^sr%c@sXeZdZdddddddd�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
NrFcCs�t|�}t|�}|dkr0td��|dk	rT|dkrTtd��|sftd��||_||_||_|dk	r�||_ntj|_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rrrrrcs			zPrettyPrinter.__init__cCs3|j||jddid�|jjd�dS)Nr�
)�_formatr+�write)rrrrrr�szPrettyPrinter.pprintcCs/t�}|j||ddid�|j�S)Nr)�	_StringIOr1�getvalue)rrZsiorrrr�s	zPrettyPrinter.pformatcCs|j|idd�dS)Nrr)�format)rrrrrr�szPrettyPrinter.isrecursivecCs,|j|idd�\}}}|o+|S)Nr)r5)rr�s�readable�	recursiverrrr�s!zPrettyPrinter.isreadablec	Cs-t|�}||krA|jt|��d|_d|_dS|j|||�}|j||}	t|�|	kr|jj	t
|�jd�}
|
dk	r�d||<|
|||||||d�||=dSt|t
�rd||<|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
Cs�|j}|d�|jdkr7||jdd�t|�}|r�t|j�dt�}	|j|	|||d||�|d�dS)N�{r	� �key�})r2r)r=�sorted�itemsr%�_format_dict_items)
rrrr
rDrErFr2ZlengthrPrrrrC�s	

zPrettyPrinter._pprint_dictcCs�t|�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�s	
z"PrettyPrinter._pprint_ordered_dictcCs>|jd�|j||||d||�|jd�dS)N�[r	�])r2�
_format_items)rrrr
rDrErFrrr�_pprint_list�s

zPrettyPrinter._pprint_listcCsb|jd�t|�dkr%dnd}|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}|tkrN|jd�d}n1|j|jd�d}|t|j�d7}t|dt�}|j||||t|�||�|j|�dS)NrKrNz({z})r	rM)	r=r2rTrU�setrrOrr[)	rrrr
rDrErF�typr]rrr�_pprint_set�s	
	
zPrettyPrinter._pprint_setcCsM|j}t|�s)|t|��dSg}|jd�}	|dkr^|d7}|d7}|j|}
}xFt|	�D]8\}}
t|
�}|t|	�dkr�|
|8}
t|�|
kr�|j|�q|tjd|
�}|j	�|}d}x�t|�D]�\}}||}|t|�dkrW|t|	�dkrW||8}tt|��|kr�|r�|jt|��|}q|}qW|r||jt|��q|Wt|�dkr�||�dS|dkr�|d�xBt|�D]4\}}|dkr%|dd|�||�q�W|dkrI|d	�dS)
NTr	z\S*\s*�rRrr0rLrS)
r2r=rT�
splitlinesr*�	enumerate�append�re�findall�pop)rrrr
rDrErFr2Zchunks�linesZ
max_width1rI�i�linerH�partsZ
max_width2�current�j�part�	candidaterrr�_pprint_str�sT	




,
	


zPrettyPrinter._pprint_strcCs�|j}t|�dkr/|t|��dS|dk}|r_|d7}|d7}|d�d}	xIt||j||�D].}
||	�||
�|	sdd|}	qW|r�|d�dS)N�r	rRrbr0rLrS)r2r=rT�_wrap_bytes_reprr*)rrrr
rDrErFr2Zparens�delimrHrrr�
_pprint_bytes's"	


 

zPrettyPrinter._pprint_bytescCsO|j}|d�|jt|�||d|d||d�|d�dS)Nz
bytearray(�
r	rS)r2ru�bytes)rrrr
rDrErFr2rrr�_pprint_bytearray<s
	
zPrettyPrinter._pprint_bytearraycCsH|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}	x�t|�D]�\}
\}}|
|	k}
|j|||�}||�|d�|j|||t|�d|
r�|nd||�|
sA||�qAWdS)Nz,
rLr	z: r)r2r)r=rdr<r1)rrPrr
rDrErFr2�delimnlZ
last_indexrjrM�ent�lastrHrrrrQMs	



z PrettyPrinter._format_dict_itemscCs�|j}||j7}|jdkr:||jdd�dd|}d}	|j|d}
}t|�}yt|�}
Wntk
r�dSYnXd}x|s�|
}yt|�}
Wn,tk
r�d}||8}|
|8}
YnX|jrk|j|||�}t|�d}|
|kr8|}
|	r8|}	|
|krk|
|8}
||	�d}	||�q�||	�|}	|j	||||r�|nd||�q�WdS)	Nr	rLz,
rbFTrz, )
r2r)r*�iter�next�
StopIterationr/r<r=r1)rrPrr
rDrErFr2r|rtrrI�itZnext_entr~r}rH�wrrrr[^sN	

		

	



zPrettyPrinter._format_itemscCsL|j||j�|j|�\}}}|s9d|_|rHd|_|S)NFT)r5rzr(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�s	! z"PrettyPrinter._pprint_default_dictc	Cs�t|�s#|jt|��dS|j}|j|jd�|jdkrg|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}x�t|j�D]�\}}	|t|j�dkr�|j|	|||d||�|jd�qj|j|	||d||�|jdd|�qjWdS)NrRr	rSz,
rL)r=�mapsr2rTrUrrdr1)
rrrr
rDrErFrWrj�mrrr�_pprint_chain_map�s	 zPrettyPrinter._pprint_chain_mapc	Cs�t|�s#|jt|��dS|j}|j|jd�|t|j�d7}|jd�|jdkr�|j||||d||�|jd�nO|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)2rr r!rrrrrr1r>rCrBr@rX�_collections�OrderedDictr\rVr^�tuplerar_�	frozensetrqrrurwrx�	bytearrayr{�_types�MappingProxyTyperQr[r<r5r��defaultdictr��Counterr��ChainMapr��dequer��UserDictr��UserListr��
UserStringrrrrrbsZ&




1


)	cCsUt|�}|tkr+t|�ddfSt|dd�}t|t�r�|tjkr�|sedSt|�}|r�||kr�dd||kfS||kr�t|�ddfSd||<d}d}g}	|	j	}
|d7}t
}t|j�dt
�}x�|D]�\}
}||
|||�\}}}|||||�\}}}|
d||f�|ot|ot|}|s�|r	d}q	W||=d	d
j|	�||fSt|t�r�|tjks�t|t�r,|tjkr,t|t�r|sdSd}n+t|�dkr'd
}n|s1dSd}t|�}|rl||krl|dd||kfS||kr�t|�ddfSd||<d}d}g}	|	j	}
|d7}xN|D]F}t
||||�\}}}|
|�|s�d}|r�d}q�W||=|d
j|	�||fSt|�}||oN|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@rr9rerrOrPr%�joinrVr�r=�
startswith)rrEr�rFr`�rrGr7r8Z
componentsrerrP�k�vZkreprZ	kreadableZkrecurZvreprZ	vreadableZvrecurr5�oZoreprZ	oreadableZorecurrHrrrr�s|
	

		
	



rcCsdt|�jt|�fS)Nz<Recursion on %s with id=%s>)rrr)rrrrr91sr9cCs�ddl}|dkrCddddgddd	d
ifgd}t�}|j�}t|idd�|j�}|j|�|j�}td||�td
||�dS)Nr�stringr	r�rr����i��z_safe_repr:zpformat:)r	r)�timerrr�print)rr�rJZt1Zt2Zt3rrr�
_perfcheck6s+	
r�ccs�d}t|�dd}x�tdt|�d�D]r}|||d�}||}||krm||8}tt|��|kr�|r�t|�V|}q3|}q3W|r�t|�VdS)N�rrr)r=�rangerT)rrrDrmr~rjrorprrrrsCs

	
rs�__main__)#r"�collectionsr�rf�sysr,�typesr��iorr3�__all__rrrrrrr%rrr�rrwr�r&�float�complexr.rr�r9r�rsrrrrr�<module>#s2	��D


Hacked By AnonymousFox1.0, Coded By AnonymousFox