o
    ïôjä‹  ã                   @   s¨  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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  d d	l!m"Z" zd dl#Z$e%e$d
ƒZ&W n e'y�   dZ&Y nw ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8 ddl9m:Z: erÌddl;m<Z<m=Z=m>Z>m?Z?m@Z@mAZA dedeBfdd„ZCdeded fdd„ZDdeEdeBfdd„ZFe Gd g ¡ZHdeEdeBfd!d"„ZI		#						dd$ed%ed& d'd(d)eBd*eBd+eeJ d,eeJ d-eeJ d.eBde eKdf fd/d0„ZLdeEd1e eMeeMd2f f deBfd3d4„ZN		#						dd%ed& d'd(d)eBd*eBd+eeJ d,eeJ d-eeJ d.eBddfd5d6„ZOG d7d8„ d8e5ƒZPd9eeef deeKeKeKf fd:d;„ZQd9d<deeKeKeKf fd=d>„ZRejSd?d@„ eeRe
eQedAd@„ edBd@„ eTdCd@„ edDd@„ eUdEd@„ eVdFd@„ e	dGd@„ eWdHd@„ eXdId@„ edJd@„ iZYeeMeegeeKeKeKf f f eZdK< eXeY [¡ ƒZ\eTejSeefZ]dedeBfdLdM„Z^eG dNdO„ dOƒƒZ_eG dPdQ„ dQƒƒZ`dedeBfdRdS„Za			d€d9ed+eeJ d,eeJ d-eeJ de_f
dTdU„ZbdVdWdddddXœd9edYeJdZeJd+eeJ d,eeJ d-eeJ d.eBdeKfd[d\„Zcdd]ddddd^œd9ed%ed& d*eBd+eeJ d,eeJ d-eeJ d.eBddfd_d`„Zdeedak�rÒG dbdc„ dcƒZfd ddlmgZg G dedf„ dfegƒZhe
eJƒZidgeidh< ddidjdkdlh dm£geUh dn£ƒe
eVdog dp¢iƒeg dq¢ƒdrehdsdtdudvdwdxgƒefƒ dyœZjejdh  kej¡ d dzllmmZm emePejd]d{d|�ƒ G d}d~„ d~ƒZnemePenƒ ƒƒ dS dS )�é    N)Úarray)ÚCounterÚUserDictÚUserListÚdefaultdictÚdeque)Ú	dataclassÚfieldsÚis_dataclass)Úisclass)Úislice)ÚMappingProxyType)ÚTYPE_CHECKINGÚAnyÚCallableÚDefaultDictÚDictÚIterableÚListÚOptionalÚSequenceÚSetÚTupleÚUnion)ÚRichReprResultÚ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©r/   © r6   ú^/var/www/html/academy/tools/voices/clone/cosy-venv/lib/python3.10/site-packages/rich/pretty.pyÚ_is_attr_object:   s   r8   z_attr_module.Attribute[Any]c                 C   s   t r	t t| ƒ¡S g S )zGet fields for an attrs object.)r1   r2   r	   r4   r5   r6   r6   r7   Ú_get_attr_fields?   s   r9   c                 C   s(   z	| j jjtjkW S  ty   Y dS w )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.
    F)Ú__repr__Ú__code__Úco_filenameÚdataclassesÚ__file__Ú	Exceptionr5   r6   r6   r7   Ú_is_dataclass_reprD   s
   ÿr@   Ú_dummy_namedtuplec              	   C   s@   d}zt  | j¡}W n ttfy   Y nw 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Ú	TypeErrorrA   )r/   Úobj_fileZdefault_repr_filer6   r6   r7   Ú_has_default_namedtuple_reprX   s   	ýrG   ÚignoreÚvalueÚconsoler)   Úoverflowr-   ÚcropÚindent_guidesÚ
max_lengthÚ
max_stringÚ	max_depthÚ
expand_allc	                 C   s¨   ddl m}	 t| tƒs| d u rd S |ptƒ }| ¡ �+}
t| |	ƒr$| ¡  |jt| tƒr-| nt	| ||||||dd�|ddd� W d   ƒ n1 sHw   Y  |
 
