ó
àÆ÷Xc           @` sK   d  d l  m Z m Z m Z d  d l m Z d „  Z d „  Z d „  Z d S(   i    (   t   absolute_importt   print_functiont   division(   t   xrangec         C` sÄ   y |  | } Wn¯ t  k
 r¿ } d } x‡ | t |  ƒ k r¯ y |  d | !| } WnO t  k
 r¡ } t | ƒ t | ƒ k r¢ t  |  d | !d t | ƒ ƒ ‚ q¢ n X| d 7} q) Wt sÀ t ‚ n X| S(   sS  
    string: a string, containing formatting instructions
    sub: a dictionary containing keys and values to substitute for
        them.

    returns: string % sub

    The only difference between this function and the % operator
    is that it raises an exception with a more informative error
    message than the % operator does.
    i    s   <<<< caused exception i   (   t	   Exceptiont   lent   strt   Falset   AssertionError(   t   stringt   subt	   finalCodet   Et   it   F(    (    s3   /tmp/pip-build-X4mzal/theano/theano/misc/strutil.pyt   render_string   s    %c         C` s½   |  j  d ƒ } g  | D] } t | ƒ ^ q } d } xs t t | ƒ ƒ D]_ } | | | j d ƒ 8} | d k  ry d } n  d | | | | | <| | | j d ƒ 7} qG Wd j | ƒ } | S(   Ns   
i    t   }s       t   {(   t   splitt   strip_leading_white_spaceR   R   t   countt   join(   R	   t   linest   linet   indentR   t   rval(    (    s3   /tmp/pip-build-X4mzal/theano/theano/misc/strutil.pyt   pretty_format$   s    	c         C` sG   x@ t  |  ƒ d k rB |  d d k s5 |  d d k rB |  d }  q W|  S(   Ni    t    s   	i   (   R   (   R   (    (    s3   /tmp/pip-build-X4mzal/theano/theano/misc/strutil.pyR   8   s    5N(	   t
   __future__R    R   R   t	   six.movesR   R   R   R   (    (    (    s3   /tmp/pip-build-X4mzal/theano/theano/misc/strutil.pyt   <module>   s   		