
    wdf             	          d 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 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 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 ddl m!Z! ddl"m#Z# ddl$m%Z% dddddd d!d"d#Z& e'e(d$          rd$Z)nd%Z)d&gZ*	  e+d'           e*,                    d(           n# e-$ r Y nw xY w	  e+d)           d*Z.n# e-$ r d+Z.Y nw xY wd, Z/	 d?d.Z0d/ Z1d0 Z2 G d1 d2e3          Z4 G d3 d4e3          Z5 G d5 d6e6          Z7 G d7 d8e%          Z8 G d9 d:e%          Z9 G d; d<e:          Z; G d= d>e%          Z<d-S )@z0Compiles nodes from the parser into Python code.    )
namedtupleupdate_wrapper)chain)	iskeyword)escape)Markup   )nodes)imap)	iteritems)izip)NativeStringIO)
range_type)string_types)	text_type)TemplateAssertionError)Symbols)VAR_LOAD_ALIAS)VAR_LOAD_PARAMETER)VAR_LOAD_RESOLVE)VAR_LOAD_UNDEFINED)EvalContext)	Optimizer)concat)NodeVisitorz==z!=>z>=<z<=inznot in)eqnegtgteqltlteqr   notinr   itemsdivisionz%from __future__ import generator_stopgenerator_stopzdef f(): yield from x()TFc                 .      fd}t          |           S )Nc                     | j         rH|j        j        s<| j                            ||j                  }||k    r|                     ||          S  | ||fi |S N)	optimizedeval_ctxvolatile	optimizervisit)selfnodeframekwargsnew_nodefs        T/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/jinja2/compiler.pynew_funczoptimizeconst.<locals>.new_funcC   sm    > 	3%."9 	3~++D%.AAH4zz(E222qtU--f---    r   )r7   r9   s   ` r8   optimizeconstr;   B   s.    . . . . . (A&&&r:   Nc                     t          | t          j                  st          d          |                    ||||||          }|                    |            ||j                                        S dS )z+Generate the python source for a node tree.z Can't compile non template nodesN)
isinstancer   Template	TypeErrorcode_generator_classr1   streamgetvalue)r3   environmentnamefilenamerA   
defer_initr-   	generators           r8   generaterH   N   s~     dEN++ <:;;;00T8VZ I OOD~((*** ~r:   c                    | | t           u s	| t          u rdS t          |           t          t          t
          t          t          t          ft          z   v rdS t          |           t          t          t          t          fv r| D ]}t          |          s dS dS t          |           t          u r;t!          |           D ])\  }} t          |          s dS t          |           s dS *dS dS )z)Does the node have a safe representation?NTF)NotImplementedEllipsistypeboolintfloatcomplexr   r	   r   tuplelistset	frozensethas_safe_reprdictr   )valueitemkeys      r8   rU   rU   \   s    }//5H3D3DtE{{tS%*fETTTtE{{udC333 	 	D && uut	e		#E** 	 	JC %% uu '' uut5r:   c                     t          |          }	 | D ]}|                    |           n# t          $ r Y nw xY w|j        S )zCheck if the names passed are accessed undeclared.  The return value
    is a set of all the undeclared names from the sequence of names found.
    )UndeclaredNameVisitorr1   VisitorExit
undeclared)r   namesvisitorr3   s       r8   find_undeclaredr`   q   sh     $E**G 	  	 DMM$	    s   , 
99c                       e Zd Zd ZdS )MacroRefc                 >    || _         d| _        d| _        d| _        d S )NF)r3   accesses_calleraccesses_kwargsaccesses_varargsr2   r3   s     r8   __init__zMacroRef.__init__   s'    	$$ %r:   N)__name__
__module____qualname__rh    r:   r8   rb   rb   ~   s#        & & & & &r:   rb   c                   2    e Zd ZdZddZd Zd	dZd ZeZdS )
Framez&Holds compile time information for us.Nc                     || _         t          |r|j        pd |          | _        d| _        d| _        |o|j        | _        d | _        |r|j        pd | _        || _        ||j        | _        d S d S )NlevelF)	r.   r   symbolstoplevel	rootlevelrequire_output_checkbufferblockparent)r2   r.   rx   rq   s       r8   rh   zFrame.__init__   s     v8&.@DNNN 
  %+$Jv/J!  ,4
  -DKKK r:   c                     t                               | j                  }|j                            | j                   | j                                        |_        |S )z!Create a copy of the current one.)object__new__	__class____dict__updaterr   copyr2   rvs     r8   r   z
Frame.copy   sG    ^^DN++
4=)))\&&((
	r:   Fc                 v    |r#t          | j        | j        j        dz             S t          | j        |           S )zReturn an inner frame.r
   rp   )rn   r.   rr   rq   )r2   isolateds     r8   innerzFrame.inner   s<     	Fdl.@1.DEEEET]D)))r:   c                 <    |                                  }d|_        |S )a  Return a soft frame.  A soft frame may not be modified as
        standalone thing as it shares the resources with the frame it
        was created of, but it's not a rootlevel frame any longer.

        This is only used to implement if-statements.
        F)r   rt   r   s     r8   softz
Frame.soft   s     YY[[	r:   )NNF)	ri   rj   rk   __doc__rh   r   r   r   __copy__rl   r:   r8   rn   rn      sa        00( ( ( (>  * * * *	 	 	 HHHr:   rn   c                       e Zd ZdZdS )r\   z?Exception used by the `UndeclaredNameVisitor` to signal a stop.Nri   rj   rk   r   rl   r:   r8   r\   r\      s        IIIIr:   r\   c                   *    e Zd ZdZd Zd Zd Zd ZdS )DependencyFinderVisitorz.A visitor that collects filter and test calls.c                 R    t                      | _        t                      | _        d S r,   )rS   filterstestsr2   s    r8   rh   z DependencyFinderVisitor.__init__   s    uuUU


r:   c                 n    |                      |           | j                            |j                   d S r,   )generic_visitr   addrD   rg   s     r8   visit_Filterz$DependencyFinderVisitor.visit_Filter   s4    4   #####r:   c                 n    |                      |           | j                            |j                   d S r,   )r   r   r   rD   rg   s     r8   
visit_Testz"DependencyFinderVisitor.visit_Test   s2    4   
ty!!!!!r:   c                     dS )zStop visiting at blocks.Nrl   rg   s     r8   visit_Blockz#DependencyFinderVisitor.visit_Block         r:   N)ri   rj   rk   r   rh   r   r   r   rl   r:   r8   r   r      sV        88  $ $ $" " "' ' ' ' 'r:   r   c                   $    e Zd ZdZd Zd Zd ZdS )r[   zA visitor that checks if a name is accessed without being
    declared.  This is different from the frame visitor as it will
    not stop at closure frames.
    c                 T    t          |          | _        t                      | _        d S r,   )rS   r^   r]   )r2   r^   s     r8   rh   zUndeclaredNameVisitor.__init__   s    ZZ
%%r:   c                     |j         dk    rM|j        | j        v r?| j                            |j                   | j        | j        k    rt                      d S | j                            |j                   d S )Nload)ctxrD   r^   r]   r   r\   discardrg   s     r8   
visit_Namez UndeclaredNameVisitor.visit_Name   sv    8v$)tz"9"9O	***$*,,!mm# -, Jty)))))r:   c                     dS )zStop visiting a blocks.Nrl   rg   s     r8   r   z!UndeclaredNameVisitor.visit_Block   r   r:   N)ri   rj   rk   r   rh   r   r   rl   r:   r8   r[   r[      sK         
     * * *& & & & &r:   r[   c                       e Zd ZdZdS )CompilerExitzRaised if the compiler encountered a situation where it just
    doesn't make sense to further process the code.  Any block that
    raises such an exception is not further processed.
    Nr   rl   r:   r8   r   r      s           r:   r   c                      e Zd Z	 dmdZd Zd Zd ZdndZd	 ZdodZ	dpdZ
d ZdpdZd Zd ZdqdZdqdZdpdZd Zd ZdndZd Zd Zd Zd Zd Zd Zd Zd Zd  Zd! Zd" Zd# Z d$ Z!d% Z"d& Z#d' Z$d( Z%dpd)Z&d* Z'd+ Z(d, Z)d- Z*d. Z+d/ Z,d0 Z-d1 Z.d2 Z/d3 Z0d4 Z1d5 Z2 e3d6d7          Z4e5Z6dZ7d8 Z8d9 Z9d: Z:d; Z;d< Z<d= Z=d> Z>d? Z?d@ Z@dA ZAdB ZBdC ZCdD ZDdE ZEdF ZFdrdGZGdrdHZH eGdI          ZI eGdJ          ZJ eGdK          ZK eGdL          ZL eGdM          ZM eGdN          ZN eGdO          ZO eGdPdQ          ZP eGdRdQ          ZQ eHdI          ZR eHdJ          ZS eHdSdQ          ZT[G[HeUdT             ZVeUdU             ZWdV ZXeUdW             ZYeUdX             ZZdY Z[eUdZ             Z\eUd[             Z]eUd\             Z^eUdnd]            Z_d^ Z`d_ Zad` Zbda Zcdb Zddc Zedd Zfde Zgdf Zhdg Zidh Zjdi Zkdj Zldk Zmdl ZndS )sCodeGeneratorNFTc                    |t                      }|| _        || _        || _        || _        d| _        || _        || _        |rt          |          | _	        i | _
        i | _        d| _        d| _        d| _        i | _        i | _        g | _        d | _        d| _        d| _        d| _        d| _        d| _        g | _        g | _        dg| _        d S )NFr   r
   Tcontext)r   rC   rD   rE   rA   created_block_contextrF   r-   r   r0   import_aliasesblocksextends_so_farhas_known_extendscode_linenor   r   
debug_info_write_debug_info
_new_lines
_last_line_first_write_last_identifier_indentation_assign_stack_param_def_block_context_reference_stack)r2   rC   rD   rE   rA   rF   r-   s          r8   rh   zCodeGenerator.__init__   s    >#%%F&	 %*"$" 	4&{33DN !   
 "'  
 !%   ! !"    !# *3%%%r:   c                 :    t          ||| j        | j                  )z*Fail with a :exc:`TemplateAssertionError`.)r   rD   rE   )r2   msglinenos      r8   failzCodeGenerator.fail<  s    $S&$)T]KKKr:   c                 6    | xj         dz  c_         d| j         z  S )zGet a new unique identifier.r
   zt_%d)r   r   s    r8   temporary_identifierz"CodeGenerator.temporary_identifier@  s$    "---r:   c                 r    |                                  |_        |                     d|j        z             dS )z7Enable buffering for the frame from that point onwards.z%s = []N)r   rv   	writeliner2   r4   s     r8   rv   zCodeGenerator.bufferE  s4    0022y5</00000r:   c                    |s|j         j        r|                     d           |                                  |                     d|j        z             |                                  |                     d           |                                  |                     d|j        z             |                                  dS |j         j        r|                     d|j        z             dS |                     d|j        z             dS )z(Return the buffer contents of the frame.zif context.eval_ctx.autoescape:zreturn Markup(concat(%s))else:zreturn concat(%s)N)r.   r/   r   indentrv   outdent
autoescape)r2   r4   force_unescapeds      r8   return_buffer_contentsz$CodeGenerator.return_buffer_contentsJ  s     	~& @AAA:U\IJJJw'''2U\ABBB* :U\IJJJ*U\9:::::r:   c                 &    | xj         dz  c_         dS )zIndent by one.r
   Nr   r   s    r8   r   zCodeGenerator.indent\  s    Qr:   r
   c                 &    | xj         |z  c_         dS )zOutdent by step.Nr   )r2   steps     r8   r   zCodeGenerator.outdent`  s    T!r:   c                     |j         |                     d|           dS |                     d|j         z  |           dS )z%Yield or write into the frame buffer.Nyield 