¡  d¡S )	Nr   )ÚConsoleRenderableé   )rK   rM   rN   rO   rP   rQ   ÚmarginTÚ )rL   Únew_line_startÚendÚ
)rJ   rR   Ú_safe_isinstancer&   r   ÚcaptureÚlineÚprintr!   ÚPrettyÚgetÚrstrip)rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rZ   r6   r6   r7   Ú_ipy_display_hookl   s4   


ÿø
ñür`   Úclass_or_tuple.c                 C   s"   zt | |ƒW S  ty   Y dS w )zFisinstance can fail in rare cases, for example types with no __class__F)Ú
isinstancer?   )r/   ra   r6   r6   r7   rY   š   s
   ÿrY   c              	      s®   ddl m‰ ˆ p
ˆƒ ‰ ˆ dusJ ‚dtddf‡ ‡‡‡‡‡‡‡fdd„}ztƒ }	W n ty5   |t_Y dS w 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   NrI   r0   c              
      sV   | dur)ˆ dus
J ‚dt _ˆ jt| tƒr| n
t| ˆˆˆˆˆˆd�ˆd� | t _dS dS )z?Replacement sys.displayhook which prettifies objects with Rich.N)rK   rM   rN   rO   rP   rQ   )rL   )ÚbuiltinsÚ_r\   rY   r!   r]   )rI   )rJ   rL   rQ   rM   rP   rN   rO   rK   r6   r7   Údisplay_hookÁ   s&   ÿù	ô
ïzinstall.<locals>.display_hook)ÚBaseFormatterc                       s<   e Zd ZU dZeed< dedef‡ ‡‡‡‡‡‡fdd„ZdS )zinstall.<locals>.RichFormatterTÚpprintrI   r0   c              
      s(   | j rt|ˆƒ ˆˆˆˆˆˆ d�S t|ƒS )N)rJ   rK   rM   rN   rO   rP   rQ   )rg   r`   Úrepr)ÚselfrI   ©rQ   r   rM   rP   rN   rO   rK   r6   r7   Ú__call__à   s   øz'install.<locals>.RichFormatter.__call__N)Ú__name__Ú
__module__Ú__qualname__rg   ÚboolÚ__annotations__r   rk   r6   rj   r6   r7   ÚRichFormatterÝ   s   
 &rq   z
