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 )ÚTemplatesNotFoundzæ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.

    .. 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	r’z| 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   	&