ó
A¾^Yc           @   s\   d  d l  Z  d  d l Z e Z e  j j d d ƒ Z d e j f d „  ƒ  YZ d d „ Z	 d S(   iÿÿÿÿNt   reprt   reprlibt   SafeReprc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s‹    subclass of repr.Repr that limits the resulting size of repr()
        and includes information on exceptions raised during the call.
    c         C   s   |  j  t j j |  | ƒ S(   N(   t   _callhelperR   t   ReprR    (   t   selft   x(    (    s+   /tmp/pip-build-UnxK1c/py/py/_io/saferepr.pyR       s    c         C   s®   d „  } | | |  j   ƒ } t | ƒ |  j  k rª t d |  j  d d ƒ } t d |  j  d | ƒ } | | |  | t | ƒ | ƒ } | |  d | t | ƒ | } n  | S(   Nc         S   sd   d |  k r  t  j j d ƒ |  Sd |  k r@ t  j j d ƒ |  St  j j d ƒ |  j d d ƒ Sd  S(   Nt   's   '%s't   "s   "%s"s   \'(   t   pyt   builtint   _totextt   replace(   t   u(    (    s+   /tmp/pip-build-UnxK1c/py/py/_io/saferepr.pyR       s
    i    i   i   s   ...(   t	   maxstringt   lent   max(   R   R   t   levelR    t   st   it   j(    (    s+   /tmp/pip-build-UnxK1c/py/py/_io/saferepr.pyt   repr_unicode   s    	"#c         C   s   |  j  t | ƒ S(   N(   R   t   builtin_repr(   R   R   R   (    (    s+   /tmp/pip-build-UnxK1c/py/py/_io/saferepr.pyt   repr_instance    s    c         G   s'  y | | | Œ } Wn t  j j k
 r/ ‚  nô t j ƒ  \ } } } t | d d ƒ } y t | ƒ }	 Wn& t  j j k
 r… ‚  n d }	 n Xd | |	 | j j t	 | ƒ f SXt
 | ƒ |  j k rt d |  j d d ƒ }
 t d |  j d |
 ƒ } | |
  d | t
 | ƒ | } n  | Sd  S(   Nt   __name__t   unknowns/   <[%s("%s") raised in repr()] %s object at 0x%x>i    i   i   s   ...(   R	   R
   t   _sysext   syst   exc_infot   getattrt   strt	   __class__R   t   idR   t   maxsizeR   (   R   t   callR   t   argsR   t   clst   et   tbt   exc_nameR   R   R   (    (    s+   /tmp/pip-build-UnxK1c/py/py/_io/saferepr.pyR   #   s(    
#(   R   t
   __module__t   __doc__R    R   R   R   (    (    (    s+   /tmp/pip-build-UnxK1c/py/py/_io/saferepr.pyR      s
   			ið   c         C   s1   t  ƒ  } | | _ | | _ d | _ | j |  ƒ S(   sP   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.
    i    (   R   R   R!   t   maxotherR    (   t   objR!   t   srepr(    (    s+   /tmp/pip-build-UnxK1c/py/py/_io/saferepr.pyt   saferepr;   s
    				(
   R	   R   R    R   R
   t
   _tryimportR   R   R   R-   (    (    (    s+   /tmp/pip-build-UnxK1c/py/py/_io/saferepr.pyt   <module>   s
   3