text/plain)Úrichr   r   Úget_ipythonÚ	NameErrorÚsysÚdisplayhookÚIPython.core.formattersrf   Údisplay_formatterÚ
formatters)rJ   rK   rL   rM   rN   rO   rP   rQ   re   Úiprf   rq   Zrich_formatterr6   )	rJ   rL   rQ   r   rM   rP   rN   rO   rK   r7   Úinstall¤   s   
$
ÿ r{   c                   @   s¸   e Zd ZdZ	d$ddddddddddddœdeded	 d
eded ded dee dedee dee dee dedededdfdd„Z						d%dd „Z							!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ÚjustifyrK   Úno_wraprM   rN   rO   rP   rQ   rT   Úinsert_lineÚ_objectÚhighlighterr+   r}   r~   r,   rK   r-   r   rM   rN   rO   rP   rQ   rT   r€   r0   c                C   sX   || _ |ptƒ | _|| _|| _|| _|| _|| _|| _|	| _	|
| _
|| _|| _|| _d S ©N)r�   r$   r‚   r}   r~   rK   r   rM   rN   rO   rP   rQ   rT   r€   )ri   r�   r‚   r}   r~   rK   r   rM   rN   rO   rP   rQ   rT   r€   r6   r6   r7   Ú__init__  s   
zPretty.__init__rJ   r)   Úoptionsr*   r.   c              	   c   sº   � t | j|j| j | j| j| j| j| jd�}t	j
|| jp|j| jp#|jt| j|jƒdd�}|r4|  |¡nt	t| jƒ› d�dd�}| jrN|jsN|j| jdd�}| jrXd|v rXd	V  |V  d S )
N©Ú	max_widthr}   rN   rO   rP   rQ   Úpretty)r~   rK   r   Ústylez.__repr__ returned empty stringz
dim italic)r‰   zrepr.indentrX   rU   )Úpretty_reprr�   r‡   rT   r}   rN   rO   rP   rQ   r(   Ú	from_ansir~   rK   r    r   r‚   r4   rM   Ú
ascii_onlyÚwith_indent_guidesr€   )ri   rJ   r…   Ú
pretty_strZpretty_textr6   r6   r7   Ú__rich_console__'  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   ó   � | ]}t |ƒV  qd S rƒ   r"   ©Ú.0r[   r6   r6   r7   Ú	<genexpr>W  ó   € z*Pretty.__rich_measure__.<locals>.<genexpr>r   )rŠ   r�   r‡   r}   rN   rO   rP   rQ   ÚmaxÚ
splitlinesr'   )ri   rJ   r…   rŽ   Ú
text_widthr6   r6   r7   Ú__rich_measure__J  s   ù
ÿ
zPretty.__rich_measure__rƒ   )rJ   r)   r…   r*   r0   r.   )rJ   r)   r…   r*   r0   r'   )rl   rm   rn   Ú__doc__r   r   Úintro   r„   r�   r˜   r6   r6   r6   r7   r]   ô   st    ýñþýûúùø	÷
öõôóòñ
ðÿÿ
þ#ÿÿþr]   r�   c                 C   ó   d| j ›d�dd| j ›d�fS )Nzdefaultdict(z, {ú})z, {}))Údefault_factory©r�   r6   r6   r7   Ú_get_braces_for_defaultdict\  s   ýrŸ   z
array[Any]c                 C   r›   )Nzarray(z, [ú])ú))Útypecoderž   r6   r6   r7   Ú_get_braces_for_arrayd  s   r£   c                 C   ó   dS )N)z	environ({rœ   zenviron({})r6   rž   r6   r6   r7   Ú<lambda>i  ó    r¥   c                 C   r¤   )N)z	Counter({rœ   z	Counter()r6   rž   r6   r6   r7   r¥   l  r¦   c                 C   r¤   )N)zdeque([r    zdeque()r6   rž   r6   r6   r7   r¥   m  r¦   c                 C   r¤   ©N)Ú{Ú}z{}r6   rž   r6   r6   r7   r¥   n  r¦   c                 C   r¤   r§   r6   rž   r6   r6   r7   r¥   o  r¦   c                 C   r¤   )N)zfrozenset({rœ   zfrozenset()r6   rž   r6   r6   r7   r¥   p  r¦   c                 C   r¤   ©N)Ú[Ú]z[]r6   rž   r6   r6   r7   r¥   q  r¦   c                 C   r¤   rª   r6   rž   r6   r6   r7   r¥   r  r¦   c                 C   r¤   )N)r¨   r©   zset()r6   rž   r6   r6   r7   r¥   s  r¦   c                 C   r¤   )N)ú(r¡   ú()r6   rž   r6   r6   r7   r¥   t  r¦   c                 C   r¤   )N)zmappingproxy({rœ   zmappingproxy({})r6   rž   r6   r6   r7   r¥   u  r¦   Ú_BRACESc                 C   s.   t | tƒpt| ƒpt| dƒpt| ƒot| ƒ S )z3Check if an object may be expanded by pretty print.Ú__rich_repr__)rY   Ú_CONTAINERSr
   Úhasattrr8   r   r5   r6   r6   r7   Ú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< dee fdd„Zdededefdd„Zdefdd„Z	d"dedededefd d!„ZdS )#ÚNodez4A node in a repr tree. May be atomic or a container.rU   Úkey_reprÚ
