
^Q\	                 @   s   d  Z  d d l Z d d l Z d d l Z 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 Gd	 d
   d
 e  Z d S)z4
Wrapper for loading templates from the filesystem.
    N)SuspiciousFileOperation)OriginTemplateDoesNotExist)	safe_join)RemovedInDjango20Warning   )Loaderc                   s[   e  Z d  Z d   f d d  Z d d   Z d d   Z d d d	  Z d d
 d  Z   S)r   Nc                s#   t  t |   j |  | |  _ d  S)N)superr   __init__dirs)selfenginer   )	__class__ H/var/www/dbchiro/venv/build/Django/django/template/loaders/filesystem.pyr
      s    zLoader.__init__c             C   s    |  j  d  k	 r |  j  S|  j j  S)N)r   r   )r   r   r   r   get_dirs   s    zLoader.get_dirsc             C   s   y5 t  j | j d |  j j  } | j   SWd  QXWnI t k
 r } z) | j t j k rk t	 |   n    WYd  d  } ~ Xn Xd  S)Nencoding)
ioopennamer   Zfile_charsetreadIOErrorerrnoENOENTr   )r   originfper   r   r   get_contents   s    !zLoader.get_contentsc             c   so   | s |  j    } n  xS | D]K } y t | |  } Wn t k
 rL w Yn Xt d | d | d |   Vq Wd S)z
        Return an Origin object pointing to an absolute path in each directory
        in template_dirs. For security reasons, if a path doesn't lie inside
        one of the template_dirs it is excluded from the result set.
        r   template_nameloaderN)r   r   r   r   )r   r   template_dirsZtemplate_dirr   r   r   r   get_template_sources#   s    zLoader.get_template_sourcesc             C   sl   t  j d t  xI |  j | |  D]5 } y |  j |  | j f SWq# t k
 rW Yq# Xq# Wt |   d  S)Nz_The load_template_sources() method is deprecated. Use get_template() or get_contents() instead.)warningswarnr   r!   r   r   r   )r   r   r    r   r   r   r   load_template_source9   s    	zLoader.load_template_source)__name__
__module____qualname__r
   r   r   r!   r$   r   r   )r   r   r      s
   	r   )__doc__r   r   r"   Zdjango.core.exceptionsr   Zdjango.templater   r   Zdjango.utils._osr   Zdjango.utils.deprecationr   baser   Z
BaseLoaderr   r   r   r   <module>   s   