3
e                 @   s   d dl ZejrddlmZ G dd deZG dd dee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G dd deZG dd deZdS )    N   )	Undefinedc                   sH   e Zd ZdZd	eje dd fddZeeje dddZ	  Z
S )
TemplateErrorz"Baseclass for all template errors.N)messagereturnc                s   t  j| d S )N)super__init__)selfr   )	__class__ 3/tmp/pip-build-3irwxpxt/Jinja2/jinja2/exceptions.pyr   
   s    zTemplateError.__init__)r   c             C   s   | j r| j d S d S )Nr   )args)r	   r   r   r   r      s    zTemplateError.message)N)__name__
__module____qualname____doc__tOptionalstrr   propertyr   __classcell__r   r   )r
   r   r      s   r   c               @   sX   e Zd ZU dZdZeje d
ejejedf  eje ddddZ	eddd	Z
dS )TemplateNotFoundzRaised if a template does not exist.

    .. versionchanged:: 2.11
        If the given name is :class:`Undefined` and no message was
        provided, an :exc:`UndefinedError` is raised.
    Nr   )namer   r   c             C   sN   t j| | |d kr6ddlm} t||r2|j  |}|| _|| _|g| _d S )Nr   )r   )	IOErrorr   runtimer   
isinstanceZ_fail_with_undefined_errorr   r   	templates)r	   r   r   r   r   r   r   r      s    
zTemplateNotFound.__init__)r   c             C   s
   t | jS )N)r   r   )r	   r   r   r   __str__1   s    zTemplateNotFound.__str__)N)r   r   r   r   r   r   r   r   Unionr   r   r   r   r   r   r      s
   
r   c                   sF   e Zd ZdZf dfejejedf  eje dd fddZ	  Z
S )TemplatesNotFounda  Like :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.

    .. versionchanged:: 2.11
        If a name in the list of names is :class:`Undefined`, a message
        about it being undefined is shown rather than the empty string.

    .. versionadded:: 2.2
    Nr   )namesr   r   c                s   |d krbddl m} g }x.|D ]&}t||r:|j|j q|j| qW djtt|}d| }t j	|rt|d nd | t
|| _d S )Nr   )r   z, z(none of the templates given were found: )r   r   r   appendZ_undefined_messagejoinmapr   r   r   listr   )r	   r    r   r   partsr   Z	parts_str)r
   r   r   r   A   s    


zTemplatesNotFound.__init__)r   r   r   r   r   Sequencer   r   r   r   r   r   r   )r
   r   r   5   s   
r   c                   sR   e Zd ZdZdeeeje eje dd fddZedddZ	d	d
 Z
  ZS )TemplateSyntaxErrorzBRaised to tell the user that there is a problem with the template.N)r   linenor   filenamer   c                s.   t  j| || _|| _|| _d | _d| _d S )NF)r   r   r)   r   r*   source
translated)r	   r   r)   r   r*   )r
   r   r   r   [   s    zTemplateSyntaxError.__init__)r   c             C   s   | j rtjt| jS d| j }| jp*| j}|r@d| d| }tjt| jd| g}| jd k	ry| jj	 | jd  }W n t
k
r   Y nX |jd|j   dj|S )Nzline zFile "z", z  r   z    
)r,   r   castr   r   r)   r*   r   r+   
splitlines
IndexErrorr"   stripr#   )r	   locationr   linesliner   r   r   r   l   s    
zTemplateSyntaxError.__str__c             C   s   | j | j| j| j| jffS )N)r
   r   r)   r   r*   )r	   r   r   r   
__reduce__   s    zTemplateSyntaxError.__reduce__)NN)r   r   r   r   r   intr   r   r   r   r5   r   r   r   )r
   r   r(   X   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   r7      s   r7   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   r8      s   r8   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   r9      s   r9   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   r:      s   r:   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   r;      s   r;   )typingr   ZTYPE_CHECKINGr   r   	Exceptionr   r   LookupErrorr   r   r(   r7   r8   r9   r:   r;   r   r   r   r   <module>   s   ##3