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

    Jinja exceptions.

    :copyright: (c) 2017 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
    )imap	text_typePY2implements_to_stringc                   @   sJ   e Zd ZdZer0d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   s&   |d k	rt |d}t| | d S )Nutf-8)r   encode	Exception__init__selfmessage r   3/usr/lib/python3/dist-packages/jinja2/exceptions.pyr
      s    zTemplateError.__init__c                 C   s(   | j r$| j d }|d k	r$|ddS d S )Nr   r   replace)argsdecoder   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 | | d S N)r	   r
   r   r   r   r   r
   !   s    c                 C   s    | j r| j d }|d k	r|S d S )Nr   )r   r   r   r   r   r   $   s    
)N)N)	__name__
__module____qualname____doc__r   r
   propertyr   r   r   r   r   r   r      s   



r   c                   @   s&   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   s.   t |  |d kr|}|| _|| _|g| _d S r   )IOErrorr
   r   name	templates)r   r   r   r   r   r   r
   4   s    
zTemplateNotFound.__init__c                 C   s   | j S r   r   r   r   r   r   __str__<   s    zTemplateNotFound.__str__)N)r   r   r   r   r   r
   r!   r   r   r   r   r   ,   s   
r   c                   @   s   e Zd ZdZ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
    r   Nc                 C   sD   |d krdd tt| }t| |r.|d p0d | 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   N)r   r   r   r   r
   r   r   r   r   r"   @   s   r"   c                   @   s"   e Zd ZdZdddZdd ZdS )TemplateSyntaxErrorzBRaised to tell the user that there is a problem with the template.Nc                 C   s.   t | | || _|| _|| _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S d| j }| jp | j}|r2d||f }| jd| g}| jd k	rz| j | jd  }W n tk
rz   d }Y nX |r|d|	   d
|S )Nzline %dzFile "%s", %sz     z    
)r+   r   r(   r)   r   r*   
splitlines
IndexErrorappendstripr$   )r   locationr   linesliner   r   r   r!   _   s    


zTemplateSyntaxError.__str__)NN)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   r5   w   s   r5   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.
    Nr6   r   r   r   r   r7      s   r7   c                   @   s   e Zd ZdZdS )UndefinedErrorz<Raised if a template tries to operate on :class:`Undefined`.Nr6   r   r   r   r   r8      s   r8   c                   @   s   e Zd ZdZdS )SecurityErrorzWRaised if a template tries to do something insecure if the
    sandbox is enabled.
    Nr6   r   r   r   r   r9      s   r9   c                   @   s   e Zd ZdZdS )FilterArgumentErrorzQThis error is raised if a filter was called with inappropriate
    arguments
    Nr6   r   r   r   r   r:      s   r:   N)r   Zjinja2._compatr   r   r   r   r	   r   r   LookupErrorr   r"   r'   r5   r7   r8   r9   r:   r   r   r   r   <module>   s   	&