o
    þÞh]  ã                   @   sr   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„ dƒZdS )é    N)ÚImproperlyConfigured)Úcached_property©Úimport_stringé   ©ÚTemplate)ÚContextÚ_builtin_context_processors)ÚTemplateDoesNotExist©Úimport_libraryc                   @   s°   e Zd Zg d¢Z										d#dd„Zd	d
„ Zeejdd„ ƒƒZ	e
dd„ ƒZdd„ Zdd„ Ze
dd„ ƒZdd„ Zdd„ Zd$dd„Zdd„ Zdd„ Zd%dd „Zd!d"„ ZdS )&ÚEngine)zdjango.template.defaulttagszdjango.template.defaultfilterszdjango.template.loader_tagsNFÚ úutf-8Tc                 C   sÄ   |d u rg }|d u rg }|d u r dg}|r|dg7 }d|fg}n|r&t dƒ‚|d u r,i }|	d u r2g }	|| _|| _|
| _|| _|| _|| _|| _|| _|| _	|  
|¡| _| j|	 | _|  | j¡| _d S )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   © r!   úV/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/template/engine.pyÚ__init__   s:   
ÿzEngine.__init__c                 C   sŽ   d| j j| js	dndt| jƒ | j| jsdndt| jƒ | jt| jƒt| jƒt| j	ƒ| j
s/dndt| j
ƒ | js:dndt| jƒ t| jƒf S )Nz`<%s:%s app_dirs=%s%s debug=%s loaders=%s string_if_invalid=%s file_charset=%s%s%s autoescape=%s>r   z dirs=%sz context_processors=%sz libraries=%sz builtins=%s)Ú	__class__Ú__qualname__r   Úreprr   r   r   r   r   r   r   r   r   ©r    r!   r!   r"   Ú__repr__A   s    ÿñýzEngine.__repr__c                  C   sB   ddl m}  ddlm} |  ¡ D ]}t||ƒr|j  S q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/   r!   r!   r"   Úget_defaultW   s   

ÿzEngine.get_defaultc                 C   s$   t }|t| jƒ7 }tdd„ |D ƒƒS )Nc                 s   s   � | ]}t |ƒV  qd S ©Nr   )Ú.0Úpathr!   r!   r"   Ú	<genexpr>v   s   € z5Engine.template_context_processors.<locals>.<genexpr>)r
   Útupler   )r    r   r!   r!   r"   Útemplate_context_processorsr   s   z"Engine.template_context_processorsc                 C   s   dd„ |D ƒS )Nc                 S   s   g | ]}t |ƒ‘qS r!   r   )r2   Úxr!   r!   r"   Ú
<listcomp>y   s    z0Engine.get_template_builtins.<locals>.<listcomp>r!   )r    r   r!   r!   r"   r   x   s   zEngine.get_template_builtinsc                 C   s&   i }|  ¡ D ]
\}}t|ƒ||< q|S r1   )Úitemsr   )r    r   ÚloadedÚnamer3   r!   r!   r"   r   {   s   zEngine.get_template_librariesc                 C   s   |   | j¡S r1   )Úget_template_loadersr   r'   r!   r!   r"   Útemplate_loaders�   s   zEngine.template_loadersc                 C   s.   g }|D ]}|   |¡}|d ur| |¡ q|S r1   )Úfind_template_loaderÚappend)r    r=   r   Útemplate_loaderÚloaderr!   r!   r"   r<   …   s   

€zEngine.get_template_loadersc                 C   sJ   t |ttfƒr|^}}ng }t |tƒrt|ƒ}|| g|¢R Ž S td| ƒ‚)Nz3Invalid value in template loaders configuration: %r)r.   r5   ÚlistÚstrr   r   )r    rA   ÚargsÚloader_classr!   r!   r"   r>   �   s   

ÿzEngine.find_template_loaderc                 C   sj   g }| j D ])}z|j||d�}||jfW   S  ty. } z| |j¡ W Y d }~qd }~ww t||d�‚)N)Úskip)Útried)r=   Úget_templateÚoriginr   ÚextendrG   )r    r;   r   rF   rG   rA   ÚtemplateÚer!   r!   r"   Úfind_template›   s   
€ÿzEngine.find_templatec                 C   s   t || d�S )zƒ
        Return a compiled Template object for the given template code,
        handling template inheritance recursively.
        ©r/   r   )r    Útemplate_coder!   r!   r"   Úfrom_string¥   s   zEngine.from_stringc                 C   s,   |   |¡\}}t|dƒst|||| d�}|S )zƒ
        Return a compiled Template object for the given template name,
        handling template inheritance recursively.
        ÚrenderrN   )rM   Úhasattrr   )r    Útemplate_namerK   rI   r!   r!   r"   rH   ¬   s   
zEngine.get_templatec                 C   sL   t |ttfƒr|  |¡}n|  |¡}t |tƒr| |¡S | t|| jd�¡S )z€
        Render the template specified by template_name with the given context.
        For use in Django's test suite.
        )r   )r.   rB   r5   Úselect_templaterH   r	   rQ   r   )r    rS   ÚcontextÚtr!   r!   r"   Úrender_to_string·   s   


zEngine.render_to_stringc                 C   sz   |st dƒ‚g }|D ]+}z|  |¡W   S  t y5 } z|jd |vr+| |jd ¡ W Y d}~q
d}~ww t d |¡ƒ‚)zV
        Given a list of template names, return the first that can be loaded.
        zNo template names providedr   Nz, )r   rH   rD   r?   Újoin)r    Útemplate_name_listÚ	not_foundrS   Úexcr!   r!   r"   rT   Ç   s   €ýzEngine.select_template)
NFNFNr   r   NNT)NNr1   )Ú__name__Ú
__module__r%   r   r#   r(   ÚstaticmethodÚ	functoolsÚ	lru_cacher0   r   r6   r   r   r=   r<   r>   rM   rP   rH   rW   rT   r!   r!   r!   r"   r      s<    
õ-




r   )r_   Údjango.core.exceptionsr   Údjango.utils.functionalr   Údjango.utils.module_loadingr   Úbaser   rU   r	   r
   Ú
exceptionsr   Úlibraryr   r   r!   r!   r!   r"   Ú<module>   s    