ó zfc@sdZddlZddlZyddlmZWn!ek rUddlmZnXdddddd gZd j Z e Z e ZeZdd d dd „Zd d dd„Zd„Zd„Zd„Zd„Zd dd„ƒYZd„Zd„Zdd„ZedkreƒndS(s/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. iÿÿÿÿN(tStringIOtpprinttpformatt isreadablet isrecursivetsafereprt PrettyPrinters, iiPc Cs2td|d|d|d|ƒ}|j|ƒdS(sAPretty-print a Python object to a stream [default is sys.stdout].tstreamtindenttwidthtdepthN(RR(tobjectRRR R tprinter((s/usr/lib64/python2.7/pprint.pyR7scCs"td|d|d|ƒj|ƒS(s<Format a Python object into a pretty-printed representation.RR R (RR(R RR R ((s/usr/lib64/python2.7/pprint.pyR=scCst|iddƒdS(s=Version of repr() which can handle recursive data structures.iN(t _safe_reprtNone(R ((s/usr/lib64/python2.7/pprint.pyRAscCst|iddƒdS(s4Determine if saferepr(object) is readable by eval().iiN(R R(R ((s/usr/lib64/python2.7/pprint.pyREscCst|iddƒdS(s8Determine if object requires a recursive representation.iiN(R R(R ((s/usr/lib64/python2.7/pprint.pyRIscCs@tjƒ.tjr,tjddtƒnt|ƒSWdQXdS(Ntignores%comparing unequal types not supported(twarningstcatch_warningst_syst py3kwarningtfilterwarningstDeprecationWarningtsorted(titerable((s/usr/lib64/python2.7/pprint.pyt_sortedMs     cBs\eZddd d d„Zd„Zd„Zd„Zd„Zd„Zd„Z d „Z RS( iiPcCs©t|ƒ}t|ƒ}|dks0tdƒ‚|dksT|dksTtdƒ‚|sftdƒ‚||_||_||_|dk r™||_n tj|_dS(sò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. isindent must be >= 0sdepth must be > 0swidth must be != 0N( tinttAssertionErrorRt_deptht_indent_per_levelt_widtht_streamRtstdout(tselfRR R R((s/usr/lib64/python2.7/pprint.pyt__init__Us  $     cCs3|j||jddidƒ|jjdƒdS(Nis (t_formatRtwrite(R R ((s/usr/lib64/python2.7/pprint.pyRtscCs/tƒ}|j||ddidƒ|jƒS(Ni(t _StringIOR"tgetvalue(R R tsio((s/usr/lib64/python2.7/pprint.pyRxs cCs|j|iddƒdS(Nii(tformat(R R ((s/usr/lib64/python2.7/pprint.pyR}scCs,|j|iddƒ\}}}|o+| S(Ni(R'(R R tstreadablet recursive((s/usr/lib64/python2.7/pprint.pyR€s!cCsÒ|d}t|ƒ}||krK|jt|ƒƒt|_t|_dS|j|||dƒ}t|ƒ} t |ƒ|j d||k} |j} |j rÀ||j krÀ| |ƒdSt | ddƒ} t| tƒr„| tjkr„| dƒ|jdkr!| |jddƒnt |ƒ} | rvd||<||j}t|jƒƒ}|d\}}|j|||ƒ}| |ƒ| dƒ|j|||t |ƒd|d||ƒ| dkr_x|dD]~\}}|j|||ƒ}| r| dd||fƒn| d |ƒ|j|||t |ƒd|d||ƒqÚWn||j}||=n| d ƒdSt| tƒr¢| tjksüt| tƒrÀ| tjksüt| tƒrÞ| tjksüt| tƒrÄ| tjkrÄt |ƒ} t| tƒr*| d ƒd }nvt| tƒrL| d ƒd}nT| s`| |ƒdS| | jƒ| dƒd}|t| jƒd7}t|ƒ}|jdkrÍ| rÍ| |jddƒn| rŽd||<||j}|j|d|||d||ƒ| dkrwxZ|dD]K}| rF| dd|ƒn | dƒ|j||||d||ƒq%Wn||j}||=nt| tƒr¶| dkr¶| dƒn| |ƒdS| |ƒdS(Nit__repr__t{t is: is, %s%s: s, %s: t}t[t]t(t)s([s])s, s, t,(t_idR#t _recursiontTruet _recursivetFalset _readablet_reprt_typet_lenRRtgetattrRt issubclasstdictR+RRtitemsR"tlistttupletsett frozensett__name__tlen(R R RRt allowancetcontexttleveltobjidtrepttyptsepLinesR#trtlengthR@tkeytenttendchar((s/usr/lib64/python2.7/pprint.pyR"„s¤      !                              cCsR|j||jƒ|j|ƒ\}}}|s<t|_n|rNt|_n|S(N(R'tcopyRR8R9R6R7(R R RHRItreprR)R*((s/usr/lib64/python2.7/pprint.pyR:às  cCst||||ƒS(sÈ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 (R R RHt maxlevelsRI((s/usr/lib64/python2.7/pprint.pyR'ésN( REt __module__RR!RRRRR"R:R'(((s/usr/lib64/python2.7/pprint.pyRTs     \ c Cs<t|ƒ}|tkrdtjkr:t|ƒttfSd|krhd|krhd}idd6}nd}idd6}|j}tƒ}|j } xG|D]?} | j ƒr¼| | ƒq| || t| ƒdd!ƒƒqWd||j ƒ|fttfSt |d dƒ} t|tƒr€| tjkr€|sCd ttfSt|ƒ} |rt||krtd t| |kfS| |kr“t|ƒttfSd|| R?R+R4R5tappendR RR@t _commajoinRARBR<t startswith( R RHRURIRLtclosuretquotestqgetR&R#tcharRNRJR)R*t componentsR_Rtktvtkreprt kreadabletkrecurtvreprt vreadabletvrecurR'totoreprt oreadabletorecurRK((s/usr/lib64/python2.7/pprint.pyR ós–         $                       cCsdt|ƒjt|ƒfS(Ns(R;RER4(R ((s/usr/lib64/python2.7/pprint.pyR5GscCs³ddl}|dkrHddddgidd6d d 6fgd }ntƒ}|jƒ}t|idd ƒ|jƒ}|j|ƒ|jƒ}d G||GHdG||GHdS(Niÿÿÿÿtstringiiiiiiiii †is _safe_repr:spformat:(ii(ttimeRRR R(R Rttptt1tt2tt3((s/usr/lib64/python2.7/pprint.pyt _perfcheckLs  0      t__main__((t__doc__tsysRRt cStringIORR$t ImportErrort__all__tjoinR`tidR4RFR<ttypeR;RRRRRRRRR R5RyRE(((s/usr/lib64/python2.7/pprint.pyt#s0         Ÿ T