o
    Mf                     @   sL   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z
 G dd de
Z	d	S )
z4
Wrapper for loading templates from the filesystem.
    )SuspiciousFileOperation)OriginTemplateDoesNotExist)	safe_join   )Loaderc                       s6   e Zd Zd
 fdd	Zdd Zdd Zdd	 Z  ZS )r   Nc                    s   t  | || _d S N)super__init__dirs)selfenginer   	__class__ d/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/django/template/loaders/filesystem.pyr
      s   
zLoader.__init__c                 C   s   | j d ur| j S | jj S r   )r   r   )r   r   r   r   get_dirs   s   zLoader.get_dirsc                 C   sZ   z!t |j| jjd}| W  d    W S 1 sw   Y  W d S  ty,   t|w )N)encoding)opennamer   file_charsetreadFileNotFoundErrorr   )r   originfpr   r   r   get_contents   s   (zLoader.get_contentsc              	   c   sF    |   D ]}zt||}W n	 ty   Y qw t||| dV  qd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_dirr   r   r   r   get_template_sources   s   
zLoader.get_template_sourcesr   )__name__
__module____qualname__r
   r   r   r   __classcell__r   r   r   r   r      s
    r   N)__doc__django.core.exceptionsr   django.templater   r   django.utils._osr   baser   
BaseLoaderr   r   r   r   <module>   s    