MINI MINI MANI MO

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

3


 \|Q
@sdZddlZddlZddlZddlZddlm	Z
dddddd	gZd!dd
ddZd"dd
ddZ
ddZddZddZGdddZddZGdd	d	ZddZeeeeeeeeedhZddZd#ddZ ddZ!e"d kre 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)StringIOpprintpformat
isreadableisrecursivesaferepr
PrettyPrinterPF)compactcCs t|||||d}|j|dS)zAPretty-print a Python object to a stream [default is sys.stdout].)streamindentwidthdepthrN)rr)objectrr
rrrZprinterr/usr/lib64/python3.6/pprint.pyr/scCst||||dj|S)z<Format a Python object into a pretty-printed representation.)r
rrr)rr)rr
rrrrrrr7scCst|idddS)z=Version of repr() which can handle recursive data structures.Nr)
_safe_repr)rrrrr<scCst|idddS)z4Determine if saferepr(object) is readable by eval().Nrr	)r)rrrrr@scCst|idddS)z8Determine if object requires a recursive representation.Nr)r)rrrrrDsc@s&eZdZdZdgZddZddZdS)	_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|jt|jftt|jt|jfkSXdS)N)r	TypeErrorstrtypeid)rotherrrr__lt__Ws
z_safe_key.__lt__N)__name__
__module____qualname____doc__	__slots__rrrrrrrHsrcCst|dt|dfS)z&Helper function for comparing 2-tuplesrr	)r)trrr_safe_tuple^sr%c@seZdZd:ddddZdd	Zd
dZdd
ZddZddZiZ	ddZ
e
e	ej<ddZ
e
e	ejj<ddZee	ej<ddZee	ej<ddZee	ej<ee	ej<ddZee	ej<ddZee	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<d0d1Z(e(e	ej)j<d2d3Z*e*e	ej+j<d4d5Z,e,e	ej-j<d6d7Z.e.e	ej/j<d8d9Z0e0e	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_sysstdoutbool_compact)rr
rrrrrrrrcszPrettyPrinter.__init__cCs&|j||jddid|jjddS)Nr
)_formatr+write)rrrrrrszPrettyPrinter.pprintcCs"t}|j||ddid|jS)Nr)	_StringIOr1getvalue)rrZsiorrrrszPrettyPrinter.pformatcCs|j|idddS)Nrr)format)rrrrrrszPrettyPrinter.isrecursivecCs |j|idd\}}}|o|S)Nr)r5)rrsreadable	recursiverrrrszPrettyPrinter.isreadablec	Cst|}||kr.|jt|d|_d|_dS|j|||}|j||}	t||	kr|jj	t
|jd}
|
dk	rd||<|
|||||||d||=dSt|t
rd||<|j||||||d||=dS|j|dS)NTFr	)rr2
_recursion
_recursive	_readable_reprr*len	_dispatchgetr__repr__
isinstancedict_pprint_dict)rrrr
	allowancecontextlevelobjidrep	max_widthprrrr1s,
zPrettyPrinter._formatc
Csj|j}|d|jdkr*||jddt|}|r^t|jtd}	|j|	|||d|||ddS)N{r	 )key})r2r)r=sorteditemsr%_format_dict_items)
rrrr
rDrErFr2ZlengthrPrrrrCs
zPrettyPrinter._pprint_dictcCslt|s|jt|dS|j}|j|jd|jt|j||t|jd|d|||jddS)N(r	))r=r2repr	__class__rr1listrP)rrrr
rDrErFclsrrr_pprint_ordered_dictsz"PrettyPrinter._pprint_ordered_dictcCs0|jd|j||||d|||jddS)N[r	])r2
_format_items)rrrr
rDrErFrrr_pprint_lists
zPrettyPrinter._pprint_listcCsH|jdt|dkrdnd}|j||||t||||j|dS)NrRr	z,)rS)r2r=r[)rrrr
rDrErFendcharrrr
_pprint_tuples

zPrettyPrinter._pprint_tuplec	Cst|s|jt|dS|j}|tkr8|jdd}n&|j|jdd}|t|jd7}t|td}|j||||t||||j|dS)NrKrNz({z})r	)rM)	r=r2rTrUsetrrOrr[)	rrrr
rDrErFtypr]rrr_pprint_sets
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|
}|st	|d
st	|j
|}d}xxt|D]l\}}||}|t|dkr|t|	dkr||8}tt||krD|r>|jt||}q|}qW|r^|jt|q^Wt|dkr|||dS|dkr|dx8t|D],\}}|dkr|dd|||qW|dkr|d	dS)NTr	z\S*\s*rRrr0rLrS)r2r=rT
splitlinesr*	enumerateappendrefindallAssertionErrorpop)rrrr
rDrErFr2ZchunkslinesZ
max_width1rIilinerHpartsZ
max_width2currentjpart	candidaterrr_pprint_strsX
$


zPrettyPrinter._pprint_strcCs|j}t|dkr"|t|dS|dk}|rF|d7}|d7}|dd}	x:t||j||D]$}
||	||
|	s^dd|}	q^W|r|ddS)Nr	rRrbr0rLrS)r2r=rT_wrap_bytes_reprr*)rrrr
rDrErFr2ZparensdelimrHrrr
_pprint_bytes's"zPrettyPrinter._pprint_bytescCs>|j}|d|jt|||d|d||d|ddS)Nz
bytearray(
r	rS)r2rwbytes)rrrr
rDrErFr2rrr_pprint_bytearray<s
zPrettyPrinter._pprint_bytearraycCs8|jd|j|j||d|d|||jddS)Nz
mappingproxy(
r	rS)r2r1copy)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
rDrErFr2delimnlZ
last_indexrlrMentlastrHrrrrQMs