%s.append()rv   r   )r2   r4   r3   s      r8   start_writezCodeGenerator.start_writed  sE    <NN8T*****NN<%,6=====r:   c                 B    |j         |                     d           dS dS )z1End the writing process started by `start_write`.N))rv   writer   s     r8   	end_writezCodeGenerator.end_writek  s%    <#JJsOOOOO $#r:   c                     |                      ||           |                     |           |                     |           dS )z4Simple shortcut for start_write + write + end_write.N)r   r   r   )r2   sr4   r3   s       r8   simple_writezCodeGenerator.simple_writep  s?    %%%

1ur:   c                     	 |                      d           |D ]}|                     ||           dS # t          $ r Y dS w xY w)zVisit a list of nodes as block in a frame.  If the current frame
        is no buffer a dummy ``if 0: yield None`` is written automatically.
        passN)r   r1   r   )r2   r   r4   r3   s       r8   
blockvisitzCodeGenerator.blockvisitv  sk    	NN6""" ( (

4''''( ( 	 	 	DD	s   04 
AAc                    | j         r| j        sk| j                            d| j         z             | xj        | j         z  c_        | j        -| j                            | j        | j        f           d| _        d| _        | j                            d| j        z             d| _         | j                            |           dS )z&Write a string into the output stream.
NFz    r   )	r   r   rA   r   r   r   r   appendr   )r2   xs     r8   r   zCodeGenerator.write  s    ? 		 $ 2!!$"8999  DO3  )5O**D,BDDT+UVVV-1D* %DKft'88999DO!r:   r   c                 \    |                      ||           |                     |           dS )z!Combination of newline and write.N)newliner   )r2   r   r3   extras       r8   r   zCodeGenerator.writeline  s)    T5!!!

1r:   c                     t          | j        d|z             | _        |*|j        | j        k    r|j        | _        |j        | _        dS dS dS )z/Add one or more newlines before the next write.r
   N)maxr   r   r   r   )r2   r3   r   s      r8   r   zCodeGenerator.newline  sR    doq5y99t > >%)[D""kDOOO  > >r:   c                    d}t          d |j        D             |pd          D ]}t          |          rd} n|j        D ]-}|                     d           |                     ||           .|sg|j        D ]-}|                     d           |                     ||           .|0t          |          D ] \  }}|                     d|d|           !|j        r0|                     d           |                     |j        |           |r |j        |                     d	           n|                     d
           |j        D ]O}|                     d|j	        z             |                     |j
        |           |                     d           P|0t          |          D ] \  }}|                     |d|d           !|j        G|                     d           |                     |j        |           |                     d           dS |                     d           dS |j        2|                     d           |                     |j        |           dS dS )a+  Writes a function call to the stream for the current node.
        A leading comma is added automatically.  The extra keyword
        arguments may not include python keywords otherwise a syntax
        error could occur.  The extra keyword arguments should be given
        as python dict.
        Fc              3   $   K   | ]}|j         V  d S r,   )rY   .0r   s     r8   	<genexpr>z*CodeGenerator.signature.<locals>.<genexpr>  s$      77aAE777777r:   rl   T, N=z, *z
, **dict({z, **{z%r: : z}, **r   }z, **)r   r5   is_python_keywordargsr   r1   r   dyn_args
dyn_kwargsrY   rW   )	r2   r3   r4   extra_kwargskwarg_workaroundkwargargrY   rW   s	            r8   	signaturezCodeGenerator.signature  s    !774;7779KLL 	 	E '' #'  9 	# 	#CJJtJJsE"""" 	9 ) )

4   

5%(((('"+L"9"9 9 9JCJJJCCC78888= 	-JJuJJt}e,,, 	/*

<((((

7### ! !

6EI-...

5;...

4    '"+L"9"9 : :JCJJSSS%%%89999*

7###

4?E222

3

3_(JJvJJt..... )(r:   c           
      $   t                      }|D ]}|                    |           dD ]d}t          | |          }t          ||          D ]A}||vr|                                 ||<   |                     ||         d|d|d           BedS )zPull all the dependencies.)r   r   z = environment.[]N)r   r1   getattrr   r   )r2   r   r_   r3   
dependencymappingrD   s          r8   pull_dependencieszCodeGenerator.pull_dependencies  s    )++ 	  	 DMM$, 	 	JdJ//G44  w&&$($=$=$?$?GDM18


