
v^                 @   sf   d  Z  d d l m Z d d l m Z 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.
    )SuspiciousFileOperation)OriginTemplateDoesNotExist)	safe_join   )Loaderc                   sI   e  Z d  Z d   f d d  Z d d   Z d d   Z d d	   Z   S)
r   Nc                s   t    j |  | |  _ d  S)N)super__init__dirs)selfenginer
   )	__class__ D/tmp/pip-build-8lau8j11/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   sX   y3 t  | j d |  j j  } | j   SWd  QRXWn t k
 rS t |   Yn Xd  S)Nencoding)opennamer   Zfile_charsetreadFileNotFoundErrorr   )r   originfpr   r   r   get_contents   s
    zLoader.get_contentsc             c   s`   xY |  j    D]K } y t | |  } Wn t k
 r= 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   Ztemplate_dirr   r   r   r   get_template_sources   s    zLoader.get_template_sources)__name__
__module____qualname__r	   r   r   r   r   r   )r   r   r      s   r   N)__doc__Zdjango.core.exceptionsr   Zdjango.templater   r   Zdjango.utils._osr   baser   Z
BaseLoaderr   r   r   r   <module>   s
   