AlkantarClanX12

Your IP : 3.145.50.71


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/pprint.cpython-34.pyo

�
e fG:�@s&dZddlZddlZddlmZddlmZ	ddddd	d
gZ
ddddd
ddd�Zdddd
ddd�Zdd	�Z
dd�Zdd�ZGdd�d�Zdd�ZGdd
�d
�Zdd�Zdd�Zddd�Zedkr"e�ndS) 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)�OrderedDict)�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�depthrN)r	r)�objectr
rrrrZprinter�r�+/opt/alt/python34/lib64/python3.4/pprint.pyr.s	c	Cs(td|d|d|d|�j|�S)z<Format a Python object into a pretty-printed representation.rrrr)r	r)rrrrrrrrr6scCst|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)rrrrrCsc@s7eZdZdZdgZdd�Zdd�ZdS)�	_safe_keyaVHelper function for key functions when sorting unorderable objects.

    The wrapped-object will fallback to an 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__Ssz_safe_key.__init__cCs�y|jj|j�}Wntk
r3t}YnX|tkr�tt|j��t|j�ftt|j��t|j�fk}n|S)N)r�__lt__�	TypeError�NotImplemented�str�type�id)r�other�rvrrrrVs
!*z_safe_key.__lt__N)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrrrGs	rcCst|d�t|d�fS)z&Helper function for comparing 2-tuplesrr
)r)�trrr�_safe_tupleasr(c@s�eZdZdddddddd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Z	dd�Z
dd�ZdS)r	r
rNrFcCsjt|�}t|�}||_||_||_|dk	rK||_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.

        N)	�int�_depth�_indent_per_level�_width�_stream�_sys�stdout�bool�_compact)rrrrr
rrrrrfs			zPrettyPrinter.__init__cCs3|j||jddid�|jjd�dS)Nr�
)�_formatr-�write)rrrrrr�szPrettyPrinter.pprintcCs/t�}|j||ddid�|j�S)Nr)�	_StringIOr3�getvalue)rr�siorrrr�s	zPrettyPrinter.pformatcCs|j|idd�dS)Nrr)�format)rrrrrr�szPrettyPrinter.isrecursivecCs,|j|idd�\}}}|o+|S)Nr)r8)rr�s�readable�	recursiverrrr�s!zPrettyPrinter.isreadablecCsv|d}t|�}||krK|jt|��d|_d|_dS|j|||d�}t|�}	|jd||}
t|�|
k}|j}|rht	|	dd�}
t
|	t�rt|d�|jdkr�||jdd�nt|�}|rfd||<||j}t
|	t
�rEt|j��}nt|j�dt�}|d\}}|j|||�}||�|d	�|j|||t|�d
|d||�|dkrOx||dd�D]g\}}|j|||�}|dd||f�|j|||t|�d
|d||�q�Wn||j}||=n|d�dSt
|	t�r�|
tjks�t
|	t�r�|
tjks�t
|	t�r�|
tjks�t
|	t�rS|
tjkrSt|�}t
|	t�r|d
�d}n�t
|	t�r<|d�d}ny|sP||�dS|	tkro|d�d}n4||	j�|d�d}|t|	j�d7}t|dt�}|jdkr�||jdd�n|rd||<|j||||j|d||�||=nt
|	t�rE|dkrE|d�n||�dSt
|	t�rht|�dkrh|
tjkrhg}|jd�}|dkr�|d7}|
d
8}
nx	t|�D]�\}}t|�}t|�|
kr|j|�q�tj d|�dg}d}x�t!dt|�d
�D]i}||||d}||}tt|��|
kr�|r�|jt|��n|}q:|}q:W|r�|jt|��q�q�Wt|�dkr�||�dS|dkr|d�nxEt|�D]7\}}|dkr:|dd|�n||�q
W|dkra|d�ndSn||�dS)Nr
TF�__repr__�{� �keyrz: rz,
%s%s: �}�[�]�(�)z({z})�,z(\s+)�r2)"rr4�
_recursion�
_recursive�	_readable�_reprrr,�len�getattr�
issubclass�dictr+�_OrderedDict�list�items�sortedr(r3r<�tuple�set�	frozensetr"r�
_format_itemsr�
splitlines�	enumerate�repr�append�re�split�range)rrr
r�	allowance�context�level�objid�rep�typ�	max_widthZsepLinesr4�rZlengthrQr?�entZendcharZchunks�lines�i�line�partsZcurrent�part�	candidaterrrr3�s�
			








	
	

	






0


	



zPrettyPrinter._formatcCs|j}dd|}d}	|j||d}
}x�|D]�}|jr�|j|||�}
t|
�d}|
|kr�|}
|	r�|}	q�n|
|kr�|
|8}
||	�d}	||
�q=q�n||	�|}	|j||||||�q=WdS)Nz,
r>rFrz, )r4r,r1rJrKr3)rrQr
rr^r_r`r4ZdelimnlZdelimrrdrfrb�wrrrrVs*	
	


	
zPrettyPrinter._format_itemscCsR|j||j�|j|�\}}}|s<d|_n|rNd|_n|S)NFT)r8�copyr*rIrH)rrr_r`rYr:r;rrrrJ+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)rrr_�	maxlevelsr`rrrr84szPrettyPrinter.format)r"r#r$rrrrrr3rVrJr8rrrrr	es#z	c!Cs6t|�}|tkrdtjkr:t|�ddfSd|krhd|krhd}idd6}nd}idd6}|j}t�}|j}	xJ|D]B}
|
j�r�|	|
�q�|	||
t|
�dd���q�Wd	||j	�|fddfSt
|d
d�}t|t�r�|tj
kr�|s=dSt|�}|rn||krndd||kfS||kr�t|�ddfSd||<d}
d}g}|j}|d7}t}t|j�d
t�}x�|D]�\}}|||||�\}}}|||||�\}}}|d||f�|
oL|oL|}
|s[|r�d}q�q�W||=ddj|�|
|fSt|t�r�|tj
ks�t|t�r
|tj
kr
t|t�r�|s�dSd}n+t|�dkrd}n|sdSd}t|�}|rG||krG|dd||kfS||krft|�ddfSd||<d}
d}g}|j}|d7}xT|D]L}t||||�\}}}||�|s�d}
n|r�d}q�q�W||=|dj|�|
|fSt|�} | | o/| jd�dfS)NZlocaleTF�'�"z\"z\'r
z%s%s%sr<�{}z{...}r?z%s: %sz{%s}z, �[]z[%s]z(%s,)�()z(%s)z...�<���)rrTF)rsTF)rtTF)rrr.�modulesrY�getr5r4�isalphar6rLrMrNr<rrGrZrrRrQr(�joinrPrSrK�
startswith)!rr_ror`rcZclosureZquotesZqgetr7r4�charrerar:r;Z
componentsrZrrQ�k�vZkreprZ	kreadableZkrecurZvreprZ	vreadableZvrecurr8�oZoreprZ	oreadableZorecurrbrrrr>s�
			

' 
	

		
	


	
rcCsdt|�jt|�fS)Nz<Recursion on %s with id=%s>)rr"r)rrrrrG�srGcCs�ddl}|dkrHddddgidd6d	d
6fgd}nt�}|j�}t|idd�|j�}|j|�|j�}td||�td
||�dS)Nr�stringr
r������i��z_safe_repr:zpformat:)r
r)�timer	rr�print)rr��pZt1Zt2Zt3rrr�
_perfcheck�s0	
r��__main__)r%r[�sysr.�collectionsrrO�iorr5�__all__rrrrrrr(r	rrGr�r"rrrr�<module>#s(	�U