DDDQ   	 	r:   c           	         g }t          |j        j                  D ]\  }\  }}|t          k    r|t          k    r1|                     |d|                                 d|d           P|t          k    r|                     |d|           v|t          k    r|	                    |           t          d          |r-|                     dd                    |          z             d S d S )N = (r   zunknown load instruction%s = missing)r   rr   loadsr   r   r   get_resolve_funcr   r   r   NotImplementedErrorjoin)r2   r4   undefstargetactionparams         r8   enter_framezCodeGenerator.enter_frame  s   '01D'E'E 
	F 
	F#FOVU++++++8M8M8O8O8O8OQVQVQVWXXXX>))FFFEE:;;;;---f%%%%)*DEEE 	@NN>EJJv,>,>>?????	@ 	@r:   c                     |seg }t          |j        j                  D ]\  }}|                    |           |r/|                     dd                    |          z             d S d S d S )Nr   r   )r   rr   r  r   r   r  )r2   r4   with_python_scoper  r  _s         r8   leave_framezCodeGenerator.leave_frame  s      	DF&u}':;; & &	f%%%% D~

60B0BBCCCCC	D 	DD Dr:   c                 .    | j         j        rd|z  S d|z  S )Nzasync def %szdef %s)rC   is_async)r2   rD   s     r8   funczCodeGenerator.func  s%    $ 	)!D(($r:   c           
      T   |                                 }|j                            |           t          |          }d}t	                      }g }t          |j                  D ]g\  }}|j        dk    r|}|j        dv r|                    |j                   |	                    |j        
                    |j                             ht          |j        d          }	d|	v r|O	 |j        |t          |j                  z
            nX# t          $ r |                     d|j                   Y n1w xY w|	                    |j                            d                     d|_        d|	v r8d|vr4|	                    |j                            d                     d|_        d|	v r8d|vr4|	                    |j                            d                     d|_        d	|_        |j                            |           |                     |                     d
          dd                    |          d|           |                                  |                     |           |                     |           |                     |           t          |j                  D ]\  }}|j        
                    |j                  }
|                     d|
z             |                                  	 |j        |t          |j                  z
           }|                     d|
z             |                     ||           n;# t          $ r. |                     |
dd|j        z  d|j        d           Y nw xY w|                     |
           |                                   	| !                                 | "                    |j        |           | #                    |d           | $                    |d           |                                   ||fS )z/Dump the function def of a macro or call block.Ncaller)r5   varargs)r  r5   r  zhWhen defining macros or call blocks the special "caller" argument must be omitted or be given a default.Tr5   r  Fmacror   r   ):if %s is missing:%s =  = undefined(zparameter %r was not providedz, name=r   )r   r  )%r   rr   analyze_noderb   rS   	enumerater   rD   r   r   refr`   bodydefaultslen
IndexErrorr   r   declare_parameterrd   re   rf   ru   r   r  r  r   rv   r	  push_parameter_definitionsr1   mark_parameter_storedr   pop_parameter_definitionsr   r   r  )r2   r3   r4   	macro_refexplicit_callerskip_special_paramsr   idxr   r]   r  defaults               r8   
macro_bodyzCodeGenerator.macro_body  s7   ""4(((TNN	!ee!$),, 	5 	5HCx8##"%x000#''111KK))#(334444$TY0OPP
z!! *M/C	NN"BCCC!   II1 	     EM;;HEEFFF(,I%z!!h6I&I&IKK77AABBB(,I%
""y8K'K'KKK77	BBCCC)-I& &+"""4(((DIIg$6$6$6$6		$H$OOOE''...!$),, 	 	HC-##CH--CNN.4555KKMMM	+-c$)nn(<= w}---

7E****    ss;chFFFR     &&s+++LLNNNN&&(((	5)))##E4#@@@$777is$   ("D %D32D3>"M5NNc                 0   d                     d |j        j        D                       }t          |j        dd          }t	          |j        j                  dk    r|dz  }|                     d|d|d	|j        d|j        d|j        d
           dS )z<Dump the macro definition for the def created by macro_body.r   c              3   >   K   | ]}t          |j                  V  d S r,   )reprrD   r   s     r8   r   z*CodeGenerator.macro_def.<locals>.<genexpr>M  s*      HHqd16llHHHHHHr:   rD   Nr
   ,zMacro(environment, macro, z, (z), z, context.eval_ctx.autoescape))	r  r3   r   r   r  r   re   rf   rd   )r2   r%  r4   	arg_tuplerD   s        r8   	macro_defzCodeGenerator.macro_defK  s    IIHHIN4GHHHHH	y~vt44y~"##q((I


 		)))***)))
	
 
	
 
	
 
	
 
	
r:   c                 \    d|j         z  }| j        |dt          | j                  z   z  }|S )z.Return a human readable position for the node.zline %dN in )r   rD   r-  )r2   r3   r   s      r8   positionzCodeGenerator.position]  s2    $9 &4	??**B	r:   c                     dd                     d t          |j                                                  D                       z  S )Nz{%s}r   c              3   *   K   | ]\  }}|d |V  dS r   Nrl   )r   rD   r  s      r8   r   z3CodeGenerator.dump_local_context.<locals>.<genexpr>e  sE       "
 "
f ff%"
 "
 "
 "
 "
 "
r:   )r  r   rr   dump_storesr   s     r8   dump_local_contextz CodeGenerator.dump_local_contextd  sQ    		 "
 "
 )%-*C*C*E*E F F"
 "
 "
 
 
 
 	
r:   c                     |                      d           |                      d           |                      d           |                      d           dS )zWrites a common preamble that is used by root and block functions.
        Primarily this sets up common local helpers and enforces a generator
        through a dead branch.
        z$resolve = context.resolve_or_missingz!undefined = environment.undefinedzcond_expr_undefined = Undefinedzif 0: yield NoneNr   r   s    r8   write_commonszCodeGenerator.write_commonsj  sX    
 	=>>>:;;; 	8999)*****r:   c                 h    | j                             |j                                                   dS )aQ  Pushes all parameter targets from the given frame into a local
        stack that permits tracking of yet to be assigned parameters.  In
        particular this enables the optimization from `visit_Name` to skip
        undefined expressions for parameters in macros as macros can reference
        otherwise unbound parameters.
        N)r   r   rr   dump_param_targetsr   s     r8   r"  z(CodeGenerator.push_parameter_definitionsv  s/     	$$U]%E%E%G%GHHHHHr:   c                 8    | j                                          dS )z+Pops the current parameter definitions set.N)r   popr   s    r8   r$  z'CodeGenerator.pop_parameter_definitions  s    !!#####r:   c                 X    | j         r"| j         d                             |           dS dS )zMarks a parameter in the current parameter definitions as stored.
        This will skip the enforced undefined checks.
        N)r   r   r2   r  s     r8   r#  z#CodeGenerator.mark_parameter_stored  s;       	6!"%--f55555	6 	6r:   c                 :    | j                             |           d S r,   )r   r   rB  s     r8   push_context_referencez$CodeGenerator.push_context_reference  s    %,,V44444r:   c                 8    | j                                          d S r,   )r   r?  r   s    r8   pop_context_referencez#CodeGenerator.pop_context_reference  s    %))+++++r:   c                     | j         d         S )NrA  r   r   s    r8   get_context_refzCodeGenerator.get_context_ref  s    ,R00r:   c                 6    | j         d         }|dk    rdS d|z  S )NrA  r   resolvez
%s.resolverH  rB  s     r8   r  zCodeGenerator.get_resolve_func  s*    .r2Y9f$$r:   c                 \    |                                  d|                     |          dS )Nz	.derived(r   )rI  r8  r   s     r8   derive_contextzCodeGenerator.derive_context  s8      """"##E****
 	
r:   c                 2    | j         sdS || j         d         v S )z4Checks if a given target is an undeclared parameter.FrA  )r   rB  s     r8   parameter_is_undeclaredz%CodeGenerator.parameter_is_undeclared  s%    $ 	5.r222r:   c                 R    | j                             t                                 dS )z+Pushes a new layer for assignment tracking.N)r   r   rS   r   s    r8   push_assign_trackingz"CodeGenerator.push_assign_tracking  s#    !!#%%(((((r:   c           	      .   | j                                         }|j        r|sdS d |D             }t          |          dk    rRt	          t          |                    }|j                            |          }|                     d|d|           n|                     d           t          |          D ]P\  }}|r| 
                    d           |j                            |          }| 
                    |d|           Q| 
                    d	           |rst          |          dk    r |                     d
