e fG:@s&dZddlZddlZddlmZddlmZ ddddd d gZ dd d dd dddZ d d dd dddZ dd Z ddZddZGdddZddZGdd d ZddZddZdddZedkr"endS) 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)StringIOpprintpformat isreadable isrecursivesaferepr PrettyPrinterPcompactFc Cs8td|d|d|d|d|}|j|dS)zAPretty-print a Python object to a stream [default is sys.stdout].streamindentwidthdepthr N)r r)objectr rrrr Zprinterr+/opt/alt/python34/lib64/python3.4/pprint.pyr.s c Cs(td|d|d|d|j|S)zrFrz, )r4r,r1rJrKr3)rrQr rr^r_r`r4ZdelimnlZdelimrrdrfrbwrrrrVs*           zPrettyPrinter._format_itemscCsR|j||j|j|\}}}|s<d|_n|rNd|_n|S)NFT)r8copyr*rIrH)rrr_r`rYr:r;rrrrJ+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)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} | jr| | q| || t| ddqWd ||j |fddfSt |d d} t |t r| t j kr|s=dSt|} |rn||krnd d| |kfS| |krt|ddfSd|| s         '                    rcCsdt|jt|fS)Nz)rr"r)rrrrrGsrGcCsddl}|dkrHddddgidd6d d 6fgd }nt}|j}t|idd|j}|j||j}td ||td ||dS)Nrstringr riz _safe_repr:zpformat:)r r)timer rrprint)rrpZt1Zt2Zt3rrr _perfchecks  0     r__main__)r%r[sysr. collectionsrrOiorr5__all__rrrrrrr(r rrGrr"rrrr#s(        U