B
    é¹`³	  ã               @   sB   d dl Z d dlZeZe j dd¡ZG dd„ dejƒZd	dd„Z	dS )
é    NÚreprÚreprlibc               @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚSafeReprz‹ subclass of repr.Repr that limits the resulting size of repr()
        and includes information on exceptions raised during the call.
    c             C   s   |   tjj| |¡S )N)Ú_callhelperr   ÚReprr   )ÚselfÚx© r	   úW/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/py/_io/saferepr.pyr      s    zSafeRepr.reprc             C   sœ   dd„ }||d | j … ƒ}t|ƒ| j kr˜td| j d d ƒ}td| j d | ƒ}||d |… |t|ƒ| d …  ƒ}|d |… d |t|ƒ| d …  }|S )Nc             S   sL   d| krt j d¡|  S d| kr0t j d¡|  S t j d¡|  dd¡ S d S )Nú'z'%s'ú"z"%s"z\')ÚpyÚbuiltinZ_totextÚreplace)Úur	   r	   r
   r      s
    z#SafeRepr.repr_unicode.<locals>.reprr   é   é   z...)Ú	maxstringÚlenÚmax)r   r   Úlevelr   ÚsÚiÚjr	   r	   r
   Úrepr_unicode   s    $$zSafeRepr.repr_unicodec             C   s   |   t|¡S )N)r   Úbuiltin_repr)r   r   r   r	   r	   r
   Úrepr_instance    s    zSafeRepr.repr_instancec             G   sü   y||f|žŽ }W n† t jjk
r,   ‚ Y nÌ   t ¡ \}}}t|ddƒ}yt|ƒ}	W n( t jjk
rr   ‚ Y n   d}	Y nX d||	|jjt	|ƒf S t
|ƒ| jkrôtd| jd d ƒ}
td| jd |
 ƒ}|d |
… d |t
|ƒ| d …  }|S d S )NÚ__name__Úunknownz/<[%s("%s") raised in repr()] %s object at 0x%x>r   r   r   z...)r   r   Z_sysexÚsysÚexc_infoÚgetattrÚstrÚ	__class__r   Úidr   Úmaxsizer   )r   Úcallr   Úargsr   ÚclsÚeÚtbZexc_namer    r   r   r	   r	   r
   r   #   s(    
$zSafeRepr._callhelperN)r   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r	   r	   r	   r
   r      s
   r   éð   c             C   s"   t ƒ }||_||_d|_| | ¡S )aP   return a size-limited safe repr-string for the given object.
    Failing __repr__ functions of user instances will be represented
    with a short exception info and 'saferepr' generally takes
    care to never raise exceptions itself.  This function is a wrapper
    around the Repr/reprlib functionality of the standard 2.6 lib.
    é    )r   r   r%   Úmaxotherr   )Úobjr%   Zsreprr	   r	   r
   Úsaferepr;   s
    r2   )r.   )
r   r   r   r   r   Z
_tryimportr   r   r   r2   r	   r	   r	   r
   Ú<module>   s
   3