z PrettyPrinter._format_dict_itemscCsN|j}||j7}|jdkr,||jdddd|}d}	|j|d}
}t|}yt|}
Wntk
rvdSXd}x|sH|
}yt|}
Wn(tk
rd}||8}|
|8}
YnX|jr|j|||}t|d}|
|kr|}
|	r|}	|
|kr|
|8}
||	d}	||q~||	|}	|j	||||r<|nd||q~WdS)	Nr	rLz,
rbFTrz, )
r2r)r*iternext
StopIterationr/r<r=r1)rrPrr
rDrErFr2r~rvrrIitZnext_entrrrHwrrrr[^sN



zPrettyPrinter._format_itemscCs4|j||j|j|\}}}|s&d|_|r0d|_|S)NFT)r5r|r(r;r:)rrrErFrTr7r8rrrr<szPrettyPrinter._reprcCst||||S)zFormat 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	maxlevelsrFrrrr5szPrettyPrinter.formatc	Cst|s|jt|dS|j|j||}|j}|t|jd7}|jd|j|d|f|j||||d|||jddS)Nr	z	%s(%s,
%srLrS)r=r2rTr<default_factoryrUrrC)	rrrr
rDrErFZrdfrWrrr_pprint_default_dictsz"PrettyPrinter._pprint_default_dictc	Cst|s|jt|dS|j}|j|jd|jdkrN|j|jdd|j}|j|||t|jd|d|||jddS)Nz({r	rLrz}))r=r2rTrUrr)most_commonrQ)	rrrr
rDrErFrWrPrrr_pprint_counters
zPrettyPrinter._pprint_counterc
Cst|js|jt|dS|j}|j|jd|t|jd7}xrt|jD]d\}}	|t|jdkr|j|	|||d|||jdqP|j|	||d|||jdd|qPWdS)NrRr	rSz,
rL)r=mapsr2rTrUrrer1)
rrrr
rDrErFrWrlmrrr_pprint_chain_maps
zPrettyPrinter._pprint_chain_mapc	Cst|s|jt|dS|j}|j|jd|t|jd7}|jd|jdkrz|j||||d|||jdn:|j|||d|||j|j||}|jdd||fdS)NrRr	rYrz])z],
%smaxlen=%s)rL)r=r2rTrUrmaxlenr[r<)	rrrr
rDrErFrWZrmlrrr
_pprint_deques

zPrettyPrinter._pprint_dequecCs|j|j|||||ddS)Nr	)r1data)rrrr
rDrErFrrr_pprint_user_dictszPrettyPrinter._pprint_user_dictcCs|j|j|||||ddS)Nr	)r1r)rrrr
rDrErFrrr_pprint_user_listszPrettyPrinter._pprint_user_listcCs|j|j|||||ddS)Nr	)r1r)rrrr
rDrErFrrr_pprint_user_stringsz!PrettyPrinter._pprint_user_string)r	r
NN)2rr r!rrrrrr1r>rCrBr@rX_collectionsOrderedDictr\rVr^tuplerar_	frozensetrsrrwryrz	bytearrayr}_typesMappingProxyTyperQr[r<r5rdefaultdictrCounterrChainMaprdequerUserDictrUserListr
UserStringrrrrrbsZ&




1


)	cCst|}|tkrt|ddfSt|dd}t|to<|tjkr8|sHdSt|}|rj||krjdd||kfS||krt|ddfSd||<d}d}g}	|	j	}
|d7}t
}t|jt
d}xf|D]^\}
}||
|||\}}}|||||\}}}|
d||f|o
|o
|}|s|rd}qW||=d	d
j|	||fSt|trP|tjksht|trd|tjkrdt|tr|s~dSd}n"t|dkrd
}n|sdSd}t|}|r||kr|dd||kfS||krt|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...<)rTF)rTF)rTF)r_builtin_scalarsrTgetattr
issubclassrBr@rr9rfrrOrPr%joinrVrr=
startswith)rrErrFr`rrGr7r8Z
componentsrfrrPkvZkreprZ	kreadableZkrecurZvreprZ	vreadableZvrecurr5oZoreprZ	oreadableZorecurrHrrrrs|



rcCsdt|jt|fS)Nz<Recursion on %s with id=%s>)rrr)rrrrr91sr9cCsddl}|dkr,dd
ddgddd	fgd
}t}|j}t|idd|j}|j||j}td||td||dS)Nrstringr	rrt)iz_safe_repr:zpformat:)r	r)timerrrprint)rrrJZt1Zt2Zt3rrr
_perfcheck6s
rccsd}t|dd}xhtdt|dD]T}|||d}||}||krR||8}tt||krv|rpt|V|}q&|}q&W|rt|VdS)Nrtr)r=rangerT)rrrDrorrlrqrrrrrruCs
ru__main__)Nr	r
N)r	r
N)N)#r"collectionsrrgsysr,typesriorr3__all__rrrrrrr%rrrrryrr&floatcomplexr.rrr9rrurrrrr<module>#s6
D



OHA YOOOO