
    k"gK                         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e      Z G d d      ZddZd Zd Zd Zd Zy)    )defaultdict)import_module)walk_packages)apps)settings)ErrorWarning)TemplateDoesNotExist)make_context)Engine)InvalidTemplateLibrary   )
BaseEnginec                   F     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
 xZS )	DjangoTemplates	templatesc                    |j                         }|j                  d      j                         }|j                  dd       |j                  dt        j                         |j                  dd       |j                  di       }| j                  |      |d<   t        | !  |       t        | j                  | j                  fi || _        y )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__s       X/var/www/html/djangosite/lib/python3.12/site-packages/django/template/backends/django.pyr    zDjangoTemplates.__init__   s    **Y',,.<.7HNN3>73KKR0	#==iH TYYAA    c                 F    g | j                         | j                         S N)"_check_string_if_invalid_is_string+_check_for_template_tags_with_the_same_name)r$   kwargss     r(   checkzDjangoTemplates.check   s.    
446
==?
 	
r)   c                     | j                   j                  }t        |t              st	        d|dt        |      d| d      gS g S )NzC'string_if_invalid' in TEMPLATES OPTIONS must be a string but got: z (z).ztemplates.E002objid)r#   string_if_invalid
isinstancestrr   type)r$   values     r(   r,   z2DjangoTemplates._check_string_if_invalid_is_string$   sH    --%%',d5k;'	  	r)   c                    t        t              }t               D ]  \  }}||   j                  |        | j                  j
                  j                         D ]  \  }}||   j                  |        g }|j                         D ]W  \  }}t        |      dkD  sdj                  d t        |      D              }|j                  t        |d| | d             Y |S )Nr   z, c              3   2   K   | ]  }t        |        y wr+   )repr).0items     r(   	<genexpr>zNDjangoTemplates._check_for_template_tags_with_the_same_name.<locals>.<genexpr>>   s     !G$t*!Gs   z, is used for multiple template tag modules: ztemplates.W003r1   )r   setget_template_tag_modulesaddr#   r   itemslenjoinsortedappendr	   )r$   r   module_namemodule_patherrorslibrary_namerB   s          r(   r-   z;DjangoTemplates._check_for_template_tags_with_the_same_name1   s    $	(@(B 	4$Kk"&&{3	4 )-(=(=(C(C(E 	4$Kk"&&{3	4 #,??#4 
	L%5zA~		!G!GG'**V '# +	
	 r)   c                 L    t        | j                  j                  |      |       S r+   )Templater#   from_string)r$   template_codes     r(   rM   zDjangoTemplates.from_stringJ   s    //>EEr)   c                     	 t        | j                  j                  |      |       S # t        $ r}t	        ||        Y d }~y d }~ww xY wr+   )rL   r#   get_templater
   reraise)r$   template_nameexcs      r(   rP   zDjangoTemplates.get_templateM   s@    	DKK44]CTJJ# 	C	s   $' 	AAAc                 <    t               }|j                  |       |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   s      r(   r   z)DjangoTemplates.get_templatetag_librariesS   s!    
 ,-	)*r)   )__name__
__module____qualname__app_dirnamer    r/   r,   r-   rM   rP   r   __classcell__)r'   s   @r(   r   r      s-    K	B
2Fr)   r   c                   *    e Zd Zd Zed        ZddZy)rL   c                      || _         || _        y r+   )templatebackend)r$   r_   r`   s      r(   r    zTemplate.__init__^   s     r)   c                 .    | j                   j                  S r+   )r_   origin)r$   s    r(   rb   zTemplate.originb   s    }}###r)   Nc                     t        ||| j                  j                  j                        }	 | j                  j                  |      S # t        $ r }t        || j                         Y d }~y d }~ww xY w)N)r   )r   r`   r#   r   r_   renderr
   rQ   )r$   contextrequestrS   s       r(   rd   zTemplate.renderf   s^    W)<)<)G)G
	'==''00# 	'C&&	's   A	 		A2A--A2)NN)rX   rY   rZ   r    propertyrb   rd    r)   r(   rL   rL   ]   s      $ $'r)   rL   Nc                     |xs | 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).
    )triedr`   chaintemplate_debug)r`   r'   argsrj   rk   hasattrrl   rS   r`   news      r(   copy_exceptionrq   p   sR     $G
#--G399
UCs$% //Jr)   c                      t        | |      }|| )zT
    Reraise TemplateDoesNotExist while maintaining template debug information.
    )rq   ro   s      r(   rQ   rQ   }   s     g
&C
3r)   c               #   ,  K   dg} | j                  d t        j                         D               | D ]O  }	 t        |      }t        |d      st        |      D ]&  }|j                  |      j                  d      |f ( Q y# t        $ r Y ^w xY ww)z^
    Yield (module_name, module_path) pairs for all installed template tag
    libraries.
    zdjango.templatetagsc              3   :   K   | ]  }|j                    d   yw)z.templatetagsN)name)r<   
app_configs     r(   r>   z+get_template_tag_modules.<locals>.<genexpr>   s!      .8:??
=)s   __path__.N)	extendr   get_app_configsr   ImportErrorrn   get_package_librariesremoveprefixlstrip)
candidates	candidatepkgru   s       r(   r@   r@      s     
 ((J <@<P<P<R    	E			*C
 3
#-c2 E''	299#>DDE	E  		s.   3BBB7B	BBBBc                  J    t               D  ci c]  \  } }| |
 c}} S c c}} w )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.
    )r@   )rG   	full_names     r(   rU   rU      s.     >V=W#9;	Y  s   c              #      K   t        | j                  | j                  dz         D ]%  }	 t        |d         }t        |d      s|d    ' y# t        $ r}t        d|d   d|      |d}~ww xY ww)zZ
    Recursively yield template tag libraries defined in submodules of a
    package.
    rx   r   zLInvalid template library specified. ImportError raised when trying to load 'z': Nregister)r   rw   rX   r   r{   r   rn   )r   entrymodulees       r(   r|   r|      s     
 s||S\\C-?@ 
	"58,F 6:&(N
  	(-21Xq: 	s-   'A5AA5
A5	A2A--A22A5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   rL   rq   rQ   r@   rU   r|   rh   r)   r(   <module>r      sY    # # !    - 0 0 ) : Jj JZ' '&
E,	r)   