
    g]                     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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                 v   |g }|g }|dg}|r|dgz  }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              n/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/template/engine.py__init__zEngine.__init__   s     <D%!#?BCGLMM?IJG*G  IH	 $"4
!2(""&"="=i"H--8!%!;!;DMM!J    c                 L   d| j                   j                  d| j                  sdndt        | j                        z  d| j                  | j
                  sdndt        | j
                        z  d| j                  dt        | j                        d	t        | j                        d
t        | j                        | j                  sdndt        | j                        z  | j                  sdndt        | j                        z  dt        | j                        dS )N<: z dirs=%sz
 app_dirs=z context_processors=%sz debug=z	 loaders=z string_if_invalid=z file_charset=z libraries=%sz builtins=%sz autoescape=>)	__class____qualname__r   reprr   r   r   r   r   r   r   r   r   r!   s    r"   __repr__zEngine.__repr__A   s    
 NN''iiBZ$tyy/%AAMM .. -T5L5L0MMN JJ''(""#nnB/D<P*PPmmB$t}}:M)MM!%
 	
r$   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.templater0   django.template.backends.djangor1   all
isinstanceenginer   )r0   r1   r6   s      r"   get_defaultzEngine.get_defaultW   s<    & 	,CkkmF&/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>v   s     H5GT]4(5Gs   )r   tupler   )r!   r   s     r"   template_context_processorsz"Engine.template_context_processorsr   s0    8eD$;$;<<H5GHHHr$   c                 >    |D cg c]  }t        |       c}S c c}w r:   r   )r!   r   xs      r"   r   zEngine.get_template_builtinsx   s    +348aq!8444s   c                 V    i }|j                         D ]  \  }}t        |      ||<    |S r:   )itemsr   )r!   r   loadednamer<   s        r"   r   zEngine.get_template_libraries{   s/    #//+JD$)$/F4L ,r$   c                 8    | j                  | j                        S r:   )get_template_loadersr   r-   s    r"   template_loaderszEngine.template_loaders   s    ((66r$   c                 b    g }|D ]'  }| j                  |      }||j                  |       ) |S r:   )find_template_loaderappend)r!   rH   r   template_loaderloaders        r"   rG   zEngine.get_template_loaders   s:    /O..?F!v&  0 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)r5   r>   liststrr   r   )r!   rM   argsloader_classs       r"   rJ   zEngine.find_template_loader   sW    fudm,"MFTDfc"(0L,t,,&EN 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)rH   get_templateoriginr   extendrU   )r!   rE   r   rT   rU   rM   templatees           r"   find_templatezEngine.find_template   st    ++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.
        r6   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.
        renderr]   )r[   hasattrr	   )r!   template_namerY   rW   s       r"   rV   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   )r5   rO   r>   select_templaterV   r
   ra   r   )r!   rc   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   rV   rQ   rK   join)r!   template_name_list	not_foundrc   excs        r"   re   zEngine.select_template   s     "&'CDD	/M((77 0 #499Y#788 ( 88A;i/$$SXXa[1s   A	B/BB)
NFNFNr(   zutf-8NNT)NNr:   )__name__
__module__r+   r   r#   r.   staticmethod	functools	lru_cacher7   r   r?   r   r   rH   rG   rJ   r[   r_   rV   rh   re    r$   r"   r   r      s     +KZ
, P  P2 I I
5 7 764	J 9r$   r   )rq   django.core.exceptionsr   django.utils.functionalr   django.utils.module_loadingr   baser	   rf   r
   r   
exceptionsr   libraryr   r   rs   r$   r"   <module>rz      s)     7 3 5  9 , #I9 I9r$   