|d         z             dS |                     dd                    t          t          |                    z             dS dS )zoPops the topmost level for assignment tracking and updates the
        context variables if necessary.
        Nc                 .    g | ]}|d d         dk    |S )Nr
   r  rl   r   s     r8   
<listcomp>z5CodeGenerator.pop_assign_tracking.<locals>.<listcomp>  s%    888a1RaR5C<<<<<r:   r
   context.vars[] = zcontext.vars.update({r   r   z})context.exported_vars.add(%r)r   z"context.exported_vars.update((%s)))r   r?  rs   r  nextiterrr   r  r   r  r   r  r   r-  )r2   r4   varspublic_namesrD   r  r(  s          r8   pop_assign_trackingz!CodeGenerator.pop_assign_tracking  s    !%%''~ 	T 	F884888t99>>T

##D-##D))CNNNdddCC@AAAANN2333&t__ 3 3	T %JJt$$$m''--

tttSS12222JJt 	<  A%%>aPQQQQQ8iiT< 8 899:    		 	r:   c           	         |
J d            t          | j        | j                  }ddlm} |                     dd                    t                    z             |                     dd                    |          z              | j        j        r|                     d           | j	         rdpd	}|
                    t          j                  d u}|                    t          j                  D ]B}|j        | j        v r#|                     d
|j        z  |j                   || j        |j        <   C|                    t          j                  D ]}|j        | j        vr||j        }	|                                 x| j        |	<   }
d|	v r8|	                    dd          \  }}|                     d|d|d|
           q|                     d|	d|
           |                     d| j        z             |                     |                     d          d|dd           |                                  |                                  t5          |          }dt7          |j        d          v r2|j                            d          }|                     d|z             |j                            |           dx|_         |_!        |o| j"         |_#        |r|                     d           | $                    |           | %                    |j                   | &                    |j        |           | '                    |d           | (                                 |r| j"        s)|                                  |                     d           |                                  tR          r"| j        j        s|                     d           nc|                     d| j        j        rdpd	z             |                                  |                     d           | (                                 | (                    d| j"         z              tU          | j                  D ]\  }}|                     |                     d |z             d|d|d           |                                  |                                  t5          |          }t7          |j        d!          }d|v r2|j                            d          }|                     d|z             d"|v r8|j                            d"          }|                     |d#|d$|d%           |j                            |           ||_+        | $                    |           | %                    |j                   | &                    |j        |           | '                    |d           | (                                 |                     d&d                    d' | j        D                       z  d           |                     d(d)                    d* | j,        D                       z             d S )+Nzno root frame allowedr
   )exportedzfrom __future__ import %sr   zfrom jinja2.runtime import zHfrom jinja2.asyncsupport import auto_await, auto_aiter, AsyncLoopContextz, environment=environment zblock %r defined twice.zfrom z import z as zimport z	name = %rrootz(context, missing=missingr  )r   r2   r   z%s = TemplateReference(context)Tzparent_template = Noner  if parent_template is not None:z4yield from parent_template.root_render_func(context)z9%sfor event in parent_template.root_render_func(context):zasync zyield eventblock_)r2   superrd  z = context.super(z, block_r   zblocks = {%s}c              3   $   K   | ]}|d |V  dS )z: block_Nrl   r   s     r8   r   z/CodeGenerator.visit_Template.<locals>.<genexpr>;  s-      'U'UA!!!QQ(?'U'U'U'U'U'Ur:   zdebug_info = %r&c              3       K   | ]	}d |z  V  
