a
    )ñ»jý�  ã                   @   sN  U d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZm	Z	m
Z
mZmZ d dlmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z" d d	l#m$Z$ zd dl%Z&e'e&d
ƒZ(W n e)�y   dZ(Y n0 ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8 ddl9m:Z: ddl;m<Z< e�r¨ddl=m>Z>m?Z?m@Z@mAZAmBZBmCZC eeDdœdd„ZEeed dœdd„ZFeGeDdœdd„ZHe Idg ¡ZJeGeDdœd d!„ZKdyeed# d$eDeDeeL eeL eeL eDe"eMdf d%œ
d&d'„ZNeGe"eOe!eOd(f f eDd)œd*d+„ZPdzed# d$eDeDeeL eeL eeL eDdd,œ	d-d.„ZQG d/d0„ d0e7ƒZReeef e!eMeMeMf d1œd2d3„ZSee e!eMeMeMf d1œd4d5„ZTd6e!eMeMeMf d1œd7d8„ZUejVd9d:„ eeUeeSed;d:„ eeTeWd<d:„ e	d=d:„ eXd>d:„ eYd?d:„ e
d@d:„ eZdAd:„ e[dBd:„ edCd:„ iZ\eeOeege!eMeMeMf f f e]dD< e[e\ ^¡ ƒZ_eWejVee	fZ`eeDdœdEdF„ZaeG dGdH„ dHƒƒZbeG dIdJ„ dJƒƒZceeDdœdKdL„Zdd{eeeL eeL eeL ebdMœdNdO„ZedPdQdddddRœeeLeLeeL eeL eeL eDeMdSœdTdU„ZfddVdddddWœeed# eDeeL eeL eeL eDddXœdYdZ„Zgehd[k�rJG d\d]„ d]ƒZid d^lmjZj G d_d`„ d`ejƒZkeeLƒZldaeldb< ddcdddedfh dg£geXh dh£ƒeeYdig dj¢iƒeg dk¢ƒdlekdmdndodpdqdrgƒeiƒ dsœZmemdb  nem¡ d dtlompZp epeRemdVdudv�ƒ G dwdx„ dxƒZqepeReqƒ ƒƒ dS )|é    N)Úarray)ÚCounterÚUserDictÚUserListÚdefaultdictÚdeque)Ú	dataclassÚfieldsÚis_dataclass)Úisclass)Úislice)ÚMappingProxyType)ÚTYPE_CHECKINGÚAnyÚCallableÚDefaultDictÚDequeÚDictÚIterableÚListÚOptionalÚSequenceÚSetÚTupleÚUnion)ÚRichReprResultZibFé   ©Úget_console)Ú	loop_last)Ú	pick_bool)ÚRichRenderable©Úcell_len)ÚReprHighlighter)ÚJupyterMixinÚJupyterRenderable)ÚMeasurement)ÚText)ÚConsoleÚConsoleOptionsÚHighlighterTypeÚJustifyMethodÚOverflowMethodÚRenderResult©ÚobjÚreturnc                 C   s   t ot t| ƒ¡S )z1Check if an object was created with attrs module.)Ú
_has_attrsÚ_attr_moduleÚhasÚtype©r0   © r7   ú1E:\soccer\ml_env\Lib\site-packages\rich/pretty.pyÚ_is_attr_object<   s    r9   z_attr_module.Attribute[Any]c                 C   s   t rt t| ƒ¡S g S )zGet fields for an attrs object.)r2   r3   r	   r5   r6   r7   r7   r8   Ú_get_attr_fieldsA   s    r:   c                 C   s2   z| j jjtjtjfv W S  ty,   Y dS 0 dS )zÙCheck 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.
    FN)Ú__repr__Ú__code__Úco_filenameÚdataclassesÚ__file__ÚreprlibÚ	Exceptionr6   r7   r7   r8   Ú_is_dataclass_reprF   s    þrB   Ú_dummy_namedtuplec              	   C   s@   d}zt  | j¡}W n ttfy*   Y n0 t  tj¡}||kS )zÍCheck if an instance of namedtuple contains the default repr

    Args:
        obj (object): A namedtuple

    Returns:
        bool: True if the default repr is used, False if there's a custom repr.
    N)ÚinspectÚgetfiler;   ÚOSErrorÚ	TypeErrorrC   )r0   Úobj_fileÚdefault_repr_filer7   r7   r8   Ú_has_default_namedtuple_repr]   s    	rJ   Úignorer)   r-   )
ÚvalueÚconsoleÚoverflowÚcropÚindent_guidesÚ
max_lengthÚ
max_stringÚ	max_depthÚ
expand_allr1   c	                 C   s¨   ddl m}	 t| tƒs| d u r"d S |p*tƒ }| ¡ �V}
t| |	ƒrH| ¡  |jt| tƒrZ| nt	| ||||||dd�|ddd� W d   ƒ n1 s�0    Y  |
 
¡  d¡S )	Nr   )ÚConsoleRenderableé   )rN   rP   rQ   rR   rS   rT   ÚmarginTÚ )rO   Únew_line_startÚendÚ
)rM   rU   Ú_safe_isinstancer&   r   ÚcaptureÚlineÚprintr!   ÚPrettyÚgetÚrstrip)rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   r]   r7   r7   r8   Ú_ipy_display_hookq   s2    


ÿøï$rc   .)r0   Úclass_or_tupler1   c                 C   s&   zt | |ƒW S  ty    Y dS 0 dS )zFisinstance can fail in rare cases, for example types with no __class__FN)Ú
isinstancerA   )r0   rd   r7   r7   r8   r\   ¡   s    r\   )	rM   rN   rO   rP   rQ   rR   rS   rT   r1   c              	      sª   ddl m} ˆ p|ƒ ‰ ˆ dus"J ‚tddœ‡ ‡‡‡‡‡‡‡fdd„}	z
tƒ }
W n tyf   |	t_Y n@0 ddlm} G ‡ ‡‡‡‡‡‡fdd	„d	|ƒ}|ƒ }||
j	j
d
< dS )aù  Install 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.
        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.
        max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.
    r   r   N©rL   r1   c              
      sR   | durNˆ dusJ ‚dt _ˆ jt| tƒr,| nt| ˆˆˆˆˆˆd�ˆd� | t _dS )z?Replacement sys.displayhook which prettifies objects with Rich.N)rN   rP   rQ   rR   rS   rT   )rO   )ÚbuiltinsÚ_r_   r\   r!   r`   )rL   ©rM   rO   rT   rP   rS   rQ   rR   rN   r7   r8   Údisplay_hookÈ   s$    ÿù
òzinstall.<locals>.display_hook)ÚBaseFormatterc                       s:   e Zd ZU dZeed< eedœ‡ ‡‡‡‡‡‡fdd„ZdS )zinstall.<locals>.RichFormatterTÚpprintrf   c              
      s*   | j rt|ˆ ˆˆˆˆˆˆd�S t|ƒS d S )N)rM   rN   rP   rQ   rR   rS   rT   )rl   rc   Úrepr)ÚselfrL   ©rM   rT   rP   rS   rQ   rR   rN   r7   r8   Ú__call__é   s    øz'install.<locals>.RichFormatter.__call__N)Ú__name__Ú
