
    h                     x    d dl Z d dlmZ d dlmZ d dlm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      Zy)    N)ImproperlyConfigured)cached_propertyimport_string   Template)Context_builtin_context_processors)TemplateDoesNotExistimport_libraryc                       e Zd Zg dZ	 	 	 ddZe ej                         d               Ze	d        Z
d Zd Ze	d        Zd	 Zd
 ZddZd Zd ZddZd Zy)Engine)zdjango.template.defaulttagszdjango.template.defaultfilterszdjango.template.loader_tagsNc                 z   |g }|g }|dg}|r|dgz  }|sd|fg}n|rt        d      |i }|	g }	|| _        || _        |
| _        || _        || _        || _        || _        || _        || _	        | j                  |      | _        | j                  |	z   | _        | j                  | j                        | _        y )Nz)django.template.loaders.filesystem.Loaderz.django.template.loaders.app_directories.Loaderz%django.template.loaders.cached.Loaderz1app_dirs must not be set when loaders is defined.)r   dirsapp_dirs
autoescapecontext_processorsdebugloadersstring_if_invalidfile_charset	librariesget_template_librariestemplate_librariesdefault_builtinsbuiltinsget_template_builtinstemplate_builtins)selfr   r   r   r   r   r   r   r   r   r   s              Y/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/django/template/engine.py__init__zEngine.__init__   s     <D%!#?BCGLMMCWMN*GI IIH	 $"4
!2(""&"="=i"H--8!%!;!;DMM!J    c                      ddl m}  ddlm} | j	                         D ]  }t        ||      s|j                  c S  t        d      )a  
        Return the first DjangoTemplates backend that's configured, or raise
        ImproperlyConfigured if none are configured.

        This is required for preserving historical APIs that rely on a
        globally available, implicitly configured engine such as:

        >>> from django.template import Context, Template
        >>> template = Template("Hello {{ name }}!")
        >>> context = Context({'name': "world"})
        >>> template.render(context)
        'Hello world!'
        r   )engines)DjangoTemplatesz)No DjangoTemplates backend is configured.)django.templater&   django.template.backends.djangor'   all
isinstanceenginer   )r&   r'   r,   s      r"   get_defaultzEngine.get_default7   sA    & 	,Ckkm 	%F&/2}}$	% ##NOOr$   c                 b    t         }|t        | j                        z  }t        d |D              S )Nc              3   2   K   | ]  }t        |        y wNr   ).0paths     r"   	<genexpr>z5Engine.template_context_processors.<locals>.<genexpr>U   s     HT]4(Hs   )r   tupler   )r!   r   s     r"   template_context_processorsz"Engine.template_context_processorsQ   s0    8eD$;$;<<H5GHHHr$   c                 >    |D cg c]  }t        |       c}S c c}w r0   r   )r!   r   xs      r"   r   zEngine.get_template_builtinsW   s    +34aq!444s   c                 V    i }|j                         D ]  \  }}t        |      ||<    |S r0   )itemsr   )r!   r   loadednamer2   s        r"   r   zEngine.get_template_librariesZ   s4    #//+ 	0JD$)$/F4L	0r$   c                 8    | j                  | j                        S r0   )get_template_loadersr   )r!   s    r"   template_loaderszEngine.template_loaders`   s    ((66r$   c                 b    g }|D ]'  }| j                  |      }||j                  |       ) |S r0   )find_template_loaderappend)r!   r>   r   template_loaderloaders        r"   r=   zEngine.get_template_loadersd   s?    / 	'O..?F!v&	' r$   c                     t        |t        t        f      r|^}}ng }t        |t              rt	        |      } || g| S t        d|z        )Nz3Invalid value in template loaders configuration: %r)r+   r4   liststrr   r   )r!   rC   argsloader_classs       r"   r@   zEngine.find_template_loaderl   sY    fudm,"MFTDfc"(0L,t,,&ENP Pr$   c                     g }| j                   D ]%  }	 |j                  ||      }||j                  fc S  t        ||      # t        $ r%}|j	                  |j
                         Y d }~^d }~ww xY w)N)skip)tried)r>   get_templateoriginr   extendrK   )r!   r;   r   rJ   rK   rC   templatees           r"   find_templatezEngine.find_templatey   sy    ++ 	&F&!..t$.?00	& #4u55 ( &QWW%%&s    A	A2A--A2c                     t        ||       S )z
        Return a compiled Template object for the given template code,
        handling template inheritance recursively.
        r,   r   )r!   template_codes     r"   from_stringzEngine.from_string   s    
 d33r$   c                 d    | j                  |      \  }}t        |d      st        ||||       }|S )z
        Return a compiled Template object for the given template name,
        handling template inheritance recursively.
        renderrS   )rQ   hasattrr	   )r!   template_namerO   rM   s       r"   rL   zEngine.get_template   s8    
  --m<&x*&-MHr$   c                    t        |t        t        f      r| j                  |      }n| j	                  |      }t        |t
              r|j                  |      S |j                  t        || j                              S )z
        Render the template specified by template_name with the given context.
        For use in Django's test suite.
        )r   )r+   rE   r4   select_templaterL   r
   rW   r   )r!   rY   contextts       r"   render_to_stringzEngine.render_to_string   sg    
 mdE]3$$]3A!!-0A gw'88G$$88GGHIIr$   c                    |st        d      g }|D ]  }	 | j                  |      c S  t        dj	                  |            # t         $ r9}|j                  d   |vr|j                  |j                  d          Y d}~od}~ww xY w)zV
        Given a list of template names, return the first that can be loaded.
        zNo template names providedr   Nz, )r   rL   rG   rA   join)r!   template_name_list	not_foundrY   excs        r"   r[   zEngine.select_template   s     "&'CDD	/ 	M((77	 #499Y#788 ( 88A;i/$$SXXa[1s   A	B/BB)
NFNFN zutf-8NNT)NNr0   )__name__
__module____qualname__r   r#   staticmethod	functools	lru_cacher-   r   r5   r   r   r>   r=   r@   rQ   rU   rL   r^   r[    r$   r"   r   r      s     FJ>@QU!KF YP  P0 I I
5 7 7P64	J 9r$   r   )ri   django.core.exceptionsr   django.utils.functionalr   django.utils.module_loadingr   baser	   r\   r
   r   
exceptionsr   libraryr   r   rk   r$   r"   <module>rr      s)     7 3 5  9 , #g9 g9r$   