dS )z%s=%sNrl   r   s     r8   r   z/CodeGenerator.visit_Template.<locals>.<genexpr>A  s&      (N(N1(N(N(N(N(N(Nr:   )-r   rC   rD   runtimer^  r   r  code_featuresr  rF   findr   Extendsfind_allBlockr   r   r   ImportedName
importnamer   r   rsplitr  r   r;  rn   r`   r  rr   r!  r  rs   rt   r   ru   r	  r   r   r  r   supports_yield_fromr   rw   r   )r2   r3   r4   r.   r^  envenvhave_extendsrw   import_impaliasmoduleobjr  rD   block_framer]   s                    r8   visit_TemplatezCodeGenerator.visit_Template  s   }}5}}}t/;;%%%%%%2TYY}5M5MMNNN4tyy7J7JJKKK$ 	NN/   _$D)DJ yy//t; ]]5;// 	, 	,EzT[((		2UZ?NNN&+DK
## }}U%788 	E 	EG!)<<<(373L3L3N3NN#C(5#::"%**S!"4"4KFCNNNUU#STTTTNNNUU#CDDD 	{TY./// 	1561B1B1B1BFFFKST 	 	
 	
 	
 	 h_TY	::::-11&99CNN<sBCCC""4(((+//%1%P$:P6P" 	5NN3444ty)))	5)))$777  	;) B@AAAKKMMM" 
4+;+D 
UVVVV1'0=XCE  
 }---LL$"889::: %T[11 	 	KD%NN99X_----vvv7	   KKMMM     //K(5FGGJ##!);;FCC@3FGGG*$$!);;GDDSSS$$$PTPTPTUVVV,,U333 $K[)))""5:...OOEJ444[DAAALLNNNNdii'U'U'U'U'UUUU 	 	
 	
 	
 	(N(Ndo(N(N(N N NN	
 	
 	
 	
 	
r:   c                    d}|j         rB| j        rdS | j        dk    r.|                     d           |                                  |dz  }|j        r|                     |          }n|                                 }t          r6| j	        j
        s*|j        #|                     d|j        d|d|           nr| j	        j
        rdpd	}|                     |d
|j        d|d|           |                                  |                     d|           |                                  |                     |           dS )z.Call a block and register it for the template.r   Nif parent_template is None:r
   zyield from context.blocks[z][0](r   	async forforz event in context.blocks[r  event)rs   r   r   r   r   scopedrM  rI  rq  rC   r  rv   rD   r   r   )r2   r3   r4   rq   r   loops         r8   r   zCodeGenerator.visit_BlockD  so   > 	 % "Q&&<===
; 	-))%00GG**,,G  	$-	 $NNN:>)))WWWMt    #,<EDNN<@DD$)))WWWU   KKMMMgu---LLNNNUr:   c                    |j         s|                     d|j                   | j        dk    rq| j        s)|                     d           |                                  |                     ddz             | j        rt                      |                                  |                     d|           | 	                    |j
        |           |                     d| j        z             |                     dt          z             |                                  |                     d	           |                                  |j        rd
| _        | xj        dz  c_        dS )zCalls the extender.z,cannot use extend from a non top-level scoper   rb  raise TemplateRuntimeError(%r)zextended multiple timesz+parent_template = environment.get_template(, %r)z6for name, parent_block in parent_template.blocks.%s():z8context.blocks.setdefault(name, []).append(parent_block)Tr
   N)rs   r   r   r   r   r   r   r   r   r1   templater   rD   dict_item_iterrt   r2   r3   r4   s      r8   visit_ExtendszCodeGenerator.visit_Extendsj  s_   ~ 	SIIDdkRRR
 "" ) @AAANN;>WWXXX % "nn$DdKKK

4=%(((

7TY&'''D~U	
 	
 	
 	QRRR
 ? 	*%)D" 	q r:   c                 \   |j         r)|                     d           |                                  d}t          |j        t
          j                  rKt          |j        j        t                    rd}nVt          |j        j        t          t          f          rd}n-t          |j        t
          j        t
          j        f          rd}|                     d|z  |           |                     |j        |           |                     d| j        z             |j         r|                                  |                     d           |                                  |                     d           |                                  |                     d	           |                                  d
}|j        r?| j        j        rdpd}|                     |d|                     |          d           nV| j        j        r|                     d           n4t*          r|                     d           d}n|                     d           |s>|                                  |                     d|           |                                  |j         r|                                  dS dS )zHandles includes.ztry:get_or_select_templateget_templateselect_templateztemplate = environment.%s(r  zexcept TemplateNotFound:r   r   Fr}  r~  zR event in template.root_render_func(template.new_context(context.get_all(), True, z)):zGfor event in (await template._get_default_module_async())._body_stream:z6yield from template._get_default_module()._body_streamTz9for event in template._get_default_module()._body_stream:r  N)ignore_missingr   r   r=   r  r   ConstrW   r   rQ   rR   TupleListr1   r   rD   r   with_contextrC   r  r8  rq  r   )r2   r3   r4   	func_nameskip_event_yieldr  s         r8   visit_IncludezCodeGenerator.visit_Include  s    	NN6"""KKMMM,	dmU[11 	*$--|<< .*		DM/%?? .-	UZ'@AA 	*)I3i?FFF

4=%(((

7TY&''' 	LLNNNNN5666KKMMMNN6"""LLNNNNN7###KKMMM  	#,<EDNN  44!8!8!?!?!?!?A   
 & 	NN!    # WXXX#'  O     	KKMMMgu---LLNNN 	LLNNNNN	 	r:   c                    |                      d|j                            |j                  z  |           |j        r|                     d|j        z             | j        j        r|                     d           |                     d           |                     |j	        |           |                     d| j
        z             |j        r>|                     d| j        j        rdpdd	|                     |          d
           n7| j        j        r|                     d           n|                     d           |j        r9|j                            d          s!|                      d|j        z             dS dS dS )zVisit regular imports.r  context.vars[%r] = await zenvironment.get_template(, %r).make_module_asyncr_  (context.get_all(), True, r   _get_default_module_async()_get_default_module()r  !context.exported_vars.discard(%r)N)r   rr   r  r  rs   r   rC   r  r1   r  rD   r  r8  
startswithr  s      r8   visit_ImportzCodeGenerator.visit_Import  s   w!2!24;!?!??FFF> 	<JJ,t{:;;;$ 	!JJx   

.///

4=%(((

8di'((( 	0JJJ $-:(@b@@++E2222    & 	0JJ45555JJ.///> 	N$+"8"8"="= 	NNN>LMMMMM	N 	N 	N 	Nr:   c                    |                      |           |                     d| j        j        rdpdz             |                     |j                   |                     d| j        z             |j        r>|                     d| j        j        rdpdd|                               d           n7| j        j        r|                     d	           n|                     d
           g }g }|j	        D ]M}t          |t                    r|\  }}n|}|                     j                            |          d|d           |                     dj                            |          z             |                                  |                     j                            |          dd|                     |          dt#          |          d|d           |                                  j        r?|                    |           |                    d          s|                    |           O|rt-          |          dk    r<|d         }|                     d|dj                            |                     n7|                     dd                    fd|D                       z             |rst-          |          dk    r |                     d|d         z             dS |                     dd                    t1          t"          |                    z             dS dS )zVisit named imports.z/included_template = %senvironment.get_template(r  r_  r  r  r  r  r   r  r  z = getattr(included_template, z
, missing)r  r  zthe template %r (imported on z%) does not export the requested name z$ % included_template.__name__, name=r  r
   r   rU  rV  zcontext.vars.update({%s})r   c              3   V   K   | ]#}|d j                             |          V  $dS r6  )rr   r  )r   rD   r4   s     r8   r   z1CodeGenerator.visit_FromImport.<locals>.<genexpr>(  sP          GKDDD%-*;*;D*A*A*AB           r:   r  z-context.exported_vars.difference_update((%s))N)r   r   rC   r  r1   r  rD   r  r8  r^   r=   rQ   r   rr   r  r   r3  r-  r   rs   r   r  r  r  r   )r2   r3   r4   	var_namesdiscarded_namesrD   rv  s     `    r8   visit_FromImportzCodeGenerator.visit_FromImport  s   T

=(5X;=	
 	
 	
 	

4=%(((

8di'((( 	0JJJ $-:(@b@@++E2222    & 	0JJ45555JJ.///	J 	2 	2D$&& "eeNN"'-"3"3E":":":":DDDB   NN.1B1B51I1IIJJJKKMMMNN
 M%%e,,,,, }}T****DJJJ8 8 8 DD	   LLNNN~ 2  ''''',, 2#**5111 	9~~"" |/3ttU]5F5Ft5L5L5LM    /ii        OX           	?##q((B_UVEWWXXXXX#%)YYtD//J/J%K%KL    		 	r:   c                    |                                 }|                                 }|                                 }|j        p%dt          |                    d          d          v }d }|r|j                            d          }|j                            |d           |j        r|j                            |d           |j        r| 	                                }|j                            |d           | 
                    d	|                     |          z  |j                   |                                  |                     |           | 
                    | j        j        rd
pd           |                     |j        |           |                     d           |                     | j        j        rdpd           |                     d           |                                  | 
                    d|j                   |                     |j        |           |                     d           |                                  | 
                    d           |                     |j        |           |                     d           |                     |d           |j        ra| 
                    d|                     d          z  |           |                                  |                     |           |j        |_        |r| 
                    d|z             |                    t.          j                  D ]3}	|	j        dk    r&|	j        dk    r|                     d|	j                   4|j        r,| 	                                }
| 
                    d|
z             | 
                    | j        j        rd
pd|           |                     |j        |           |r>| j        j        r|                     d|z             n.|                     d|z             n|                     d           |j        r|                     d|z             |j        r|                     d           na| j        j        r|s|                     d           |                     |j        |           | j        j        r|s|                     d           |j        r|                     d           |j        r|                     d            n|                     |rd!pd           |                                  |                     |           |                     |j        |           |j        r| 
                    d"|
z             |                                  |                     ||j        o|j                    |j        r| 
                    d#|
z             |                                  |                     |           |                     |j        |           |                     |           |                                  |j        r|                      |           |                                  | !                    ||           | j        j        r|                     d$           |                     d%           | j        j        r|                     d           |                     |j        |           | j        j        r|                     d           |                     d&           | "                    |           d S d S )'Nr  )r  )only)r  r  )
for_branchelsetestz
%s(fiter):z
async for zfor r2  zauto_aiter(fiter)fiter:if r      Tr  z'%s(reciter, loop_render_func, depth=0):r   storez8Can't assign to special loop variable in for-loop targetz%s = 1z, %s in AsyncLoopContext(z, %s in LoopContext(z%s(reciterzauto_aiter(r   z&, undefined, loop_render_func, depth):z, undefined):z%s = 0zif %s:r  zloop(z, loop))#r   	recursiver`   iter_child_nodesrr   r!  r  else_r  r   r   r  r   r	  rC   r  r1   r  r   r   r  rv   rl  r   Namer   rD   r   r   rY  r   r  r   r   r   )r2   r3   r4   
loop_frame
test_frame
else_frameextended_looploop_refloop_filter_funcrD   iteration_indicators              r8   	visit_ForzCodeGenerator.visit_For5  s   [[]]
[[]]
[[]]

  
&O!!y!1195
 5
 +
  	D!);;FCCH'''@@@: 	E++DV+DDD9 	A#88::++DV+DDDNN<$))4D*E*EEtyQQQKKMMMZ(((NN4+4EOPPPJJt{J///JJvJJt'0H5HSGTTTJJsOOOKKMMMNN5$),,,JJty*---JJsOOOKKMMMNN8$$$JJt{J///LLOOOZ4@@@
 > 	2NN9DIIf<M<MMt   KKMMMKK
### !+ 1J  	6NN>H4555MM%*-- 	 	Dx7""tyF':':		NK  
 : 	;"&";";"="=NN8&99:::t'0A\KVTRRR

4;
+++ 	( >

6ABBBB

1H<====JJv9 	1JJu//000> 	 JJy!!!!( * *

=)))JJty%((((    

39 	JJsOOO> 	AJJ?@@@@JJ}8?C@@@$$$	:...: 	;NN8&99:::$.*K^ 	 	
 	
 	
 : 	NN8&99:::KKMMMZ(((OODJ
333Z(((LLNNN > 	"''
333LLNNNUD)))( %

8$$$JJw( *

=)))JJty%((((  

3JJy!!!NN5!!!!!	" 	"r:   c                 (   |                                 }|                     d|           |                     |j        |           |                     d           |                                  |                     |j        |           |                                  |j	        D ]}|                     d|           |                     |j        |           |                     d           |                                  |                     |j        |           |                                  |j
        rZ|                     d           |                                  |                     |j
        |           |                                  d S d S )Nr  r  zelif r   )r   r   r1   r  r   r   r   r  r   elif_r  )r2   r3   r4   if_framer  s        r8   visit_IfzCodeGenerator.visit_If  sN   ::<<ud###

49h'''

3	8,,,Z 	 	ENN7E***JJuz8,,,JJsOOOKKMMMOOEJ111LLNNNN: 	NN7###KKMMMOODJ111LLNNNNN		 	r:   c                    |                      ||          \  }}|                                  |j        rT|j                            d          s|                     d|j        z             |                     d|j        z             |                     d|j                            |j                  z             | 	                    ||           d S )Nr  rW  r  r  )
r*  r   rs   rD   r  r   r   rr   r  r0  )r2   r3   r4   macro_framer%  s        r8   visit_MacrozCodeGenerator.visit_Macro  s    !%u!=!=Y> 	>9'',, H

:TYFGGGNN049<===

7U]..ty999:::y+.....r:   c                    |                      ||          \  }}|                     d           |                     ||           |                     ||           |                     |j        |d           |                     |           d S )Nz	caller = T)forward_caller)r*  r   r0  r   
visit_Callcallr   )r2   r3   r4   
call_framer%  s        r8   visit_CallBlockzCodeGenerator.visit_CallBlock  s     $e < <
I{###y*---%%%	5>>>ur:   c                    |                                 }|j                            |           |                     |           |                     |           |                     |j        |           |                     ||           |                     |j	        |           | 
                    |           |                     |           d S r,   )r   rr   r  r	  rv   r   r  r   r   filterr   r  )r2   r3   r4   filter_frames       r8   visit_FilterBlockzCodeGenerator.visit_FilterBlock  s    {{}}))$///&&&L!!!	<000%%%$+|444u&&&&&r:   c                    |                                 }|j                            |           |                     |           t	          |j        |j                  D ]Z\  }}|                                  |                     ||           | 	                    d           |                     ||           [| 
                    |j        |           |                     |           d S Nr   )r   rr   r  r	  r   targetsvaluesr   r1   r   r   r  r  )r2   r3   r4   
with_framer  exprs         r8   
visit_WithzCodeGenerator.visit_With  s    [[]]
''---$$$ t{;; 	$ 	$LFDLLNNNJJvz***JJuJJtU####	:...$$$$$r:   c                 f    |                      |           |                     |j        |           d S r,   )r   r1   r3   r  s      r8   visit_ExprStmtzCodeGenerator.visit_ExprStmt  s0    T

49e$$$$$r:   _FinalizeInfo)constsrcc                 h     j          j         S  j        x}d} j        j        rid} j        j        fd}t	          dd          du r|dz  }d}n:t	          dd          du r|d	z  }d}nt	          d
d          du r|dz  } fd}                     ||           _          j         S )a  Build the finalize function to be used on constants and at
        runtime. Cached so it's only created once for all output nodes.

        Returns a ``namedtuple`` with the following attributes:

        ``const``
            A function to finalize constant data at compile time.

        ``src``
            Source code to output around nodes to be evaluated at
            runtime.
        Nzenvironment.finalize(c                 ,      |                     S r,   rl   )rW   r)  env_finalizes    r8   finalizez.CodeGenerator._make_finalize.<locals>.finalize  s    w||E22333r:   contextfunctionFT	context, evalcontextfunctioncontext.eval_ctx, environmentfunctionenvironment, c                 8      j         |                     S r,   )rC   )rW   r)  r  r2   s    r8   r  z.CodeGenerator._make_finalize.<locals>.finalize'  s"    "7<<0@%#H#HIIIr:   )	_finalize_default_finalizerC   r  r   r  )r2   r  r  r)  r  s   `  @@r8   _make_finalizezCodeGenerator._make_finalize  s(    >%>!!337$ 	J)C+4L4 4 4 4 4 4 |%6>>$FF{"'<eDDLL++'<eDDLL&J J J J J J J ++Hc::~r:   c                 :    t          t          |                    S )zGiven a group of constant values converted from ``Output``
        child nodes, produce a string to write to the template module
        source.
        )r-  r   )r2   groups     r8   _output_const_reprz CodeGenerator._output_const_repr-  s    
 F5MM"""r:   c                     |                     |j                  }|j        j        rt          |          }t	          |t
          j                  rt          |          S |                    |          S )aC  Try to optimize a child of an ``Output`` node by trying to
        convert it to constant, finalized data at compile time.

        If :exc:`Impossible` is raised, the node is not constant and
        will be evaluated at runtime. Any other exception will also be
        evaluated at runtime for easier debugging.
        )	as_constr.   r   r   r=   r   TemplateDatar   r  )r2   r3   r4   r  r  s        r8   _output_child_to_constz$CodeGenerator._output_child_to_const4  sf     en-->$ 	"5MME dE.// 	$U###~~e$$$r:   c                     |j         j        r|                     d           n7|j         j        r|                     d           n|                     d           |j        |                     |j                   dS dS )zXOutput extra source code before visiting a child of an
        ``Output`` node.
        z7(escape if context.eval_ctx.autoescape else to_string)(zescape(z
to_string(N)r.   r/   r   r   r  r2   r3   r4   r  s       r8   _output_child_prezCodeGenerator._output_child_preG  s     >" 	%JJPQQQQ^& 	%JJy!!!!JJ|$$$<#JJx|$$$$$ $#r:   c                 l    |                      d           |j        |                      d           dS dS )zWOutput extra source code after visiting a child of an
        ``Output`` node.
        r   N)r   r  r  s       r8   _output_child_postz CodeGenerator._output_child_postU  s6     	

3<#JJsOOOOO $#r:   c                    |j         r2| j        rd S |                     d           |                                  |                                 }g }|j        D ]}	 |j        s-t          |t
          j                  st          j	                    | 
                    |||          }n1# t
          j	        t          f$ r |                    |           Y |w xY w|r7t          |d         t                    r|d                             |           |                    |g           |j        bt          |          dk    r|                     d|j        z             n|                     d|j        z             |                                  |D ]}t          |t                    rN|                     |          }|j        |                     d|z              L|                     |dz              e|j        |                     d|           n|                     |           |                     |||           |                     ||           |                     |||           |j        |                     d           |j        >|                                  |                     t          |          dk    rdnd	           |j         r|                                  d S d S )
Nr|  rA  r
   r   z%s.extend((r   r.  r   )))ru   r   r   r   r  r   r  r=   r  
Impossibler  	Exceptionr   rR   rv   r  r  r   r  r1   r  r   r   )	r2   r3   r4   r  r  childr  rX   vals	            r8   visit_OutputzCodeGenerator.visit_Output^  s   % 	% NN8999KKMMM&&((
 Z 	% 	%E N- "%);<<-  *,,,33E5(KK$i0    E"""  %
48T22 %R&&&&UG$$$$<#4yyA~~|el:;;;;}u|;<<<KKMMM 	$ 	$D$%% $--d33<'NN8c>2222NN39----<'NN8T2222LL&&& &&tUH===

4'''''eX>>><+JJsOOO<#LLNNNNN#d))q..33d;;;% 	LLNNNNN	 	s   AB&&+CCc                    |                                   |                     |           |                     |j        |           |                     d           |                     |j        |           |                     |           d S r  )rQ  r   r1   r  r   r3   r\  r  s      r8   visit_AssignzCodeGenerator.visit_Assign  s~    !!###T

4;&&&

5

49e$$$  '''''r:   c                    |                                   |                                }d|_        |j                            |           |                     |           |                     |           |                     |j        |           | 	                    |           | 
                    |j        |           |                     d           |j        |                     |j        |           n|                     d|j        z             |                     d           |                     |           |                     |           d S )NFz9 = (Markup if context.eval_ctx.autoescape else identity)(
concat(%s)r   )rQ  r   ru   rr   r  r	  rv   r   r  r   r1   r  r   r  r   r\  r  )r2   r3   r4   ry  s       r8   visit_AssignBlockzCodeGenerator.visit_AssignBlock  s3   !!###kkmm ,1(((...%%%K   	;///T

4;&&&

NOOO;"dk;7777JJ|k&88999

3  '''%%%%%r:   c           	         |j         dk    r3|j        r,| j        r%| j        d                             |j                   |j                            |j                  }|j         dk    rh|j                            |          }|&|d         t          k    r| 	                    |          r&| 
                    d|j        d|d|d           d S | 
                    |           d S )	Nr  rA  r   r   z(undefined(name=z) if z is missing else r   )r   rs   r   r   rD   rr   r  	find_loadr   rO  r   )r2   r3   r4   r  r   s        r8   r   zCodeGenerator.visit_Name  s    8w5>! 6"2&**49555m	**
 8v=**3//D G11144S99 2 


yyy###sss,   

3r:   c                 4   |j                             |j                  }|                     d|z             |                                  |                     ddz             |                                  |                     |d|j        d           d S )Nz!if not isinstance(%s, Namespace):r  z/cannot assign attribute on non-namespace objectr   r   )rr   r  rD   r   r   r   attr)r2   r3   r4   r  s       r8   visit_NSRefzCodeGenerator.visit_NSRef  s     m	**:S@AAA,?@	
 	
 	
 	333			233333r:   c                     |                     |j                  }t          |t                    r$|                     t          |                     d S |                     t          |                     d S r,   )r  r.   r=   rO   r   strr-  )r2   r3   r4   r  s       r8   visit_ConstzCodeGenerator.visit_Const  sc    mmEN++c5!! 	"JJs3xx     JJtCyy!!!!!r:   c                     	 |                      t          |                    |j                                       d S # t          j        $ r! |                      d|j        z             Y d S w xY w)Nz9(Markup if context.eval_ctx.autoescape else identity)(%r))r   r-  r  r.   r   r  datar  s      r8   visit_TemplateDataz CodeGenerator.visit_TemplateData  s    	JJtDMM%.99::;;;;; 	 	 	JJKdiW     	s   :> ,A.-A.c                     |                      d           d}t          |j                  D ]2\  }}|r|                      d           |                     ||           3|                      |dk    rdpd           d S )Nr   rA  r   r   z,)r   r   r  r'   r1   r2   r3   r4   r(  rX   s        r8   visit_TuplezCodeGenerator.visit_Tuple  s    