value_reprÚ
open_braceÚclose_braceÚemptyFÚlastÚis_tupleÚis_namedtupleNÚchildrenz: Úkey_separatorz, Ú	separatorr0   c                 c   s¼   � | j r| j V  | jV  | jr| jV  dS | jdur\| jrV| jV  | jr<| js<t| jƒdkr<| jd  ¡ E dH  dV  n| jD ]}| ¡ E dH  |j	sO| j
V  q?| jV  dS | jV  dS dS )zGenerate tokens for this node.Nr   r   ú,)rµ   r¾   r¶   r½   r·   r»   r¼   ÚlenÚiter_tokensrº   r¿   r¸   r¹   )ri   Úchildr6   r6   r7   rÂ   •  s(   €

€ózNode.iter_tokensÚstart_lengthrN   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#   )ri   rÄ   rN   Útotal_lengthÚtokenr6   r6   r7   Úcheck_length«  s   
ÿzNode.check_lengthc                 C   s   d  |  ¡ ¡}|S ©NrU   )ÚjoinrÂ   )ri   Z	repr_textr6   r6   r7   Ú__str__¼  s   zNode.__str__éP   r|   r‡   r}   rQ   c                 C   s‚   t | dd�g}d}|t|ƒk r5|| }|jr+|js+|s | |¡s+| |¡|||d …< |d7 }|t|ƒk s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   rX   c                 s   r�   rƒ   )Ústrr‘   r6   r6   r7   r“   Ö  r”   zNode.render.<locals>.<genexpr>)Ú_LinerÁ   Ú
expandableÚexpandedrÇ   ÚexpandrÉ   )ri   r‡   r}   rQ   ÚlinesÚline_nor[   Úrepr_strr6   r6   r7   ÚrenderÀ  s   ûzNode.render)rË   r|   F)rl   rm   rn   r™   rµ   rÎ   rp   r¶   r·   r¸   r¹   rº   ro   r»   r¼   r½   r   r   r¾   r¿   r   rÂ   rš   rÇ   rÊ   rÖ   r6   r6   r6   r7   r´   …  s4   
 ÿÿÿÿþ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defdd„ƒZdedefdd„Zdeded  fdd„Zdefdd„ZdS )rÏ   zA line in repr output.NÚparentFrÍ   rÌ   rU   ÚtextÚsuffixÚ
whitespacerÑ   rº   r0   c                 C   s   t | jduo	| jjƒS )z"Check if the line may be expanded.N)ro   rÌ   r½   ©ri   r6   r6   r7   rÐ   ç  s   z_Line.expandablerN   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Ç   )ri   rN   rÄ   r6   r6   r7   rÇ   ì  s   ÿz_Line.check_lengthr}   c                 c   sÚ   � | j }|dus
J ‚| j}|jsJ ‚|jr&t|j› |j› |j› �|d�V }nt|j|d�V }| jd|  }|jo>t|jƒdk}t	|jƒD ]\}}|rLdn|j
}	t||||	|oX| d�}
|
V  qDt|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º   )ri   r}   rÌ   rÚ   Únew_lineZchild_whitespaceZtuple_of_onerº   rÃ   r¿   r[   r6   r6   r7   rÒ   ô  s:   €

þûüz_Line.expandc                 C   sD   | j r| j› | j› | jpd› �S | j› | j› | jpd› | j ¡ › �S rÈ   )rº   rÚ   rØ   rÌ   rÙ   r_   rÛ   r6   r6   r7   rÊ     s   "ÿz_Line.__str__)rl   rm   rn   r™   r×   r   rp   rÍ   ro   rÌ   r´   rØ   rÎ   rÙ   rÚ   rÑ   rº   ÚpropertyrÐ   rš   rÇ   r   rÒ   rÊ   r6   r6   r6   r7   rÏ   Ú  s   
 !rÏ   c                 C   s:   zt | ddƒ}W n
 ty   Y dS w t| tƒot|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)Úgetattrr?   rb   Útuple)r/   r	   r6   r6   r7   Ú_is_namedtuple  s   þrâ   c              	      sd   dt dtf‡fdd„‰tƒ ‰ˆj‰ˆj‰ddt dtdtdtf‡ ‡‡‡‡‡‡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/   r0   c              
      sŽ   ˆ dur$t | ttfƒr$t| ƒˆ kr$t| ƒˆ  }| dˆ … ›d|› �}|S zt| ƒ}W |S  tyF } zdt|ƒ›d�}W Y d}~|S d}~ww )z0Get repr string for an object, but catch errors.Nú+z<repr-error ú>)rY   ÚbytesrÎ   rÁ   rh   r?   )r/   Ú	truncatedÚobj_reprÚerror)rO   r6   r7   Úto_reprF  s   ÿü