__module__Ú__qualname__rl   ÚboolÚ__annotations__r   rp   r7   ro   r7   r8   ÚRichFormatteræ   s   
rv   z
text/plain)Úrichr   r   Úget_ipythonÚ	NameErrorÚsysÚdisplayhookÚIPython.core.formattersrk   Údisplay_formatterÚ
formatters)rM   rN   rO   rP   rQ   rR   rS   rT   r   rj   Úiprk   rv   Úrich_formatterr7   ri   r8   Úinstall«   s    
"
 r�   c                   @   s”   e Zd ZdZdddddddddddddœeed eed ed	 ee eee ee ee eeedd
œdd„Zddddœdd„Z	ddddœdd„Z
dS )r`   ak  A 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.
    Né   Fr   )Úindent_sizeÚjustifyrN   Úno_wraprP   rQ   rR   rS   rT   rW   Úinsert_liner+   r,   r-   )Ú_objectÚhighlighterrƒ   r„   rN   r…   rP   rQ   rR   rS   rT   rW   r†   r1   c                C   sX   || _ |ptƒ | _|| _|| _|| _|| _|| _|| _|	| _	|
| _
|| _|| _|| _d S ©N)r‡   r$   rˆ   rƒ   r„   rN   r…   rP   rQ   rR   rS   rT   rW   r†   )rn   r‡   rˆ   rƒ   r„   rN   r…   rP   rQ   rR   rS   rT   rW   r†   r7   r7   r8   Ú__init__  s    zPretty.__init__r)   r*   r.   )rM   Úoptionsr1   c              	   c   s¸   t | j|j| j | j| j| j| j| jd�}t	j
|| jp:|j| jpD|jt| j|jƒdd�}|rf|  |¡nt	t| jƒ› d�dd�}| jrš|jsš|j| jdd�}| jr®d|v r®d	V  |V  d S )
N©Ú	max_widthrƒ   rQ   rR   rS   rT   Úpretty)r„   rN   r…   Ústylez.__repr__ returned empty stringz
dim italic)r�   zrepr.indentr[   rX   )Úpretty_reprr‡   r�   rW   rƒ   rQ   rR   rS   rT   r(   Ú	from_ansir„   rN   r    r…   rˆ   r5   rP   Ú
ascii_onlyÚwith_indent_guidesr†   )rn   rM   r‹   Ú
pretty_strÚpretty_textr7   r7   r8   Ú__rich_console__0  s<    
ù	

û	ÿþýÿzPretty.__rich_console__r'   c              	   C   sL   t | j|j| j| j| j| j| jd�}|r>tdd„ | 	¡ D ƒƒnd}t
||ƒS )NrŒ   c                 s   s   | ]}t |ƒV  qd S r‰   r"   ©Ú.0r^   r7   r7   r8   Ú	<genexpr>`  ó    z*Pretty.__rich_measure__.<locals>.<genexpr>r   )r�   r‡   r�   rƒ   rQ   rR   rS   rT   ÚmaxÚ
splitlinesr'   )rn   rM   r‹   r”   Ú
text_widthr7   r7   r8   Ú__rich_measure__S  s    ù
ÿzPretty.__rich_measure__)N)rq   rr   rs   Ú__doc__r   r   Úintrt   rŠ   r–   rž   r7   r7   r7   r8   r`   ý   sH    ýñð þ$þr`   )r‡   r1   c                 C   s   d| j ›d�dd| j ›d�fS )Nzdefaultdict(z, {ú})z, {}))Údefault_factory©r‡   r7   r7   r8   Ú_get_braces_for_defaultdicte  s    ýr¤   c                 C   s,   | j d u rdS dd| j › d�d| j › d�fS )N)údeque([ú])zdeque()r¥   z
], maxlen=ú)zdeque(maxlen=)Úmaxlenr£   r7   r7   r8   Ú_get_braces_for_dequem  s    
ýr©   z
array[Any]c                 C   s   d| j ›d�dd| j ›d�fS )Nzarray(z, [r¦   r§   )Útypecoder£   r7   r7   r8   Ú_get_braces_for_arrayw  s    r«   c                 C   s   dS )N)z	environ({r¡   zenviron({})r7   r£   r7   r7   r8   Ú<lambda>|  rš   r¬   c                 C   s   dS )N)z	Counter({r¡   z	Counter()r7   r£   r7   r7   r8   r¬     rš   c                 C   s   dS ©N)Ú{Ú}z{}r7   r£   r7   r7   r8   r¬   �  rš   c                 C   s   dS r­   r7   r£   r7   r7   r8   r¬   ‚  rš   c                 C   s   dS )N)zfrozenset({r¡   zfrozenset()r7   r£   r7   r7   r8   r¬   ƒ  rš   c                 C   s   dS ©N)ú[ú]z[]r7   r£   r7   r7   r8   r¬   „  rš   c                 C   s   dS r°   r7   r£   r7   r7   r8   r¬   …  rš   c                 C   s   dS )N)r®   r¯   zset()r7   r£   r7   r7   r8   r¬   †  rš   c                 C   s   dS )N)ú(r§   ú()r7   r£   r7   r7   r8   r¬   ‡  rš   c                 C   s   dS )N)zmappingproxy({r¡   zmappingproxy({})r7   r£   r7   r7   r8   r¬   ˆ  rš   Ú_BRACESc                 C   s.   t | tƒs$t| ƒs$t| dƒs$t| ƒo,t| ƒ S )z3Check if an object may be expanded by pretty print.Ú__rich_repr__)r\   Ú_CONTAINERSr
   Úhasattrr9   r   r6   r7   r7   r8   Úis_expandableŽ  s    
