a
    ӗa                     @   s\   d Z g dZddlZddlmZ ddlmZ dddZG d	d
 d
Zdd Z	e Z
e
jZdS )zGRedo the builtin repr() (representation) but with limits on most sizes.)Reprreprrecursive_repr    N)islice)	get_ident...c                    s    fdd}|S )zGDecorator to make a repr function return fillvalue for a recursive callc                    sX   t    fdd}td|_td|_td|_td|_tdi |_|S )Nc              	      sL   t | t f}|v r S | z| }W | n| 0 |S N)idr   adddiscard)selfkeyresult)	fillvaluerepr_runninguser_function */home/manager/Python-3.9.10/Lib/reprlib.pywrapper   s    

z<recursive_repr.<locals>.decorating_function.<locals>.wrapper
__module____doc____name____qualname____annotations__)setgetattrr   r   r   r   r   )r   r   r   )r   r   r   decorating_function   s    z+recursive_repr.<locals>.decorating_functionr   )r   r   r   r   r   r   	   s    r   c                   @   s~   e Zd Zdd Zdd Zdd Zddd	Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS ) r   c                 C   sF   d| _ d| _d| _d| _d| _d| _d| _d| _d| _d| _	d| _
d S )N            (   )maxlevelmaxtuplemaxlistmaxarraymaxdictmaxsetmaxfrozensetmaxdeque	maxstringmaxlongmaxother)r   r   r   r   __init__&   s    zRepr.__init__c                 C   s   |  || jS r   )repr1r#   )r   xr   r   r   r   3   s    z	Repr.reprc                 C   sV   t |j}d|v r$| }d|}t| d| rFt| d| ||S | ||S d S )N _Zrepr_)typer   splitjoinhasattrr   repr_instance)r   r0   leveltypenamepartsr   r   r   r/   6   s    

z
Repr.repr1 c           
         s   t |}|dkr|rd}nX|d  | j fddt||D }	||krT|	d d|	}|dkrr|rr|| }d|||f S )Nr   r      c                    s   g | ]}| qS r   r   ).0elemnewlevelr/   r   r   
<listcomp>G       z'Repr._repr_iterable.<locals>.<listcomp>, z%s%s%s)lenr/   r   appendr5   )
r   r0   r8   leftrightZmaxiterZtrailnspiecesr   r?   r   _repr_iterable@   s    
zRepr._repr_iterablec                 C   s   |  ||dd| jdS )N(),)rK   r$   r   r0   r8   r   r   r   
repr_tupleM   s    zRepr.repr_tuplec                 C   s   |  ||dd| jS )N[])rK   r%   rO   r   r   r   	repr_listP   s    zRepr.repr_listc                 C   s,   |sd|j  S d|j  }| |||d| jS )Nzarray('%s')zarray('%s', []))ZtypecoderK   r&   )r   r0   r8   Zheaderr   r   r   
repr_arrayS   s    

zRepr.repr_arrayc                 C   s$   |sdS t |}| ||dd| jS )Nzset(){})_possibly_sortedrK   r(   rO   r   r   r   repr_setY   s    zRepr.repr_setc                 C   s$   |sdS t |}| ||dd| jS )Nzfrozenset()zfrozenset({z}))rX   rK   r)   rO   r   r   r   repr_frozenset_   s    zRepr.repr_frozensetc                 C   s   |  ||dd| jS )Nzdeque([rT   )rK   r*   rO   r   r   r   
repr_dequef   s    zRepr.repr_dequec                 C   s   t |}|dkrdS |dkr dS |d }| j}g }tt|| jD ].}|||}||| |}	|d||	f  qB|| jkr|d d|}
d|
f S )	Nr   z{}z{...}r<   z%s: %sr   rC   z{%s})rD   r/   r   rX   r'   rE   r5   )r   r0   r8   rH   r@   r/   rJ   r   ZkeyreprZvalreprrI   r   r   r   	repr_dicti   s    

zRepr.repr_dictc                 C   s   t |d | j }t|| jkrtd| jd d }td| jd | }t |d | |t|| d   }|d | d |t|| d   }|S Nr         r   )builtinsr   r+   rD   maxr   r0   r8   rI   ijr   r   r   repr_strx   s    &$zRepr.repr_strc                 C   sh   t |}t|| jkrdtd| jd d }td| jd | }|d | d |t|| d   }|S r]   )r`   r   rD   r,   ra   rb   r   r   r   repr_int   s    
$zRepr.repr_intc                 C   s   zt |}W n& ty4   d|jjt|f  Y S 0 t|| jkrtd| jd d }td| jd | }|d | d |t|| d   }|S )Nz<%s instance at %#x>r   r^   r_   r   )	r`   r   	Exception	__class__r   r	   rD   r-   ra   rb   r   r   r   r7      s    $zRepr.repr_instanceN)r;   )r   r   r   r.   r   r/   rK   rP   rS   rU   rY   rZ   r[   r\   re   rf   r7   r   r   r   r   r   $   s   

	r   c                 C   s*   z
t | W S  ty$   t|  Y S 0 d S r   )sortedrg   list)r0   r   r   r   rX      s    
rX   )r   )r   __all__r`   	itertoolsr   _threadr   r   r   rX   ZaReprr   r   r   r   r   <module>   s   
s	