3
š(ƒha	  ã               @   s„   d dl mZ d dlmZmZ ddlmZ ddlmZ ddl	m
Z
 ddd	„Zdd
d„Zddd„Zddd„ZG dd„ dejeeƒƒZdS )é    )Úsix)ÚDeprecationInstanceCheckÚRemovedInDjango20Warningé   )Úengines)ÚOrigin)ÚTemplateDoesNotExistNc             C   sb   g }t |ƒ}xD|D ]<}y
|j| ƒS  tk
rL } z|j|ƒ W Y dd}~X qX qW t| |d‚dS )zw
    Loads and returns a template for the given name.

    Raises TemplateDoesNotExist if no such template exists.
    N)Úchain)Ú_engine_listÚget_templater   Úappend)Útemplate_nameÚusingr	   r   ÚengineÚe© r   ú:/tmp/pip-install-q3hcpn_q/Django/django/template/loader.pyr      s    

 r   c             C   sœ   t | tjƒrtd|  ƒ‚g }t|ƒ}xR| D ]J}xD|D ]<}y
|j|ƒS  tk
rn } z|j|ƒ W Y dd}~X q4X q4W q*W | rtdj| ƒ|d‚ntdƒ‚dS )z¿
    Loads and returns a template for one of the given names.

    Tries names in order and returns the first template found.

    Raises TemplateDoesNotExist if no such template exists.
    zselect_template() takes an iterable of template names but got a string: %r. Use get_template() if you want to load a single template by name.Nz, )r	   zNo template names provided)	Ú
isinstancer   Ústring_typesÚ	TypeErrorr
   r   r   r   Újoin)Ztemplate_name_listr   r	   r   r   r   r   r   r   r   Úselect_template   s    


$r   c             C   s4   t | ttfƒrt| |d}nt| |d}|j||ƒS )z„
    Loads a template and renders it with a context. Returns a string.

    template_name may be a string or a list of strings.
    )r   )r   ÚlistÚtupler   r   Úrender)r   ÚcontextÚrequestr   Útemplater   r   r   Úrender_to_string:   s    r   c             C   s   | d krt jƒ S t |  gS )N)r   Úall)r   r   r   r   r
   G   s    r
   c               @   s   e Zd ZdZeZdS )ÚLoaderOriginzdjango.template.OriginN)Ú__name__Ú
__module__Ú__qualname__Úalternativer   Zdeprecation_warningr   r   r   r   r    K   s   r    )N)N)NNN)N)Zdjango.utilsr   Zdjango.utils.deprecationr   r   Ú r   Úbaser   Ú
exceptionsr   r   r   r   r
   Úwith_metaclassr    r   r   r   r   Ú<module>   s   



