o
    þÞhK  ã                   @   sÔ   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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„ deƒZG dd„ dƒZddd„Zdd„ Zdd„ Zdd„ Zdd„ ZdS )é    )Údefaultdict)Úimport_module)Úwalk_packages)Úapps)Úsettings)ÚErrorÚWarning)ÚTemplateDoesNotExist)Úmake_context)ÚEngine)ÚInvalidTemplateLibraryé   )Ú
BaseEnginec                       sP   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
‡  ZS )ÚDjangoTemplatesÚ	templatesc                    s~   |  ¡ }| d¡  ¡ }| dd¡ | dtj¡ | dd¡ | di ¡}|  |¡|d< tƒ  |¡ t	| j
| jfi |¤Ž| _d S )NÚOPTIONSÚ
autoescapeTÚdebugÚfile_charsetzutf-8Ú	libraries)ÚcopyÚpopÚ
setdefaultr   ÚDEBUGÚgetÚget_templatetag_librariesÚsuperÚ__init__r   ÚdirsÚapp_dirsÚengine)ÚselfÚparamsÚoptionsr   ©Ú	__class__© ú_/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/template/backends/django.pyr      s   zDjangoTemplates.__init__c                 K   s   g |   ¡ ¢|  ¡ ¢S ©N)Ú"_check_string_if_invalid_is_stringÚ+_check_for_template_tags_with_the_same_name)r!   Úkwargsr&   r&   r'   Úcheck   s
   ÿþzDjangoTemplates.checkc                 C   s2   | j j}t|tƒstd|t|ƒf | dd�gS g S )NzK'string_if_invalid' in TEMPLATES OPTIONS must be a string but got: %r (%s).ztemplates.E002©ÚobjÚid)r    Ústring_if_invalidÚ
isinstanceÚstrr   Útype)r!   Úvaluer&   r&   r'   r)   $   s   

ÿüÿz2DjangoTemplates._check_string_if_invalid_is_stringc                 C   s¦   t tƒ}tƒ D ]\}}||  |¡ q| jj ¡ D ]\}}||  |¡ qg }| ¡ D ]%\}}t|ƒdkrPd dd„ t	|ƒD ƒ¡}| 
t|›d|› �| dd�¡ q+|S )Nr   z, c                 s   s   � | ]}t |ƒV  qd S r(   )Úrepr)Ú.0Úitemr&   r&   r'   Ú	<genexpr>>   s   € zNDjangoTemplates._check_for_template_tags_with_the_same_name.<locals>.<genexpr>z, is used for multiple template tag modules: ztemplates.W003r-   )r   ÚsetÚget_template_tag_modulesÚaddr    r   ÚitemsÚlenÚjoinÚsortedÚappendr   )r!   r   Úmodule_nameÚmodule_pathÚerrorsÚlibrary_namer<   r&   r&   r'   r*   1   s(   ÿüÿ€	z;DjangoTemplates._check_for_template_tags_with_the_same_namec                 C   s   t | j |¡| ƒS r(   )ÚTemplater    Úfrom_string)r!   Útemplate_coder&   r&   r'   rF   J   s   zDjangoTemplates.from_stringc              
   C   sF   z
t | j |¡| ƒW S  ty" } zt|| ƒ W Y d }~d S d }~ww r(   )rE   r    Úget_templater	   Úreraise)r!   Útemplate_nameÚexcr&   r&   r'   rH   M   s   €ÿzDjangoTemplates.get_templatec                 C   s   t ƒ }| |¡ |S )zŽ
        Return a collation of template tag libraries from installed
        applications and the supplied custom_libraries argument.
        )Úget_installed_librariesÚupdate)r!   Úcustom_librariesr   r&   r&   r'   r   S   s   