3"4:.. 	$ 	$IC !

4   JJtU####

3!8$+,,,,,r:   c                     |                      d           t          |j                  D ]2\  }}|r|                      d           |                     ||           3|                      d           d S )Nr   r   r   r  r  s        r8   
visit_ListzCodeGenerator.visit_List  sr    

3"4:.. 	$ 	$IC !

4   JJtU####

3r:   c                 R   |                      d           t          |j                  D ]g\  }}|r|                      d           |                     |j        |           |                      d           |                     |j        |           h|                      d           d S )N{r   r   r   )r   r  r'   r1   rY   rW   r  s        r8   
visit_DictzCodeGenerator.visit_Dict  s    

3"4:.. 	* 	*IC !

4   JJtx'''JJtJJtz5))))

3r:   c                 ,     t            fd            }|S )Nc                    | j         j        rr| j         j        v rd|                     dz             |                     |j        |           |                     d           |                     |j        |           nc|                     d           |                     |j        |           |                     dz             |                     |j        |           |                     d           d S )Nz$environment.call_binop(context, %r, r   r    %s r   )rC   	sandboxedintercepted_binopsr   r1   leftrightr2   r3   r4   operators      r8   r_   z$CodeGenerator.binop.<locals>.visitor  s      *. 0 CCC

AHLMMM

49e,,,

4   

4:u----

3

49e,,,

6H,---

4:u---JJsOOOOOr:   r;   r  interceptabler_   s   `  r8   binopzCodeGenerator.binop  s-    		 	 	 	 
	  r:   c                 ,     t            fd            }|S )Nc                 4   | j         j        rB| j         j        v r4|                     dz             |                     |j        |           n3|                     dz              |                     |j        |           |                     d           d S )Nz#environment.call_unop(context, %r, r   r   )rC   r  intercepted_unopsr   r1   r3   r  s      r8   r_   z#CodeGenerator.uaop.<locals>.visitor2  s      *- 0 BBB

@8KLLL

49e,,,,

3>***

49e,,,JJsOOOOOr:   r  r  s   `  r8   uaopzCodeGenerator.uaop1  s-    	
	 
	 
	 
	 

	 r:   +-*/z//z**%and)r  orznot c                 
   |j         j        rd}n|j         j        rd}nd}|                     d|z             |j        D ]-}|                     ||           |                     d           .|                     d           d S )Nz;(context.eval_ctx.volatile and markup_join or unicode_join)markup_joinunicode_joinz%s((r   r  )r.   r/   r   r   r   r1   )r2   r3   r4   r  r   s        r8   visit_ConcatzCodeGenerator.visit_ConcatO  s    >" 	'UII^& 	'%II&I

6I%&&&: 	 	CJJsE"""JJt

4r:   c                     |                      d           |                     |j        |           |j        D ]}|                     ||           |                      d           d S )Nr   r   )r   r1   r  ops)r2   r3   r4   ops       r8   visit_ComparezCodeGenerator.visit_Compare]  sb    

3

49e$$$( 	" 	"BJJr5!!!!

3r:   c                     |                      dt          |j                 z             |                     |j        |           d S )Nr  )r   	operatorsr2  r1   r  r  s      r8   visit_OperandzCodeGenerator.visit_Operande  s<    

6Idg..///

49e$$$$$r:   c                 (   | j         j        r|                     d           |                     d           |                     |j        |           |                     d|j        z             | j         j        r|                     d           d S d S )N(await auto_await(zenvironment.getattr(r  r  )rC   r  r   r1   r3   r  r  s      r8   visit_GetattrzCodeGenerator.visit_Getattri  s    $ 	-JJ+,,,

)***

49e$$$

7TY&'''$ 	JJt	 	r:   c                 z   t          |j        t          j                  rb|                     |j        |           |                     d           |                     |j        |           |                     d           d S | j        j        r|                     d           |                     d           |                     |j        |           |                     d           |                     |j        |           |                     d           | j        j        r|                     d           d S d S )Nr   r   r8  zenvironment.getitem(r   r   r  )	r=   r   r   Slicer1   r3   r   rC   r  r  s      r8   visit_GetitemzCodeGenerator.visit_Getitemu  s    dh,, 	!JJty%(((JJsOOOJJtx'''JJsOOOOO( 1

/000JJ-...JJty%(((JJtJJtx'''JJsOOO( !

4     ! !r:   c                 *   |j         |                     |j         |           |                     d           |j        |                     |j        |           |j        2|                     d           |                     |j        |           d S d S )Nr  )startr1   r   stopr   r  s      r8   visit_SlicezCodeGenerator.visit_Slice  s    :!JJtz5)))