ÿþüûr¹   c                   @   sæ   e Zd ZU dZdZeed< dZeed< dZeed< dZ	eed< dZ
eed< dZeed	< dZeed
< dZeed< dZeed   ed< dZeed< dZeed< ee dœdd„Zeeedœdd„Zedœdd„Zdeeeedœdd„ZdS ) ÚNodez4A node in a repr tree. May be atomic or a container.rX   Úkey_reprÚ
value_reprÚ
open_braceÚclose_braceÚemptyFÚlastÚis_tupleÚis_namedtupleNÚchildrenz: Úkey_separatorz, Ú	separator©r1   c                 c   s²   | j r| j V  | jV  | jr&| jV  nˆ| jdur®| jr¦| jV  | jrt| jstt| jƒdkrt| jd  ¡ E dH  dV  n(| jD ] }| ¡ E dH  |j	sz| j
V  qz| jV  n| jV  dS )zGenerate tokens for this node.Nr   r   ú,)r»   rÄ   r¼   rÃ   r½   rÁ   rÂ   ÚlenÚiter_tokensrÀ   rÅ   r¾   r¿   )rn   Úchildr7   r7   r8   rÉ   ¨  s"    




zNode.iter_tokens)Ústart_lengthrQ   r1   c                 C   s0   |}|   ¡ D ]}|t|ƒ7 }||kr dS qdS )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)rÉ   r#   )rn   rË   rQ   Útotal_lengthÚtokenr7   r7   r8   Úcheck_length¾  s    
zNode.check_lengthc                 C   s   d  |  ¡ ¡}|S ©NrX   )ÚjoinrÉ   )rn   Ú	repr_textr7   r7   r8   Ú__str__Ï  s    zNode.__str__éP   r‚   )r�   rƒ   rT   r1   c                 C   sx   t | dd�g}d}|t|ƒk r`|| }|jrV|jsV|s@| |¡sV| |¡|||d …< |d7 }qd dd„ |D ƒ¡}|S )al  Render 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)ÚnodeÚis_rootr   r   r[   c                 s   s   | ]}t |ƒV  qd S r‰   )Ústrr—   r7   r7   r8   r™   é  rš   zNode.render.<locals>.<genexpr>)Ú_LinerÈ   Ú
expandableÚexpandedrÎ   ÚexpandrÐ   )rn   r�   rƒ   rT   ÚlinesÚline_nor^   Úrepr_strr7   r7   r8   ÚrenderÓ  s    
zNode.render)rÓ   r‚   F)rq   rr   rs   rŸ   r»   rÖ   ru   r¼   r½   r¾   r¿   rÀ   rt   rÁ   rÂ   rÃ   r   r   rÄ   rÅ   r   rÉ   r    rÎ   rÒ   rÞ   r7   r7   r7   r8   rº   ˜  s(   
 ÿþrº   c                   @   s¾   e Zd ZU dZdZed  ed< dZeed< dZ	ee
 ed< dZeed< dZeed	< dZeed
< dZeed< dZeed< eedœdd„ƒZeedœdd„Zeed  dœdd„Zedœdd„ZdS )r×   zA line in repr output.NÚparentFrÕ   rÔ   rX   ÚtextÚsuffixÚ
whitespacerÙ   rÀ   rÆ   c                 C   s   t | jduo| jjƒS )z"Check if the line may be expanded.N)rt   rÔ   rÃ   ©rn   r7   r7   r8   rØ   ú  s    z_Line.expandable)rQ   r1   c                 C   s:   t | jƒt| jƒ t| jƒ }| jdus,J ‚| j ||¡S )z4Check this line fits within a given number of cells.N)rÈ   râ   r#   rà   rá   rÔ   rÎ   )rn   rQ   rË   r7   r7   r8   rÎ   ÿ  s    ÿz_Line.check_length)rƒ   r1   c                 c   sØ   | j }|dusJ ‚| j}|js"J ‚|jrJt|j› |j› |j› �|d�V }nt|j|d�V }| jd|  }|jozt|jƒdk}t	|jƒD ]4\}}|r–dn|j
}	t||||	|o®| d�}
|
V  q†t|j|| j| jd�V  dS )z6Expand this line by adding children on their own line.N)rà   râ   ú r   rÇ   )rß   rÔ   râ   rá   rÀ   )rà   râ   rá   rÀ   )rÔ   râ   rÃ   r»   r×   rÄ   r½   rÁ   rÈ   r   rÅ   r¾   rá   rÀ   )rn   rƒ   rÔ   râ   Únew_lineÚchild_whitespaceÚtuple_of_onerÀ   rÊ   rÅ   r^   r7   r7   r8   rÚ     s8    
þ
ûüz_Line.expandc                 C   sH   | j r | j› | j› | jpd› �S | j› | j› | jp4d› | j ¡ › �S d S rÏ   )rÀ   râ   rà   rÔ   rá   rb   rã   r7   r7   r8   rÒ   (  s    "ÿz_Line.__str__)rq   rr   rs   rŸ   rß   r   ru   rÕ   rt   rÔ   rº   rà   rÖ   rá   râ   rÙ   rÀ   ÚpropertyrØ   r    rÎ   r   rÚ   rÒ   r7   r7   r7   r8   r×   í  s   
!r×   c                 C   s:   zt | ddƒ}W n ty$   Y dS 0 t| tƒo8t|tƒS )aX  Checks if an object is most likely a namedtuple. It is possible
    to craft an object that passes this check and isn't a namedtuple, but
    there is only a minuscule chance of this happening unintentionally.

    Args:
        obj (Any): The object to test

    Returns:
        bool: True if the object is a namedtuple. False otherwise.
    Ú_fieldsNF)ÚgetattrrA   re   Útuple)r0   r	   r7   r7   r8   Ú_is_namedtuple1  s
    rì   )r‡   rQ   rR   rS   r1   c              	      s\   t tdœ‡fdd„‰tƒ ‰ˆj‰ˆj‰dt tttdœ‡ ‡‡‡‡‡‡fd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/   c              
      sŒ   ˆ durFt | ttfƒrFt| ƒˆ krFt| ƒˆ  }| dˆ … ›d|› �}nBzt| ƒ}W n4 ty† } zdt|ƒ›d�}W Y d}~n
d}~0 0 |S )z0Get repr string for an object, but catch errors.Nú+z<repr-error ú>)r\   ÚbytesrÖ   rÈ   rm   rA   )r0   Ú	truncatedÚobj_reprÚerror)rR   r7   r8   Úto_reprY  s    ÿþ
ý&ztraverse.<locals>.to_reprFr   )r0   ÚrootÚdepthr1   c           "         s²  t ˆƒ}|ˆv rtdd�S tˆƒ}ˆduo0|ˆk}tttttttf f  dœdd„}ztˆdƒ}W n t	yz   d}Y n0 d}|s¶ztˆd	ƒr t
ˆƒs ˆ ¡ }W n t	y´   Y n0 |du�r
ˆ|ƒ tˆjd
dƒ}	t||ƒƒ}
ˆjj}|
�rØg }|j}|�r,|	�rtd|› d�d�}nt|› d�d�}nª|	�rNtd|› d�d||dd�}nt|› d�d||d�}t|
ƒD ]h\}}t|tƒ�r´|\}}ˆ||d d�}||_||_d|_||ƒ nˆ||d d�}||_||ƒ �qln&t|	�rìd|› d�n|› d�g |d�}ˆ|ƒ �nŒtˆƒ�r&|�s&ˆ|ƒ g }|j}tˆƒ‰ ˆ �r|�rVtˆjj› d�d�}nªtˆjj› d�d||d�}tttttttgtf  f  dœ‡ ‡fdd„}t|ƒ ƒD ]T\}\}}}|�rÒtt||ƒƒd�}nˆ||d d�}||_||_d|_||ƒ �qªntˆjj› d�g |d�}ˆ|ƒ �nptˆƒ�rtˆtƒ�s|�stˆƒ�rˆ|ƒ g }|j}|�rztˆjj› d�d�}n€tˆjj› d�d||ˆjj› d�d�}t‡fdd„tˆƒD ƒƒD ]>\}}ˆtˆ|jƒ|d d�}|j|_||_d|_||ƒ �qºˆ|ƒ �n�tˆƒ�r¾t ˆƒ�r¾ˆ|ƒ ˆjj}|�rBt|› d�d�}npg }|j}t|› d�d||› d�d�}tˆ !¡  "¡ ƒD ]8\}\}}ˆ||d d�}||_||_d|_||ƒ �qxˆ|ƒ �nØtˆt#ƒ�r†t#D ]}tˆ|ƒ�rÎ|} �qì�qÎˆ|ƒ t$| ˆƒ\}}}|�r$t|› d|› �d�}�nX|j%tˆƒj%k�rJtˆˆƒ|d �}�n2ˆ�rng }t||||d�}|j}t&ˆƒ}|d }tˆt'ƒ�rìt(ˆ "¡ ƒ}ˆdu�r¦t)|ˆƒ}t*|ƒD ]:\} \}}ˆ||d d�}ˆ|ƒ|_| |k|_||ƒ �q®nRt(ˆƒ}!ˆdu�rt)|!ˆƒ}!t*|!ƒD ],\} }ˆ||d d�}| |k|_||ƒ �qˆdu�r||ˆk�r||td!|ˆ › �d"d �ƒ nt|g |d#�}ˆ|ƒ ntˆˆƒ|d �}tˆƒtk|_+tˆƒ|_,|S )$zWalk the object depth first.z...)r¼   N)Ú	rich_argsr1   c                 s   s‚   | D ]x}t |tƒrvt|ƒdkr>|\}}}||kr2q||fV  q|t|ƒdkr^|\}}||fV  q|t|ƒdkr||d V  q|V  qd S )Né   é   r   r   )r\   rë   rÈ   )rö   ÚargÚkeyrÊ   Údefaultr7   r7   r8   Úiter_rich_argsy  s    

z3traverse.<locals>._traverse.<locals>.iter_rich_argsÚ,awehoi234_wdfjwljet234_234wdfoijsdfmmnxpi492Fr¶   Úangularú<z...>z(...)rä   rî   )r½   r¾   rÃ   rÀ   rÅ   r³   r§   )r½   r¾   rÃ   rÀ   r   )rõ   ú=r´   )r¼   rÃ   rÀ   rÆ   c                  3   sv   ˆ D ]l} | j rztˆ| jƒ}W n2 tyP } z| j|dfV  W Y d}~qd}~0 0 | j|t| j ƒrh| j ndfV  qdS )z$Iterate over attr fields and values.N)rm   rê   ÚnamerA   Úcallable)ÚattrrL   rò   ©Úattr_fieldsr0   r7   r8   Ú
iter_attrsÛ  s    $ýz/traverse.<locals>._traverse.<locals>.iter_attrs)r½   r¾   rÃ   rÀ   r¿   c                 3   s$   | ]}|j rtˆ |jƒr|V  qd S r‰   )rm   r¸   r  )r˜   Úfieldr6   r7   r8   r™     s   þz.traverse.<locals>._traverse.<locals>.<genexpr>)r½   r¾   rÃ   r¿   )r¼   rÀ   z... +T)r¿   rÃ   rÀ   )-Úidrº   r5   r   r   r   r   rÖ   r¸   rA   r   r¶   rê   ÚlistÚ	__class__rq   Úappendr   r\   rë   rÀ   r»   rÄ   r9   r:   r   r   r
   rB   r	   r  rì   rJ   Ú_asdictÚitemsr·   rµ   r;   rÈ   Ú_MAPPING_CONTAINERSÚiterr   Ú	enumeraterÁ   rÂ   )"r0   rô   rõ   Úobj_idÚobj_typeÚreached_max_depthrü   Úfake_attributesÚrich_repr_resultrþ   ÚargsÚ
class_namerÃ   r  rÔ   rÀ   rù   rú   rÊ   Ú
child_noder  r  rL   Úrepr_callabler  Úcontainer_typer½   r¾   r¿   Ú	num_itemsÚlast_item_indexÚ
iter_itemsÚindexÚiter_values)Ú	_traverserS   rQ   Úpop_visitedÚpush_visitedró   Úvisited_idsr  r8   r   m  sv   
$ÿ


ûü
ýüÿÿÿþýüûþÿü
ü








ztraverse.<locals>._traverseT)rô   )Fr   )r   rÖ   ÚsetÚaddÚremovert   r    rº   )r‡   rQ   rR   rS   rÔ   r7   )r   rS   rQ   rR   r!  r"  ró   r#  r8   ÚtraverseD  s    & ~r'  rÓ   r‚   rŒ   )r‡   r�   rƒ   rQ   rR   rS   rT   r1   c          	      C   s4   t | tƒr| }nt| |||d�}|j|||d�}|S )a‡  Prettify 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.
    )rQ   rR   rS   )r�   rƒ   rT   )r\   rº   r'  rÞ   )	r‡   r�   rƒ   rQ   rR   rS   rT   rÔ   rÝ   r7   r7   r8   r�   n  s    
ÿÿr�   T)rM   rP   rQ   rR   rS   rT   )r‡   rM   rP   rQ   rR   rS   rT   r1   c             
   C   s6   |du rt ƒ n|}|jt| |||||dd�dd� dS )aó  A 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.
    NrK   )rQ   rR   rS   rP   rT   rN   T)Ú	soft_wrap)r   r_   r`   )r‡   rM   rP   rQ   rR   rS   rT   Ú_consoler7   r7   r8   rl   –  s    ù	örl   Ú__main__c                   @   s   e Zd Zedœdd„ZdS )Ú