z)DjangoTemplates.get_templatetag_libraries)Ú__name__Ú
__module__Ú__qualname__Úapp_dirnamer   r,   r)   r*   rF   rH   r   Ú__classcell__r&   r&   r$   r'   r      s    r   c                   @   s*   e Zd Zdd„ Zedd„ ƒZddd„ZdS )	rE   c                 C   s   || _ || _d S r(   )ÚtemplateÚbackend)r!   rT   rU   r&   r&   r'   r   ^   s   
zTemplate.__init__c                 C   s   | j jS r(   )rT   Úorigin)r!   r&   r&   r'   rV   b   s   zTemplate.originNc              
   C   sV   t ||| jjjd�}z| j |¡W S  ty* } zt|| jƒ W Y d }~d S d }~ww )N)r   )r
   rU   r    r   rT   Úrenderr	   rI   )r!   ÚcontextÚrequestrK   r&   r&   r'   rW   f   s   ÿ€ÿzTemplate.render)NN)rO   rP   rQ   r   ÚpropertyrV   rW   r&   r&   r&   r'   rE   ]   s
    
rE   Nc                 C   s:   |p| j }| j| j| j|| jdœŽ}t| dƒr| j|_|S )zî
    Create a new TemplateDoesNotExist. Preserve its declared attributes and
    template debug data but discard __traceback__, __context__, and __cause__
    to make this object suitable for keeping around (in a cache, for example).
    )ÚtriedrU   ÚchainÚtemplate_debug)rU   r%   Úargsr[   r\   Úhasattrr]   ©rK   rU   Únewr&   r&   r'   Úcopy_exceptionp   s
   

rb   c                 C   s   t | |ƒ}|| ‚)zT
    Reraise TemplateDoesNotExist while maintaining template debug information.
    )rb   r`   r&   r&   r'   rI   }   s   
rI   c               	   c   s|   � dg} |   dd„ t ¡ D ƒ¡ | D ])}zt|ƒ}W n	 ty#   Y qw t|dƒr;t|ƒD ]}| |¡ d¡|fV  q-qdS )z^
    Yield (module_name, module_path) pairs for all installed template tag
    libraries.
    zdjango.templatetagsc                 s   s   � | ]	}|j › d �V  qdS )z.templatetagsN)Úname)r6   Ú
app_configr&   r&   r'   r8   ‹   s   € 
ÿz+get_template_tag_modules.<locals>.<genexpr>Ú__path__Ú.N)	Úextendr   Úget_app_configsr   ÚImportErrorr_   Úget_package_librariesÚremoveprefixÚlstrip)Ú
candidatesÚ	candidateÚpkgrc   r&   r&   r'   r:   …   s    €
ÿþ
€÷r:   c                   C   s   dd„ t ƒ D ƒS )a  
    Return the built-in template tag libraries and those from installed
    applications. Libraries are stored in a dictionary where keys are the
    individual module names, not the full module paths. Example:
    django.templatetags.i18n is stored as i18n.
    c                 S   s   i | ]\}}||“qS r&   r&   )r6   rA   Ú	full_namer&   r&   r'   Ú
<dictcomp>¢   s    
ÿz+get_installed_libraries.<locals>.<dictcomp>)r:   r&   r&   r&   r'   rL   ›   s   ÿrL   c                 c   sr   � t | j| jd ƒD ],}zt|d ƒ}W n ty+ } ztd|d |f ƒ|‚d}~ww t|dƒr6|d V  q
dS )zZ
    Recursively yield template tag libraries defined in submodules of a
    package.
    rf   r   zSInvalid template library specified. ImportError raised when trying to load '%s': %sNÚregister)r   re   rO   r   ri   r   r_   )ro   ÚentryÚmoduleÚer&   r&   r'   rj   §   s$   €
ÿÿý€ÿ

€örj   r(   )Úcollectionsr   Ú	importlibr   Úpkgutilr   Údjango.appsr   Údjango.confr   Údjango.core.checksr   r   Údjango.templater	   Údjango.template.contextr
   Údjango.template.enginer   Údjango.template.libraryr   Úbaser   r   rE   rb   rI   r:   rL   rj   r&   r&   r&   r'   Ú<module>   s$    M