þ€þztraverse.<locals>.to_reprFr   ÚrootÚdepthc           "   	      s–  t ˆƒ}|ˆv rtdd�S tˆƒ}ˆduo|ˆk}dtdttttttf f  fdd„}ztˆdƒ}W n t	y>   d	}Y nw d}|s\ztˆd
ƒrQt
ˆƒsQˆ ¡ }W n	 t	y[   Y nw |durþˆ|ƒ tˆjdd	ƒ}	t||ƒƒ}
ˆjj}|
ræg }|j}|r“|	rŠtd|› d�d�}nnt|› d�d�}ne|	r£td|› d�d||dd�}nt|› d�d||d�}t|
ƒD ]2\}}t|tƒrÕ|\}}ˆ||d d�}||_||_d|_||ƒ q²ˆ||d d�}||_||ƒ q²nt|	rïd|› d�n|› d�g |d�}ˆ|ƒ �n@tˆƒ�rŒ|�sŒˆ|ƒ g }|j}tˆƒ‰ ˆ �rz|�r$tˆjj› d�d�}nbtˆjj› d�d||d�}dtttttttgtf  f  f‡ ‡fdd„}t|ƒ ƒD ]*\}\}}}|�rbtt||ƒƒd�}nˆ||d d�}||_||_d|_||ƒ �qNntˆjj› d�g |d�}ˆ|ƒ �n²tˆƒ�rútˆtƒ�sú|�sútˆƒ�rúˆ|ƒ g }|j}|�r¶tˆjj› d�d�}n>tˆjj› d�d||ˆjj› d�d�}tdd„ tˆƒD ƒƒD ]\}}ˆtˆ|jƒ|d d�}|j|_||_d|_||ƒ �qÔˆ|ƒ �nDtˆƒ�rUt ˆƒ�rUˆ|ƒ ˆjj}|�rt|› d�d�}n8g }|j}t|› d�d||› d�d�}tˆ !¡  "¡ ƒD ]\}\}}ˆ||d d�}||_||_d|_||ƒ �q3ˆ|ƒ nétˆt#ƒ�r6t#D ]}tˆ|ƒ�ri|} n�q]ˆ|ƒ t$| ˆƒ\}}}|�r†t|› d|› �d�}n«|j%tˆƒj%k�r˜tˆˆƒ|d �}n™ˆ�r*g }t||||d�}|j}t&ˆƒ}|d }tˆt'ƒ�rét(ˆ "¡ ƒ}ˆdu�rÆt)|ˆƒ}t*|ƒD ]\} \}}ˆ||d d�}ˆ|ƒ|_| |k|_||ƒ �qÊn)t(ˆƒ}!ˆ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ƒ|_+tˆƒ|_,|S )$zWalk the object depth first.z...)r¶   NÚ	rich_argsr0   c                 s   s„   � | D ]<}t |tƒr<t|ƒdkr |\}}}||krq||fV  qt|ƒdkr0|\}}||fV  qt|ƒdkr;|d V  q|V  qd S )Né   é   r   r   )rY   rá   rÁ   )rì   ÚargÚkeyrÃ   Údefaultr6   r6   r7   Úiter_rich_argsf  s    €


€óz3traverse.<locals>._traverse.<locals>.iter_rich_argsZ,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º   c                  3   sx   � ˆ D ]6} | j r9ztˆ| jƒ}W n ty) } z| j|dfV  W Y d}~qd}~ww | j|t| j ƒr5| j ndfV  qdS )z$Iterate over attr fields and values.N)rh   rà   Únamer?   Úcallable)ÚattrrI   rè   ©Zattr_fieldsr/   r6   r7   Ú
iter_attrsÈ  s   €€þý€øz/traverse.<locals>._traverse.<locals>.iter_attrs)r·   r¸   r½   rº   r¹   c                 s   s   � | ]}|j r|V  qd S rƒ   )rh   )r’   Úfieldr6   r6   r7   r“   ü  s   € ÿ
ÿz.traverse.<locals>._traverse.<locals>.<genexpr>)r·   r¸   r½   r¹   )r¶   rº   z... +T)r¹   r½   rº   )-Úidr´   r4   r   r   r   r   rÎ   r²   r?   r   r°   rà   ÚlistÚ	__class__rl   Úappendr   rY   rá   rº   rµ   r¾   r8   r9   r   r   r
   r@   r	   rö   râ   rG   Ú_asdictÚitemsr±   r¯   r:   rÁ   Ú_MAPPING_CONTAINERSÚiterr   Ú	enumerater»   r¼   )"r/   rê   rë   Úobj_idÚobj_typeZreached_max_depthrò   Zfake_attributesZrich_repr_resultró   ÚargsÚ
