
    k"g                         d dl mZ d dl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mZ  G d
 de      Z G d d      Z G d d      Zd Zy)    )PathN)settings)TemplateDoesNotExistTemplateSyntaxError)cached_property)import_string   )
BaseEngine)csrf_input_lazycsrf_token_lazyc                   >     e Zd ZdZ fdZd Zd Zed        Z xZ	S )Jinja2jinja2c                 4   |j                         }|j                  d      j                         }t        |   |       |j                  dg       | _        |j                  dd      }t        |      }d|vr"t        j                  | j                        |d<   |j                  dd       |j                  dt        j                         |j                  d	t        j                  rt        j                  nt        j                          |d
i || _        y )NOPTIONScontext_processorsenvironmentzjinja2.Environmentloader
autoescapeTauto_reload	undefined )copypopsuper__init__r   r   r   FileSystemLoadertemplate_dirs
setdefaultr   DEBUGDebugUndefined	Undefinedenv)selfparamsoptionsr   environment_cls	__class__s        X/var/www/html/djangosite/lib/python3.12/site-packages/django/template/backends/jinja2.pyr   zJinja2.__init__   s    **Y',,. ")++.BB"Gkk-1EF'47" & 7 78J8J KGH<.=(..9(....fFVFV	
 #-W-    c                 L    t        | j                  j                  |      |       S N)Templater#   from_string)r$   template_codes     r)   r.   zJinja2.from_string%   s    ,,];TBBr*   c                 0   	 t        | j                  j                  |      |       S # t        j                  $ r}t        |j                  |       |d }~wt        j                  $ r-}t        |j                        }t        |      |_
        ||d }~ww xY w)N)backend)r-   r#   get_templater   TemplateNotFoundr   namer   argsget_exception_infotemplate_debug)r$   template_nameexcnews       r)   r2   zJinja2.get_template(   s    	DHH11-@$GG&& 	H&sxx>CG)) 	%chh/C!3C!8C3	s    $' BAB((BBc                 R    | j                   D cg c]  }t        |       c}S c c}w r,   )r   r   )r$   paths     r)   template_context_processorsz"Jinja2.template_context_processors2   s!    040G0GHd#HHHs   $)
__name__
__module____qualname__app_dirnamer   r.   r2   r   r=   __classcell__)r(   s   @r)   r   r      s.    K.(C I Ir*   r   c                       e Zd Zd ZddZy)r-   c                 l    || _         || _        t        |j                  |j                        | _        y )Nr4   r8   )templater1   Originfilenamer4   origin)r$   rF   r1   s      r)   r   zTemplate.__init__8   s,     """--
r*   Nc                 r   |i }|S||d<   t        |      |d<   t        |      |d<   | j                  j                  D ]  }|j	                   ||              	 | j
                  j                  |      S # t        j                  $ r-}t        |j                        }t        |      |_        ||d }~ww xY w)Nrequest
csrf_input
csrf_token)r   r   r1   r=   updaterF   renderr   r   r5   r6   r7   )r$   contextrK   context_processorr9   r:   s         r)   rO   zTemplate.render@   s    ?G!(GI$3G$<GL!$3G$<GL!%)\\%M%M ;!09:;	==''00)) 	%chh/C!3C!8C3	s   A6 6B6	(B11B6)NN)r>   r?   r@   r   rO   r   r*   r)   r-   r-   7   s    
r*   r-   c                       e Zd ZdZd Zy)rG   zc
    A container to hold debug information as described in the template API
    documentation.
    c                      || _         || _        y r,   rE   )r$   r4   r8   s      r)   r   zOrigin.__init__W   s    	*r*   N)r>   r?   r@   __doc__r   r   r*   r)   rG   rG   Q   s    
+r*   rG   c                    d}| j                   }| j                  }|5t        | j                        }|j	                         r|j                         }|kt        t        |j                         j                  d      d            }||dz
     d   }t        |      }t        d||z
  dz
        }t        |||z         }	n
d}g }dx}x}}	| j                  | j                  |||	 |d|d|||	d
S )z
    Format exception information for display on the debug page using the
    structure described in the template API documentation.
    
   
r	   )startr    )
r4   messagesource_lineslinebeforeduringaftertotaltopbottom)linenosourcer   rH   exists	read_textlist	enumeratestripsplitlenmaxminrZ   )
	exceptioncontext_linesrc   rd   exception_filelinesr^   r`   ra   rb   s
             r)   r6   r6   \   s   
 MFF~i001  "#--/FYv||~33D9CDvz"1%E
!Vm+a/0UF]23   f""$$c&) r*   )pathlibr   r   django.confr   django.templater   r   django.utils.functionalr   django.utils.module_loadingr   baser
   utilsr   r   r   r-   rG   r6   r   r*   r)   <module>ry      sE        E 3 5  3&IZ &IR 4+ +!r*   