B ҌBM @sddlZddlZddlZddlZddlmZ ddddddgZ d d d d dZ d!d d ddZ ddZ ddZddZGdddZddZGdddZddZeeeeeeeeedhZddZd"ddZddZ e!dkredS)#N)StringIOpprintpformat isreadable isrecursivesaferepr PrettyPrinterPF)compactcCs t|||||d}||dS)N)streamindentwidthdepthr )rr)objectr r rrr Zprinterr)/opt/alt/python37/lib/python3.7/pprint.pyr/scCst||||d|S)N)r rrr )rr)rr rrr rrrr7scCst|idddS)Nr) _safe_repr)rrrrr<scCst|idddS)Nrr )r)rrrrr@scCst|idddS)Nr)r)rrrrrDsc@s"eZdZdgZddZddZdS) _safe_keyobjcCs ||_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__ __slots__rrrrrrrHs rcCst|dt|dfS)Nrr )r)trrr _safe_tuple^sr$c@seZdZd:ddddZdd Zd d Zd d ZddZddZiZ ddZ e e e j <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)r cCs|t|}t|}|dkr td|dk r8|dkr8td|sDtd||_||_||_|dk rf||_ntj|_t||_ dS)Nrzindent must be >= 0zdepth must be > 0zwidth must be != 0) int ValueError_depth_indent_per_level_width_stream_sysstdoutbool_compact)rr rrr r rrrrcszPrettyPrinter.__init__cCs&|||jddid|jddS)Nr )_formatr*write)rrrrrrszPrettyPrinter.pprintcCs"t}|||ddid|S)Nr) _StringIOr0getvalue)rrZsiorrrrszPrettyPrinter.pformatcCs||idddS)Nrr)format)rrrrrrszPrettyPrinter.isrecursivecCs ||idd\}}}|o| S)Nr)r4)rrsreadable recursiverrrrszPrettyPrinter.isreadablec Cst|}||kr.|t|d|_d|_dS||||}|j||} t|| kr|j t |j d} | dk rd||<| |||||||d||=dSt |t rd||<|||||||d||=dS||dS)NTFr )rr1 _recursion _recursive _readable_reprr)len _dispatchgetr__repr__ isinstancedict _pprint_dict) rrr r allowancecontextlevelobjidrep max_widthprrrr0s,    zPrettyPrinter._formatc Csj|j}|d|jdkr*||jddt|}|r^t|td} || |||d|||ddS)N{r  )key})r1r(r<sorteditemsr$_format_dict_items) rrr r rCrDrEr1lengthrOrrrrBs zPrettyPrinter._pprint_dictcCslt|s|t|dS|j}||jd|t|||t|jd|d|||ddS)N(r ))r<r1repr __class__rr0listrO)rrr r rCrDrEclsrrr_pprint_ordered_dictsz"PrettyPrinter._pprint_ordered_dictcCs0|d|||||d|||ddS)N[r ])r1 _format_items)rrr r rCrDrErrr _pprint_lists zPrettyPrinter._pprint_listcCsH|dt|dkrdnd}|||||t|||||dS)NrRr z,)rS)r1r<r[)rrr r rCrDrEendcharrrr _pprint_tuples  zPrettyPrinter._pprint_tuplec Cst|s|t|dS|j}|tkr8|dd}n&||jdd}|t|jd7}t|td}|||||t|||||dS)NrJrMz({z})r )rL) r<r1rTrUsetrrNrr[) rrr r rCrDrEtypr]rrr _pprint_sets  zPrettyPrinter._pprint_setcCs|j}t|s|t|dSg}|d} |dkrD|d7}|d7}|j|} } xt| D]\} } t| }| t| dkr| |8} t|| kr||q\td| }| | }d}xtt|D]h\}}||}|t|dkr| t| dkr||8}tt||kr&|r |t||}q|}qW|r\|t|q\Wt|dkr^||dS|dkrp|dx8t|D],\} }| dkr|dd|||qzW|dkr|d dS) NTr z\S*\s*rRrr/rKrS) r1r<rT splitlinesr) enumerateappendrefindallpop)rrr r rCrDrEr1ZchunkslinesZ max_width1rHilinerGpartsZ max_width2currentjpart candidaterrr _pprint_strsT         zPrettyPrinter._pprint_strc Cs|j}t|dkr"|t|dS|dk}|rF|d7}|d7}|dd} x:t||j||D]$} || || | s^dd|} q^W|r|ddS)Nr rRrbr/rKrS)r1r<rT_wrap_bytes_reprr)) rrr r rCrDrEr1ZparensdelimrGrrr _pprint_bytes's"  zPrettyPrinter._pprint_bytesc Cs>|j}|d|t|||d|d||d|ddS)Nz bytearray( r rS)r1rubytes)rrr r rCrDrEr1rrr_pprint_bytearray<s zPrettyPrinter._pprint_bytearraycCs8|d||||d|d|||ddS)Nz mappingproxy( r rS)r1r0copy)rrr r rCrDrErrr_pprint_mappingproxyEs z"PrettyPrinter._pprint_mappingproxyc Cs|j}||j7}dd|}t|d} xrt|D]f\} \} } | | k} || ||}|||d|| ||t|d| r|nd||| s2||q2WdS)Nz, rKr z: r)r1r(r<rdr;r0)rrOr r rCrDrEr1delimnlZ last_indexrjrLentlastrGrrrrPMs    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||||}t|d}| |kr| } | r|} | |kr| |8} || d} ||q~|| |} | ||||r<|nd||q~WdS) Nr rKz, rbFTrz, ) r1r(r)iternext StopIterationr.r;r<r0)rrOr r rCrDrEr1r|rtrrHitZnext_entr~r}rGwrrrr[^sN         zPrettyPrinter._format_itemscCs4||||j|\}}}|s&d|_|r0d|_|S)NFT)r4rzr'r:r9)rrrDrErTr6r7rrrr;s zPrettyPrinter._reprcCst||||S)N)r)rrrD maxlevelsrErrrr4szPrettyPrinter.formatc Cst|s|t|dS||j||}|j}|t|jd7}|d|j|d|f|||||d|||ddS)Nr z %s(%s, %srKrS)r<r1rTr;default_factoryrUrrB) rrr r rCrDrEZrdfrWrrr_pprint_default_dictsz"PrettyPrinter._pprint_default_dictc Cst|s|t|dS|j}||jd|jdkrN||jdd|}||||t|jd|d|||ddS)Nz({r rKrz}))r<r1rTrUrr( most_commonrP) rrr r rCrDrErWrOrrr_pprint_counters zPrettyPrinter._pprint_counterc Cst|js|t|dS|j}||jd|t|jd7}xrt|jD]d\}} |t|jdkr|| |||d|||dqP|| ||d|||dd|qPWdS)NrRr rSz, rK)r<mapsr1rTrUrrdr0) rrr r rCrDrErWrjmrrr_pprint_chain_maps  zPrettyPrinter._pprint_chain_mapc Cst|s|t|dS|j}||jd|t|jd7}|d|jdkrz|||||d|||dn:||||d||||j||}|dd||fdS)NrRr rYrz])z], %smaxlen=%s)rK)r<r1rTrUrmaxlenr[r;) rrr r rCrDrErWZrmlrrr _pprint_deques    zPrettyPrinter._pprint_dequec Cs||j|||||ddS)Nr )r0data)rrr r rCrDrErrr_pprint_user_dictszPrettyPrinter._pprint_user_dictc Cs||j|||||ddS)Nr )r0r)rrr r rCrDrErrr_pprint_user_listszPrettyPrinter._pprint_user_listc Cs||j|||||ddS)Nr )r0r)rrr r rCrDrErrr_pprint_user_stringsz!PrettyPrinter._pprint_user_string)r r NN)2rr r!rrrrrr0r=rBrAr?rX _collections OrderedDictr\rVr^tuplerar_ frozensetrqrrurwrx bytearrayr{_typesMappingProxyTyperPr[r;r4r defaultdictrCounterrChainMaprdequerUserDictrUserListr UserStringrrrrrbsZ&      1    )       cCst|}|tkrt|ddfSt|dd}t|tr:|tjkr:|sJdSt|}|rl||krldd||kfS||krt|ddfSd||<d}d}g} | j } |d7}t } t | t d} xf| D]^\} }| | |||\}}}| ||||\}}}| d||f|o |o |}|s|rd}qW||=d d | ||fSt|trR|tjksjt|trf|tjkrft|tr|sd Sd }n"t|dkrd }n|sdSd}t|}|r||kr|dd||kfS||krt|ddfSd||<d}d}g} | j } |d7}x>|D]6}t ||||\}}}| ||s)rrr)rrrrr81sr8cCsddl}|dkr,ddddgdddfgd }t}|}t|idd|}|||}td ||td ||dS) Nrstring)r rrr)iz _safe_repr:zpformat:)timerZ perf_counterrrprint)rrrIZt1Zt2Zt3rrr _perfcheck6s rccsd}t|dd}xhtdt|dD]T}|||d}||}||krR||8}tt||krv|rpt|V|}q&|}q&W|rt|VdS)Nrrr)r<rangerT)rrrCrmr~rjrorprrrrsCs rs__main__)Nr r N)r r N)N)" collectionsrrfsysr+typesriorr2__all__rrrrrrr$rrrrrwrr%floatcomplexr-rrr8rrsrrrrr%s4   D