39 JJty%(((9 JJsOOOJJty%((((( ! r:   c                    | j         j        r|                     d           |                     | j        |j                 dz              | j         j                            |j                  }|#|                     d|j        z  |j                   t          |dd          du r|                     d           nQt          |dd          du r|                     d	           n(t          |d
d          du r|                     d           |j	        | 
                    |j	        |           nz|j        j        r'|                     d|j        d|j        d           nG|j        j        r|                     d|j        z             n|                     d|j        z             |                     ||           |                     d           | j         j        r|                     d           d S d S )Nawait auto_await(r   zno filter named %rcontextfilterFTr  evalcontextfilterr  environmentfilterr  z/(context.eval_ctx.autoescape and Markup(concat(z)) or concat(r  zMarkup(concat(%s))r  r   )rC   r  r   r   rD   getr   r   r   r3   r1   r.   r/   rv   r   r   )r2   r3   r4   r  s       r8   r   zCodeGenerator.visit_Filter  s   $ 	,JJ*+++

4<	*S0111'++DI66<II*TY6DDD4%00D88JJ{####T.66$>>JJ+,,,,T.66$>>JJ''' 9 JJty%((((^$ 	4JJJ8=elllT    ^& 	4JJ+el:;;;;JJ|el2333tU###

3$ 	JJsOOOOO	 	r:   c                 N   |                      | j        |j                 dz              |j        | j        j        vr#|                     d|j        z  |j                   |                     |j        |           |                     ||           |                      d           d S )Nr   zno test named %rr   )	r   r   rD   rC   r   r   r1   r3   r   r  s      r8   r   zCodeGenerator.visit_Test  s    

4:di(3.///9D,222II(494dkBBB

49e$$$tU###

3r:   c                 B     fd}                      d                                j                                         d                                j                                         d            |                                   d           d S )Nc                      j                             j                    S                     dd                              z  z             d S )Nzcond_expr_undefined(%r)zRthe inline if-expression on %s evaluated to false and no else section was defined.)expr2r1   r   r3  )r4   r3   r2   s   r8   write_expr2z1CodeGenerator.visit_CondExpr.<locals>.write_expr2  sc    z%zz$*e444JJ)359]]45H5HI    r:   r   z if z else r   )r   r1   expr1r  )r2   r3   r4   rK  s   ``` r8   visit_CondExprzCodeGenerator.visit_CondExpr  s    
	 
	 
	 
	 
	 
	 
	 	

3

4:u%%%

6

49e$$$

8

3r:   c                    | j         j        r|                     d           | j         j        r|                     d           n|                     d           |                     |j        |           |rddipd }|                     |||           |                     d           | j         j        r|                     d           d S d S )NrB  zenvironment.call(context, zcontext.call(r  r   )rC   r  r   r  r1   r3   r   )r2   r3   r4   r  r   s        r8   r  zCodeGenerator.visit_Call  s    $ 	,JJ*+++% 	(JJ34444JJ'''

49e$$$%>8X*>F$tUL111

3$ 	JJsOOOOO	 	r:   c                 v    |                      |j        dz              |                     |j        |           d S )Nr   )r   rY   r1   rW   r  s      r8   visit_KeywordzCodeGenerator.visit_Keyword  s6    

48c>"""

4:u%%%%%r:   c                     |                      d           |                     |j        |           |                      d           d S )NzMarkup(r   r   r1   r  r  s      r8   visit_MarkSafezCodeGenerator.visit_MarkSafe  s=    

9

49e$$$

3r:   c                     |                      d           |                     |j        |           |                      d           d S )Nz5(context.eval_ctx.autoescape and Markup or identity)(r   rR  r  s      r8   visit_MarkSafeIfAutoescapez(CodeGenerator.visit_MarkSafeIfAutoescape  s>    

JKKK

49e$$$

3r:   c                 @    |                      d|j        z              d S )Nzenvironment.r   rD   r  s      r8   visit_EnvironmentAttributez(CodeGenerator.visit_EnvironmentAttribute  s!    

>DI-.....r:   c                 P    |                      d|j        d|j                   d S )Nzenvironment.extensions[z].)r   
identifierrD   r  s      r8   visit_ExtensionAttributez&CodeGenerator.visit_ExtensionAttribute  s+    


doootyyQRRRRRr:   c                 P    |                      | j        |j                            d S r,   )r   r   ro  r  s      r8   visit_ImportedNamez CodeGenerator.visit_ImportedName  s$    

4&t788888r:   c                 :    |                      |j                   d S r,   rW  r  s      r8   visit_InternalNamez CodeGenerator.visit_InternalName  s    

49r:   c                 0    |                      d           d S )Nr   )r   r  s      r8   visit_ContextReferencez$CodeGenerator.visit_ContextReference  s    

9r:   c                 V    |                      |                     |                     d S r,   )r   rM  r  s      r8   visit_DerivedContextReferencez+CodeGenerator.visit_DerivedContextReference  s(    

4&&u--.....r:   c                 2    |                      d|           d S )Ncontinuer:  r  s      r8   visit_ContinuezCodeGenerator.visit_Continue  s    z4(((((r:   c                 2    |                      d|           d S )Nbreakr:  r  s      r8   visit_BreakzCodeGenerator.visit_Break  s    w%%%%%r:   c                     |                                 }|j                            |           |                     |           |                     |j        |           |                     |           d S r,   )r   rr   r  r	  r   r  r  )r2   r3   r4   scope_frames       r8   visit_ScopezCodeGenerator.visit_Scope  sj    kkmm((...%%%	;///%%%%%r:   c                 *   |                                  }|                     |d|                     |                     |                     d|z             |                     |j        |           |                     |           |                    d          }|j                            |           | 	                    |           | 
                    |j        |           |                     |           |                                  d S )Nr   z
%s.vars = T)r   )r   r   rM  r1   r   rD  r   rr   r  r	  r   r  r  rF  )r2   r3   r4   r   rk  s        r8   visit_OverlayScopez CodeGenerator.visit_OverlayScope  s    ''))CCC)<)<U)C)C)CDEEE|c)***

4<'''##C(((kk4k00((...%%%	;///%%%""$$$$$r:   c                 B   |j         D ]}|                     d|j        z             |                     |j        |           	 |j                            |j                  }t          |j        |j        |           v# t          j	        $ r d|j        _
        Y w xY wd S )Nzcontext.eval_ctx.%s = T)optionsr   rY   r1   rW   r  r.   setattrr   r  r/   )r2   r3   r4   keywordr  s        r8   visit_EvalContextModifierz'CodeGenerator.visit_EvalContextModifier   s    | 	: 	:GNN3gkABBBJJw}e,,,:m,,U^<< S9999 # / / /*.'''/	: 	:s   A>>BBc                 `   |                                  }|j                                        }|                     d|z             |                     ||           |j        D ]}|                     ||           |j                            |           |                     d|z             d S )Nz%s = context.eval_ctx.save()zcontext.eval_ctx.revert(%s))r   r.   saver   rs  r  r1   revert)r2   r3   r4   old_ctx_name	saved_ctxr  s         r8   visit_ScopedEvalContextModifierz-CodeGenerator.visit_ScopedEvalContextModifier+  s    0022N''))	5DEEE&&tU333Y 	% 	%EJJue$$$$i(((4|CDDDDDr:   NFTr   )r
   r,   )Nr   )T)ori   rj   rk   rh   r   r   rv   r   r   r   r   r   r   r   r   r   r   r   r   r	  r  r  r*  r0  r3  r8  r;  r"  r$  r#  rD  rF  rI  r  rM  rO  rQ  r\  rz  r   r  r  r  r  r  r  r  r  r  r  r  r   r  r   r  r  r  r  r  r  r  r  r  r  r   r  r  r
  r  r  r  r   r$  	visit_Add	visit_Sub	visit_Mul	visit_Divvisit_FloorDiv	visit_Pow	visit_Mod	visit_Andvisit_Or	visit_Pos	visit_Neg	visit_Notr;   r/  r3  r6  r9  r<  r@  r   r   rM  r  rP  rS  rU  rX  r[  r]  r_  ra  rc  rf  ri  rl  rn  rs  ry  rl   r:   r8   r   r      s       TX@4 @4 @4 @4HL L L. . .
