
    g*                         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
 d dlmZ d dlmZ  G d	 d
e
      Z G d d      Ze j"                  d        Zy)    N)Counter)Path)apps)settings)ImproperlyConfigured)cached_property)import_stringc                       e Zd Zy)InvalidTemplateEngineErrorN)__name__
__module____qualname__     m/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/template/utils.pyr   r      s    r   r   c                   6    e Zd ZddZed        Zd Zd Zd Zy)EngineHandlerNc                      || _         i | _        y)z|
        templates is an optional list of template engine definitions
        (structured like settings.TEMPLATES).
        N)
_templates_engines)self	templatess     r   __init__zEngineHandler.__init__   s    
 $r   c                 (   | j                   t        j                  | _         i }g }| j                   D ]@  }	 |d   j                  dd      d   }|g di d|}|||d	   <   |j                  |d	          B t        |      }|j                         D cg c]  \  }}|d
kD  s| }	}}|	r)t        dj                  dj                  |	                  |S # t        $ r- |j                  dd      }t        dj                  |            w xY wc c}}w )NBACKEND.   z<not defined>zHInvalid BACKEND for a template engine: {}. Check your TEMPLATES setting.F)NAMEDIRSAPP_DIRSOPTIONSr      zoTemplate engine aliases aren't unique, duplicates: {}. Set a unique NAME for each engine in settings.TEMPLATES.z, )r   r   	TEMPLATESrsplit	Exceptiongetr   formatappendr   most_commonjoin)
r   r   backend_namestpldefault_nameinvalid_backendcountsaliascount
duplicatess
             r   r   zEngineHandler.templates   sA   ??"&00DO	??C	  #9~44S!<R@ %!	
 C &)Ic&k"  V-+ #. '060B0B0DR0DuPQ	e0D
R&KKQ6IIj)L  9  "%'')_"E*..4f_.E & Ss   CD!D6Dc                 :   	 | j                   |   S # t        $ r 	 | j                  |   }n'# t        $ r t        dj	                  |            w xY w|j                         }|j                  d      }t        |      } ||      }|| j                   |<   |cY S w xY w)Nz4Could not find config for '{}' in settings.TEMPLATESr   )r   KeyErrorr   r   r(   copypopr	   )r   r1   paramsbackend
engine_clsengines         r   __getitem__zEngineHandler.__getitem__C   s    	=='' 	. 0,,2F5M  [[]Fjj+G&w/J'F#)DMM% M%	s$    	B+B$AABBc                 ,    t        | j                        S N)iterr   )r   s    r   __iter__zEngineHandler.__iter__Z   s    DNN##r   c                 2    | D cg c]  }| |   	 c}S c c}w r>   r   )r   r1   s     r   allzEngineHandler.all]   s    )-.U...s   r>   )	r   r   r   r   r   r   r<   r@   rB   r   r   r   r   r      s+     ' 'R.$/r   r   c                     t        j                         D cg c]L  }|j                  r>t        |j                        | z  j	                         rt        |j                        | z  N }}t        |      S c c}w )z
    Return an iterable of paths of directories to load app templates from.

    dirname is the name of the subdirectory containing templates inside
    installed applications.
    )r   get_app_configspathr   is_dirtuple)dirname
app_configtemplate_dirss      r   get_app_template_dirsrK   a   sm     ..00J??Z__ 5 ?GGI 	Z__'0   s   AA5)	functoolscollectionsr   pathlibr   django.appsr   django.confr   django.core.exceptionsr   django.utils.functionalr   django.utils.module_loadingr	   r   r   	lru_cacherK   r   r   r   <module>rU      sQ          7 3 5	!5 	N/ N/b    r   