o 7]h<@sUddlZddlZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z ddlm Z mZmZddlmZddlmZddlmZddlmZmZmZmZmZmZmZmZmZmZm Z dd l!m"Z"zddl#Z$Wn e%yzdZ$Ynwd d l&m'Z'd d l(m)Z)d d l*m+Z+d dl,m-Z-d dl.m/Z/d dl0m1Z1d dl2m3Z3m4Z4d dl5m6Z6d dl7m8Z8erd dl9m:Z:m;Z;mZ>m?Z?dede@fddZAdededfddZBdeCde@fddZD       djd ed!ed"d#d$d%e@d&e@d'eeEd(eeEd)e@ddfd*d+ZF       djd!ed"d#d$d%e@d&e@d'eeEd(eeEd)e@ddfd,d-ZGGd.d/d/e3ZHd0eeefdeeIeIeIffd1d2ZJd0d3deeIeIeIffd4d5ZKejLd6d7eeKe eJed8d7e d9d7eMd:d7e d;d7eNdd7ePd?d7eQd@d7edAd7i ZReeSeegeeIeIeIfffeTdB<eQeRUZVeMejLee fZWdede@fdCdDZXe GdEdFdFZYe GdGdHdHZZ   dkd0ed'eeEd(eeEdIeeEdeYf dJdKZ[dLdMdddddNd0edOeEdPeEd'eeEd(eeEdIeeEd)e@deIfdQdRZ\ddSdddddTd0ed!ed"d&e@d'eeEd(eeEdIeeEd)e@ddfdUdVZ]e^dWkrmGdXdYdYZ_e eEZ`dZe`d[<d d\d]d^d_hd`geNhdae eOdbgdciegdddee_dfZaead[beaddglcmdZdedeHeadSdhdidSdS)lN)array)CounterUserDictUserList defaultdictdeque) dataclassfields is_dataclass)isclass)islice)MappingProxyType) TYPE_CHECKINGAnyCallable DefaultDictDictIterableListOptionalSetTupleUnion)RichReprResult get_console) loop_last) pick_bool)RichRenderablecell_len)ReprHighlighter) JupyterMixinJupyterRenderable) Measurement)Text)ConsoleConsoleOptionsHighlighterType JustifyMethodOverflowMethod RenderResultobjreturncCstduo tt|S)z1Check if an object was created with attrs module.N) _attr_modulehastyper-r39/usr/lib/python3/dist-packages/pip/_vendor/rich/pretty.py_is_attr_object8sr5z_attr_module.Attribute[Any]cCstdur tt|SgS)zGet fields for an attrs object.N)r/r r1r2r3r3r4_get_attr_fields=sr6cCs(z |jjjtjkWStyYdSw)zCheck if an instance of a dataclass contains the default repr. Args: obj (object): A dataclass instance. Returns: bool: True if the default repr is used, False if there is a custom repr. F)__repr____code__ co_filename dataclasses__file__ Exceptionr2r3r3r4_is_dataclass_reprBs   r=ignoreFvalueconsoler'overflowr+crop indent_guides max_length max_string expand_allc Csddlm}t|ts|durdS|pt}|jrCgd} | D]#} t|| d} t| rBz| } Wn t y:Yqw| durBdSqt||rL| |j t|t rU|n t ||||||dd|dddS)Nr)ConsoleRenderable) _repr_html__repr_markdown_ _repr_json_ _repr_latex_ _repr_jpeg_ _repr_png_ _repr_svg__repr_mimebundle_ )rArCrDrErFmarginT)rBnew_line_start)r@rG isinstancer$r is_jupytergetattrinspectismethodr<lineprintrPretty) r?r@rArBrCrDrErFrGipython_repr_methods repr_methodmethod repr_resultr3r3r4_ipy_display_hookSsD         r_c sddlmp dusJdtddffdd }z$t}ddlm} Gfd d d | } | } | |jjd <WdStyS|t _ YdSw) aInstall automatic pretty printing in the Python REPL. Args: console (Console, optional): Console instance or ``None`` to use global console. Defaults to None. overflow (Optional[OverflowMethod], optional): Overflow method. Defaults to "ignore". crop (Optional[bool], optional): Enable cropping of long lines. Defaults to False. indent_guides (bool, optional): Enable indentation guides. Defaults to False. max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation. Defaults to None. max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None. expand_all (bool, optional): Expand all containers. Defaults to False. max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100. rrNr?r.c sT|dur(dus Jdt_jt|tr|n t|dd|t_dSdS)z?Replacement sys.displayhook which prettifies objects with Rich.N)rArCrDrErF)rB)builtins_rYrSrrZ)r?)r@rBrFrCrDrErAr3r4 display_hooks$  zinstall..display_hook) BaseFormattercs:eZdZUdZeed<dedeffdd ZdS)zinstall..RichFormatterTpprintr?r.c s&|jrt|dSt|S)N)r@rArCrDrErF)rdr_repr)selfr?rFrrCrDrErAr3r4__call__s z'install..RichFormatter.__call__N)__name__ __module__ __qualname__rdbool__annotations__rrhr3rgr3r4 RichFormatters $rnz text/plain) pip._vendor.richrr get_ipythonIPython.core.formattersrcdisplay_formatter formattersr<sys displayhook) r@rArBrCrDrErFrbiprcrnrich_formatterr3)r@rBrFrrCrDrErAr4installs   "   rxc@seZdZdZ d$dddddddddddd deded d ed ed d eddeededeedeedeededededdfddZ      d%dd Z      !d&d"d#Z dS)'rZakA rich renderable that pretty prints an object. Args: _object (Any): An object to pretty print. highlighter (HighlighterType, optional): Highlighter object to apply to result, or None for ReprHighlighter. Defaults to None. indent_size (int, optional): Number of spaces in indent. Defaults to 4. justify (JustifyMethod, optional): Justify method, or None for default. Defaults to None. overflow (OverflowMethod, optional): Overflow method, or None for default. Defaults to None. no_wrap (Optional[bool], optional): Disable word wrapping. Defaults to False. indent_guides (bool, optional): Enable indentation guides. Defaults to False. max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation. Defaults to None. max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None. max_depth (int, optional): Maximum depth of nested data structures, or None for no maximum. Defaults to None. expand_all (bool, optional): Expand all containers. Defaults to False. margin (int, optional): Subtrace a margin from width to force containers to expand earlier. Defaults to 0. insert_line (bool, optional): Insert a new line if the output has multiple new lines. Defaults to False. NFr) indent_sizejustifyrAno_wraprCrDrE max_depthrFrQ insert_line_object highlighterr)rzr{r*rAr+r|rCrDrEr}rFrQr~r.c CsX||_|pt|_||_||_||_||_||_||_| |_ | |_ | |_ | |_ | |_ dSN)rr"rrzr{rAr|rCrDrEr}rFrQr~)rfrrrzr{rAr|rCrDrEr}rFrQr~r3r3r4__init__s  zPretty.__init__r@r'optionsr(r,c cst|j|j|j|j|j|j|j|jd}t ||j p|j |j p"|j t |j |j dd}|r3||n t t|jddd}|jrM|jsM|j|jdd}|jrWd|vrWd V|VdS) N max_widthrzrDrEr}rFpretty)r{rAr|stylez.__repr__ returned empty stringz dim italic)rz repr.indent ) pretty_reprrrrQrzrDrEr}rFr&r{rArr|rr1rC ascii_onlywith_indent_guidesr~)rfr@r pretty_str pretty_textr3r3r4__rich_console__s>        zPretty.__rich_console__r%cCsDt|j|j|j|j|jd}|rtdd|Dnd}t||S)N)rrzrDrEcs|]}t|VqdSrr .0rXr3r3r4 ?z*Pretty.__rich_measure__..r) rrrrzrDrEmax splitlinesr%)rfr@rr text_widthr3r3r4__rich_measure__4s zPretty.__rich_measure__r)r@r'rr(r.r,)r@r'rr(r.r%) rirjrk__doc__rrintrlrrrr3r3r3r4rZst       #rZrcCsd|jddd|jdfS)Nz defaultdict(z, {})z, {}))default_factoryrr3r3r4_get_braces_for_defaultdictDs  rz array[Any]cCsd|jdddfS)Nzarray(z, [])zarray({_object.typecode!r}))typecoderr3r3r4_get_braces_for_arrayLsrcCdS)N)z environ({rz environ({})r3rr3r3r4QrcCr)N)z Counter({rz Counter()r3rr3r3r4rTrcCr)N)zdeque([rzdeque()r3rr3r3r4rUrcCrN){}z{}r3rr3r3r4rVrcCrrr3rr3r3r4rWrcCr)N)z frozenset({rz frozenset()r3rr3r3r4rXrcCrN)[]z[]r3rr3r3r4rYrcCrrr3rr3r3r4rZrcCr)N)rrzset()r3rr3r3r4r[rcCr)N)()()r3rr3r3r4r\rcCr)N)zmappingproxy({rzmappingproxy({})r3rr3r3r4r]r_BRACEScCs.t|tpt|pt|dpt|ot| S)z3Check if an object may be expanded by pretty print. __rich_repr__)rS _CONTAINERSr hasattrr5r r2r3r3r4 is_expandablecs rc @seZdZUdZdZeed<dZeed<dZeed<dZ eed<dZ eed<dZ e ed <dZ e ed <d Zeeded <d ZdZeed<deefddZdedede fddZdefddZ d dedede defddZd S)!Nodez4A node in a repr tree. May be atomic or a container.rkey_repr value_repr open_brace close_braceemptyFlastis_tupleNchildrenz: z, separatorr.ccs|jr |jV|jV|jr|jVdS|jdurY|jrS|jV|jr9t|jdkr9|jdEdHdVn|jD]}|EdH|jsL|j Vq<|j VdS|j VdSdS)zGenerate tokens for this node.Nrr,) r key_separatorrrrrlen iter_tokensrrrr)rfchildr3r3r4r|s(     zNode.iter_tokens start_lengthrDcCs0|}|D]}|t|7}||krdSqdS)a*Check the length fits within a limit. Args: start_length (int): Starting length of the line (indent, prefix, suffix). max_length (int): Maximum length. Returns: bool: True if the node can be rendered within max length, otherwise False. FT)rr!)rfrrD total_lengthtokenr3r3r4 check_lengths  zNode.check_lengthcCsd|}|SNr)joinr)rf repr_textr3r3r4__str__sz Node.__str__PryrrzrFcCst|ddg}d}|t|kr5||}|jr+|js+|s ||s+|||||d<|d7}|t|ksddd|D}|S)alRender the node to a pretty repr. Args: max_width (int, optional): Maximum width of the repr. Defaults to 80. indent_size (int, optional): Size of indents. Defaults to 4. expand_all (bool, optional): Expand all levels. Defaults to False. Returns: str: A repr string of the original object. T)nodeis_rootrrrcsrr)strrr3r3r4rrzNode.render..)_Liner expandableexpandedrexpandr)rfrrzrFlinesline_norXrepr_strr3r3r4renders    z Node.render)rryF)rirjrkrrrrmrrrrrrlrrrrrrrrrrrrr3r3r3r4rms2         rc@seZdZUdZdZeded<dZeed<dZ ee ed<dZ e ed<dZ e ed <dZe ed <dZeed <dZeed <ed efddZded efddZded edfddZd e fddZdS)rzA line in repr output.NparentFrrrtextsuffix whitespacerrr.cCst|jduo |jjS)z"Check if the line may be expanded.N)rlrrrfr3r3r4rsz_Line.expandablerDcCs:t|jt|jt|j}|jdusJ|j||S)z4Check this line fits within a given number of cells.N)rrr!rrrr)rfrDrr3r3r4rsz_Line.check_lengthrzc cs|j}|dus J|j}|jsJ|jr&t|j|j|j|dV}nt|j|dV}|jd|}|jo>t|jdk}t |jD]\}}|rLdn|j } t|||| |oX| d} | VqDt|j ||j |j dVdS)z6Expand this line by adding children on their own line.N)rr rr)rrrrr)rrrr)rrrrrrrrrrrrrr) rfrzrrnew_linechild_whitespace tuple_of_onerrrrXr3r3r4rs:    z _Line.expandcCsD|jr|j|j|jp dS|j|j|jpd|jSr)rrrrrrstriprr3r3r4rs"z _Line.__str__)rirjrkrrrrmrrlrrrrrrrrpropertyrrrrrrr3r3r3r4rs       !rr}c sddtdtffdd tjjddtdtdtdtffd d |d d }|S)a`Traverse object and generate a tree. Args: _object (Any): Object to be traversed. max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation. Defaults to None. max_string (int, optional): Maximum length of string before truncating, or None to disable truncating. Defaults to None. max_depth (int, optional): Maximum depth of data structures, or None for no maximum. Defaults to None. Returns: Node: The root of a tree structure which can be used to render a pretty repr. r-r.c sdur$t|ttfr$t|kr$t|}|dd|}|Szt|}W|StyF}zdt|d}WYd}~|Sd}~ww)z0Get repr string for an object, but catch errors.N+z )rSbytesrrrer<)r- truncatedobj_reprerror)rEr3r4to_reprs    ztraverse..to_reprFrrootdepthc# st}tjjtjjf}duo|k}dtdttttt tfffdd}zt d}Wn t y9d}Ynwd}|sWzt drLt sL }Wn t yVYnw|durtj d d} t||} jj} | rg} | j} |r|td d }nT| rtd | d d| |d d}n t| dd| |d}t| D]2\}}t|tr|\}}||dd}||_||_d|_| |q||dd}||_| |qnt| rd | dn| dg|d}ntrg|sgg} | j} trY|rtd d }ntjjdd| |d}dttt ttttgt ffffdd }t|D]*\}\}}}|r@tt ||d }n||dd}||_||_d|_| |q,nwtjjdg|d}nitrtts|sts|dkrt }|vrtd d S|g} | j} |rtd d }n0tjjdd| |d}tddt!DD]\}}t|j"|dd}|j"|_||_d|_| |q|ntt#rt#D] }t|r|}nqt }|vrtd d S|t$|\}}}|rtd |d}n|j%tj%kr*t|d}nrg} t||| |d}| j} t&}|d}tt'r{t()} durXt*| } t+| D]\}!\}}||dd}||_|!|k|_| |q\n)t(}"durt*|"}"t+|"D]\}!}||dd}|!|k|_| |qdur|kr| td|ddnt|g|d }|nt|d}tt|_,|S)!zWalk the object depth first.N rich_argsr.css|D]<}t|tr._traverse..iter_rich_args,awehoi234_wdfjwljet234_234wdfoijsdfmmnxpi492Frangularz...)r._traverse..iter_attrs)rcss|]}|jr|VqdSr)re)rfieldr3r3r4rs  z.traverse.._traverse..)rrz... +T)rrr)-r1rt version_infomajorminorrrrrrrr<r rrUlist __class__riappendrrrSrrrrr5r6rrr r=idr rrrr7r_MAPPING_CONTAINERSiteritemsr enumerater)#r-rrobj_type py_versionreached_max_depthrfake_attributesrich_repr_resultrargs class_namerrrrrrr child_noderrr? repr_callableobj_idrcontainer_typerrr num_itemslast_item_index iter_itemsindex iter_values) _traverser}rD pop_visited push_visitedr visited_idsrr4r.sV&                                    ztraverse.._traverseT)rN)Fr)rrsetaddremoverlrr)rrDrEr}rr3)rr}rDrErrrrr4traverses, br rryrrrzc Cs4t|tr|}nt||||d}|j|||d}|S)aPrettify repr string by expanding on to new lines to fit within a given width. Args: _object (Any): Object to repr. max_width (int, optional): Desired maximum width of repr string. Defaults to 80. indent_size (int, optional): Number of spaces to indent. Defaults to 4. max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation. Defaults to None. max_string (int, optional): Maximum length of string before truncating, or None to disable truncating. Defaults to None. max_depth (int, optional): Maximum depth of nested data structure, or None for no depth. Defaults to None. expand_all (bool, optional): Expand all containers regardless of available width. Defaults to False. Returns: str: A possibly multi-line representation of the object. )rDrEr})rrzrF)rSrr r) rrrzrDrEr}rFrrr3r3r4rs rT)r@rCrDrEr}rFc Cs6|durtn|}|jt||||||dddddS)aA convenience function for pretty printing. Args: _object (Any): Object to pretty print. console (Console, optional): Console instance, or None to use default. Defaults to None. max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation. Defaults to None. max_string (int, optional): Maximum length of strings before truncating, or None to disable. Defaults to None. max_depth (int, optional): Maximum depth for nested data structures, or None for unlimited depth. Defaults to None. indent_guides (bool, optional): Enable indentation guides. Defaults to True. expand_all (bool, optional): Expand all containers. Defaults to False. Nr>)rDrEr}rCrFrAT) soft_wrap)rrYrZ)rr@rCrDrEr}rF_consoler3r3r4rd;s rd__main__c@seZdZdefddZdS) BrokenReprr.cCs dddS)Nrrzthis will failr3rr3r3r4r7cszBrokenRepr.__repr__N)rirjrkrr7r3r3r3r4r$bsr$fooz Hello World!gZd;Y@gʡE3t@gcA>rrrryr%r>rrrcrumble)applerhubarbbuttersugarflour)r+orangepearkumquatr2Xduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurian)FTN)r&barrcounteratomicBroken)rY)rCrE)Nr>FFNNF)NNN)er`r:rVosrertr collectionsrrrrrrr r r itertoolsr typesr typingrrrrrrrrrrrpip._vendor.rich.reprrrr/ ImportErrorrr_loopr_pickrabcrcellsr!rr"jupyterr#r$measurer%rr&r@r'r(r)r*r+r,rlr5r6objectr=rr_rxrZrrr_Environdict frozensetrrrrr1rmkeysrrrrrr rrdrir$ddatarrorYr3r3r3r4s     4              A K$f (  SE  + %