class_namer½   rÿ   rÌ   rº   rï   rð   rÃ   Ú
child_noderú   rö   rI   Zrepr_callablerû   Úcontainer_typer·   r¸   r¹   Ú	num_itemsZlast_item_indexÚ
iter_itemsÚindexÚiter_values)Ú	_traverserP   rN   Úpop_visitedÚpush_visitedré   Úvisited_idsrù   r7   r  Z  sˆ  
&ÿÿ€ÿ
ûü


õýüÿø
ÿÿþýüûÿÿü
þü



ü


€

ztraverse.<locals>._traverseT)rê   N)Fr   )r   rÎ   ÚsetÚaddÚremovero   rš   r´   )r�   rN   rO   rP   rÌ   r6   )r  rP   rN   rO   r  r  ré   r  r7   Útraverse1  s   , |r  rË   r|   r†   r‡   r}   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.
    )rN   rO   rP   )r‡   r}   rQ   )rY   r´   r  rÖ   )	r�   r‡   r}   rN   rO   rP   rQ   rÌ   rÕ   r6   r6   r7   rŠ   Y  s   
ÿÿrŠ   T)rJ   rM   rN   rO   rP   rQ   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.
    NrH   )rN   rO   rP   rM   rQ   rK   T)Ú	soft_wrap)r   r\   r]   )r�   rJ   rM   rN   rO   rP   rQ   Ú_consoler6   r6   r7   rg   �  s   ù	
örg   Ú__main__c                   @   ó   e Zd Zdefdd„ZdS )Ú
BrokenReprr0   c                 C   s   dd  dS )Nr   r   zthis will failr6   rÛ   r6   r6   r7   r:   ©  s   zBrokenRepr.__repr__N©rl   rm   rn   rÎ   r:   r6   r6   r6   r7   r  ¨  ó    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)rl   rm   rn   rÎ   rp   Úfloatr   r6   r6   r6   r7   r  ¯  s   
 r  é   ÚfoozHello World!gZd;ßY@gÁÊ¡E¶3t@g    cA>   r#  é   é   é   )r   rî   rí   r|   >   r   rî   rí   Zcrumble)ÚappleZrhubarbÚbutterZsugarZflour)r(  ÚorangeÚpearÚkumquatr,  AX  duriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurian)FTNzSparkling British Spring WaterzCarbonated spring watergÍÌÌÌÌÌì?Zwaterzits amazing!zits terrible!)r$  Úbarr   ÚcounterZatomicÚ
namedtupleZBroken)r\   é   )rM   rO   c                   @   r  )ÚThingr0   c                 C   r¤   )NzHello[38;5;239m World!r6   rÛ   r6   r6   r7   r:   à  s   zThing.__repr__Nr  r6   r6   r6   r7   r1  ß  r  r1  )NrH   FFNNNF)NNN)orc   Úcollectionsr=   rB   Úosru   r   r   r   r   r   r   r   r	   r
   r   Ú	itertoolsr   Útypesr   Útypingr   r   r   r   r   r   r   r   r   r   r   r   Z	rich.reprr   rø   r2   r²   r1   ÚImportErrorrU   r   Ú_loopr   Ú_pickr    Úabcr!   Úcellsr#   r‚   r$   Újupyterr%   r&   Úmeasurer'   rØ   r(   rJ   r)   r*   r+   r,   r-   r.   ro   r8   r9   Úobjectr@   r/  rA   rG   rš   rÎ   r`   r4   rY   r{   r]   rŸ   r£   Ú_EnvironÚdictÚ	frozensetrý   r  rá   r¯   rp   Úkeysr±   r  r³   r´   rÏ   râ   r  rŠ   rg   rl   r  r  r  ÚdÚdatarÿ   rr   r\   r1  r6   r6   r6   r7   Ú<module>   s¼  
 8ÿ 
÷ÿþýüûúùø	÷


ö.ÿÿ
þøÿþýüûúùø	
÷P$h
(ó
TCüÿþýü
û  -øÿýüûúùø	
÷+øÿýüûúùø	
÷
%ú
ÿÿ
ûá!Ã