
SL                 @   s  d  Z  d d l m Z m Z m Z m Z Gd d   d e  Z e Gd d   d e e	 e   Z
 Gd d   d e
  Z e Gd	 d
   d
 e   Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z d S)z
    jinja2.exceptions
    ~~~~~~~~~~~~~~~~~

    Jinja exceptions.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
    )imap	text_typePY2implements_to_stringc               @   sm   e  Z d  Z d Z e rH d d d  Z e d d    Z d d   Z n! d d	 d  Z e d
 d    Z d S)TemplateErrorz"Baseclass for all template errors.Nc             C   s5   | d  k	 r! t  |  j d  } t j |  |  d  S)Nzutf-8)r   encode	Exception__init__)selfmessage r   3/usr/lib/python3/dist-packages/jinja2/exceptions.pyr	      s    zTemplateError.__init__c             C   s6   |  j  r2 |  j  d } | d  k	 r2 | j d d  Sd  S)Nr   zutf-8replace)argsdecode)r
   r   r   r   r   r      s    	zTemplateError.messagec             C   s   |  j  p d S)N )r   )r
   r   r   r   __unicode__   s    zTemplateError.__unicode__c             C   s   t  j |  |  d  S)N)r   r	   )r
   r   r   r   r   r	   !   s    c             C   s*   |  j  r& |  j  d } | d  k	 r& | Sd  S)Nr   )r   )r
   r   r   r   r   r   $   s    	)	__name__
__module____qualname____doc__r   r	   propertyr   r   r   r   r   r   r      s   r   c               @   s7   e  Z d  Z d Z d Z d d d  Z d d   Z d S)TemplateNotFoundz$Raised if a template does not exist.Nc             C   sA   t  j |   | d  k r | } | |  _ | |  _ | g |  _ d  S)N)IOErrorr	   r   name	templates)r
   r   r   r   r   r   r	   4   s    		zTemplateNotFound.__init__c             C   s   |  j  S)N)r   )r
   r   r   r   __str__<   s    zTemplateNotFound.__str__)r   r   r   r   r   r	   r   r   r   r   r   r   ,   s   r   c               @   s(   e  Z d  Z d Z f  d d d  Z d S)TemplatesNotFoundzLike :class:`TemplateNotFound` but raised if multiple templates
    are selected.  This is a subclass of :class:`TemplateNotFound`
    exception, so just catching the base exception will catch both.

    .. versionadded:: 2.2
    Nc             C   s^   | d  k r( d d j  t t |   } t j |  | rA | d pD d  |  t |  |  _ d  S)Nz(none of the templates given were found: z,    )joinr   r   r   r	   listr   )r
   namesr   r   r   r   r	   H   s
    #zTemplatesNotFound.__init__)r   r   r   r   r	   r   r   r   r   r   @   s   r   c               @   s4   e  Z d  Z d Z d d d d  Z d d   Z d S)TemplateSyntaxErrorzBRaised to tell the user that there is a problem with the template.Nc             C   sA   t  j |  |  | |  _ | |  _ | |  _ d  |  _ d |  _ d  S)NF)r   r	   linenor   filenamesource
translated)r
   r   r$   r   r%   r   r   r   r	   T   s    				zTemplateSyntaxError.__init__c             C   s   |  j  r |  j Sd |  j } |  j p, |  j } | rE d | | f } |  j d | g } |  j d  k	 r y |  j j   |  j d } Wn t k
 r d  } Yn X| r | j d | j	    d j
 |  S)Nzline %dzFile "%s", %sz  r   z    
)r'   r   r$   r%   r   r&   
splitlines
IndexErrorappendstripr    )r
   locationr   linesliner   r   r   r   _   s    	zTemplateSyntaxError.__str__)r   r   r   r   r	   r   r   r   r   r   r#   P   s   r#   c               @   s   e  Z d  Z d Z d S)TemplateAssertionErrora  Like a template syntax error, but covers cases where something in the
    template caused an error at compile time that wasn't necessarily caused
    by a syntax error.  However it's a direct subclass of
    :exc:`TemplateSyntaxError` and has the same attributes.
    N)r   r   r   r   r   r   r   r   r0   w   s   r0   c               @   s   e  Z d  Z d Z d S)TemplateRuntimeErrorzoA generic runtime error in the template engine.  Under some situations
    Jinja may raise this exception.
    N)r   r   r   r   r   r   r   r   r1      s   r1   c               @   s   e  Z d  Z d Z d S)UndefinedErrorz<Raised if a template tries to operate on :class:`Undefined`.N)r   r   r   r   r   r   r   r   r2      s   r2   c               @   s   e  Z d  Z d Z d S)SecurityErrorzWRaised if a template tries to do something insecure if the
    sandbox is enabled.
    N)r   r   r   r   r   r   r   r   r3      s   r3   c               @   s   e  Z d  Z d Z d S)FilterArgumentErrorzQThis error is raised if a filter was called with inappropriate
    arguments
    N)r   r   r   r   r   r   r   r   r4      s   r4   N)r   Zjinja2._compatr   r   r   r   r   r   r   LookupErrorr   r   r#   r0   r1   r2   r3   r4   r   r   r   r   <module>
   s   "&