1 1 1
; ; ; ;$  " " " "> > > >  
   	 	 	     
* * * *3/ 3/ 3/ 3/j  @ @ @ D D D D  
N  N  N `
 
 
$  
 
 

+ 
+ 
+I I I$ $ $6 6 65 5 5, , ,1 1 1% % %
 
 
3 3 3) ) )  >z
 z
 z
 z
x$ $ $L+! +! +!Z8 8 8tN N N2I I IVD" D" D"L  */ / /  	' 	' 	'
% 
% 
%% % % J0@AAM "I' ' 'R# # #% % %&% % %  M M M^( ( (& & &0  04 4 4" " "  - - -       (     c

Ic

Ic

Ic

IU4[[NdIc

Ie5111IuT///HS		IS		IV5111It  ]   ]% % % 	 	 ]	 ! ! ]!() ) )   ]@   ]   ]*    ]& & &  
  
/ / /S S S9 9 9    / / /) ) )& & && & &% % %	: 	: 	:E E E E Er:   r   rz  )=r   collectionsr   	functoolsr   	itertoolsr   rr  r   r   
markupsafer   r	   r_  r   _compatr   r   r   r   r   r   r   
exceptionsr   
idtrackingr   r   r   r   r   r   r0   r   utilsr   r_   r   r5  hasattrrV   r  ri  execr   SyntaxErrorrq  r;   rH   rU   r`   rz   rb   rn   RuntimeErrorr\   r   r[   r  r   r   rl   r:   r8   <module>r     s7   6 6 " " " " " " $ $ $ $ $ $       2 2 2 2 2 2                                     # # # # # #       ! ! ! ! ! !       . . . . . .       & & & & & & * * * * * * ( ( ( ( ( ( * * * * * *                                     



	 		 74  NNN	D	0111)**** 	 	 	D	D	"###         	' 	' 	' QU+ + + +  *
 
 
& & & & &v & & &: : : : :F : : :zJ J J J J, J J J' ' ' ' 'k ' ' '&& & & & &K & & &,    9   |E |E |E |E |EK |E |E |E |E |Es$   3 C CC C. .C87C8