BrokenReprrÆ   c                 C   s   dd  dS )Nr   r   zthis will failr7   rã   r7   r7   r8   r;   ¾  s    zBrokenRepr.__repr__N©rq   rr   rs   rÖ   r;   r7   r7   r7   r8   r+  ½  s   r+  )Ú
NamedTuplec                   @   s:   e Zd ZU eed< eed< eed< eed< ee ed< dS )ÚStockKeepingUnitr  ÚdescriptionZpriceÚcategoryZreviewsN)rq   rr   rs   rÖ   ru   Úfloatr   r7   r7   r7   r8   r.  Ä  s
   
r.  é   ÚfoozHello World!gZd;ßY@gÁÊ¡E¶3t@g    cA>   r2  é   é   é   )r   rø   r÷   r‚   >   r   rø   r÷   Zcrumble)ÚappleZrhubarbÚbutterZsugarZflour)r7  ZorangeÚpearÚkumquatr:  AX  duriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurian)FTNzSparkling British Spring WaterzCarbonated spring watergÍÌÌÌÌÌì?Zwaterzits amazing!zits terrible!)r3  Úbarr   ÚcounterZatomicÚ
namedtupleZBroken)r_   é   )rP   rR   c                   @   s   e Zd Zedœdd„ZdS )ÚThingrÆ   c                 C   s   dS )NzHello[38;5;239m World!r7   rã   r7   r7   r8   r;   õ  s    zThing.__repr__Nr,  r7   r7   r7   r8   r?  ô  s   r?  )NrK   FFNNNF)NrK   FFNNNF)NNN)rrg   Úcollectionsr>   rD   Úosr@   rz   r   r   r   r   r   r   r   r	   r
   r   Ú	itertoolsr   Útypesr   Útypingr   r   r   r   r   r   r   r   r   r   r   r   r   Z	rich.reprr   r  r3   r¸   r2   ÚImportErrorrX   r   Ú_loopr   Ú_pickr    Úabcr!   Úcellsr#   rˆ   r$   Újupyterr%   r&   Úmeasurer'   rà   r(   rM   r)   r*   r+   r,   r-   r.   rt   r9   r:   ÚobjectrB   r=  rC   rJ   r    rÖ   rc   r5   r\   r�   r`   r¤   r©   r«   Ú_EnvironÚdictÚ	frozensetr	  r$  rë   rµ   ru   Úkeysr·   r  r¹   rº   r×   rì   r'  r�   rl   rq   r+  r-  r.  ÚdÚdatar  rw   r_   r?  r7   r7   r7   r8   Ú<module>   sl  
<
 
        ÷
ö1þ        ø÷Rh"

ó(
TC   üû  /ø÷+ø÷%
ú
ÿÿ
ûá!