HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/jinja2/__pycache__/compiler.cpython-310.pyc
o

�N�g�!�@s�dZddlZddlmZddlmZddlmZddl	m
Z
ddlmZ
ddlmZdd	lmZd
dlmZd
dlmZd
d
lmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlm Z d
dl!m"Z"ej#r�ddl$Z%d
dl&m'Z'ej(dej)dej*fd�Z+dddddd d!d"d#�Z,d$e+d%e+fd&d'�Z-d(e.d%ej)d)ej/d*gdffd+d,�Z0d(e.d%ej)d)ej1d*gdffd-d.�Z2		/	0dNd1ej3d2d3d4ej4e.d5ej4e.d6ej4ej5d7e6d8e6d%ej4e.fd9d:�Z7d;ej*d%e6fd<d=�Z8d>ej9ej:d?ej9e.d%ej;e.fd@dA�Z<GdBdC�dC�Z=GdDd*�d*�Z>GdEdF�dFe?�Z@GdGdH�dHe"�ZAGdIdJ�dJe"�ZBGdKdL�dLeC�ZDGdMd)�d)e"�ZEdS)Oz0Compiles nodes from the parser into Python code.�N)�contextmanager)�update_wrapper)�StringIO)�chain)�	iskeyword)�escape)�Markup�)�nodes)�TemplateAssertionError)�Symbols)�VAR_LOAD_ALIAS)�VAR_LOAD_PARAMETER)�VAR_LOAD_RESOLVE)�VAR_LOAD_UNDEFINED)�EvalContext)�	Optimizer)�_PassArg)�concat)�NodeVisitor)�Environment�F.)Zboundz==z!=�>z>=�<z<=�inznot in)�eq�ne�gtZgteq�ltZlteqrZnotin�f�returnc
s2dddtjdddtjdtjf
�fdd	�}t|��S)
N�self�
CodeGenerator�node�frame�Frame�kwargsr csJ|jdur|jjs|j�||j�}||kr|�||�S�|||fi|��S�N)�	optimizer�eval_ctx�volatile�visit)r!r#r$r&Znew_node�r��C/opt/saltstack/salt/lib/python3.10/site-packages/jinja2/compiler.py�new_func.s
zoptimizeconst.<locals>.new_func)r
�Expr�t�Anyr)rr/r-r,r.�
optimizeconst-s�����
r3�opr"r%c	�(tdddtjdtddf�fdd��}|S)Nr!r"r#r$r cs�|jjr'�|jjvr'|�d��d��|�|j|�|�d�|�|j|�n|�d�|�|j|�|�d��d��|�|j|�|�d�dS)Nz environment.call_binop(context, �, �(� �))�environment�	sandboxedZintercepted_binops�writer+�left�right�r!r#r$�r4r-r.�visitor>s�

z_make_binop.<locals>.visitor)r3r
�BinExprr%�r4rAr-r@r.�_make_binop=s"rDc	r5)Nr!r"r#r$r cs`|jjr�|jjvr|�d��d��|�|j|�n|�d��|�|j|�|�d�dS)Nzenvironment.call_unop(context, r6r7r9)r:r;Zintercepted_unopsr<r+r#r?r@r-r.rAUs�z_make_unop.<locals>.visitor)r3r
�	UnaryExprr%rCr-r@r.�
_make_unopRs"rFFTr#r:r�name�filename�stream�
defer_init�	optimizedcCsHt|tj�s
td��|�||||||�}|�|�|dur"|j��SdS)z+Generate the python source for a node tree.z Can't compile non template nodesN)�
isinstancer
�Template�	TypeErrorZcode_generator_classr+rI�getvalue)r#r:rGrHrIrJrK�	generatorr-r-r.�generatees
�

rQ�valuecCs�|dus|tus|turdSt|�ttttttt	hvrdSt|�t
ttt
hvr0tdd�|D��St|�turAtdd�|��D��SdS)z)Does the node have a safe representation?NTcss�|]}t|�VqdSr'��
has_safe_repr)�.0�vr-r-r.�	<genexpr>�s�z has_safe_repr.<locals>.<genexpr>css$�|]
\}}t|�o
t|�VqdSr'rS�rU�krVr-r-r.rW�s�"F)�NotImplemented�Ellipsis�type�bool�int�float�complex�range�strr�tuple�list�set�	frozenset�all�dict�items�rRr-r-r.rT}srTr
�namescCs<t|�}z|D]}|�|�qW|jStyY|jSw)z�Check if the names passed are accessed undeclared.  The return value
    is a set of all the undeclared names from the sequence of names found.
    )�UndeclaredNameVisitorr+�VisitorExit�
undeclared)r
rkrAr#r-r-r.�find_undeclared�s���roc@s,eZdZdejejejfddfdd�ZdS)�MacroRefr#r NcCs||_d|_d|_d|_dS�NF)r#�accesses_caller�accesses_kwargs�accesses_varargs�r!r#r-r-r.�__init__�s
zMacroRef.__init__)	�__name__�
__module__�__qualname__r1�Unionr
�Macro�	CallBlockrvr-r-r-r.rp�s$rpc	@sheZdZdZ		ddedejddejeddfdd�Zdd
d�Z	dd
e
ddfdd�Zddd�Ze	Z
dS)r%z&Holds compile time information for us.Nr)�parent�levelr cCs~||_||_|durt|d�|_d|_d|_d|_nt|j|d�|_|j|_|j|_|j|_d|_d|_d|_	d|_
d|_dS)N�r~F)r)r}r�symbols�require_output_check�buffer�block�toplevel�	rootlevel�
loop_frame�block_frame�
soft_frame)r!r)r}r~r-r-r.rv�s 
zFrame.__init__�te.SelfcCs*t�|j�}|j�|j�|j��|_|S)z!Create a copy of the current one.)�object�__new__�	__class__�__dict__�updater��copy�r!�rvr-r-r.r��sz
Frame.copyF�isolatedcCs&|r
t|j|jjdd�St|j|�S)zReturn an inner frame.r	r)r%r)r�r~)r!r�r-r-r.�inner�szFrame.innercCs|��}d|_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 and conditional
        expressions.
        FT)r�r�r�r�r-r-r.�soft�sz
Frame.soft)NN)r r��F)rwrxry�__doc__rr1�Optionalr^rvr�r]r�r��__copy__r-r-r-r.r%�s"����
�
3

c@�eZdZdZdS)rmz?Exception used by the `UndeclaredNameVisitor` to signal a stop.N�rwrxryr�r-r-r-r.rm��rmc@sVeZdZdZd
dd�Zdejddfdd�Zdejddfd	d
�Z	dej
ddfdd�ZdS)�DependencyFinderVisitorz.A visitor that collects filter and test calls.r NcCst�|_t�|_dSr')re�filters�tests�r!r-r-r.rv�sz DependencyFinderVisitor.__init__r#cC�|�|�|j�|j�dSr')�
generic_visitr��addrGrur-r-r.�visit_Filter�
z$DependencyFinderVisitor.visit_FiltercCr�r')r�r�r�rGrur-r-r.�
visit_Testr�z"DependencyFinderVisitor.visit_TestcC�dS)zStop visiting at blocks.Nr-rur-r-r.�visit_Block�z#DependencyFinderVisitor.visit_Block�r N)rwrxryr�rvr
�Filterr��Testr��Blockr�r-r-r-r.r��s
r�c@sPeZdZdZdejeddfdd�Zdej	ddfdd	�Z
dejddfd
d�ZdS)rlz�A 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.
    rkr NcCst|�|_t�|_dSr')rerkrn)r!rkr-r-r.rvs
zUndeclaredNameVisitor.__init__r#cCsL|jdkr|j|jvr|j�|j�|j|jkrt��dS|j�|j�dS)N�load)�ctxrGrkrnr�rm�discardrur-r-r.�
visit_Names�z UndeclaredNameVisitor.visit_NamecCr�)zStop visiting a blocks.Nr-rur-r-r.r�!r�z!UndeclaredNameVisitor.visit_Block)
rwrxryr�r1�Iterablerbrvr
�Namer�r�r�r-r-r-r.rls
rlc@r�)�CompilerExitz�Raised 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�r-r-r-r.r�%r�r�c@s�	eZdZU			d�dddejedejedejejd	ed
eddfdd
�Ze	defdd��Z
dededdfdd�Zdefdd�Z
deddfdd�Z	d�dededdfdd�Zd�dd�Zd�d eddfd!d"�Zd�ded#ejejddfd$d%�Zdeddfd&d'�Z	d�d(eded#ejejddfd)d*�Zd+ejejdeddfd,d-�Zd.eddfd/d0�Z	1d�d.ed#ejejd2eddfd3d4�Zd�d#ejejd2eddfd5d6�Z	d�d#ejejejej fded7ejej!eej"fddfd8d9�Z#d+ejejddfd:d;�Z$deddfd<d=�Z%d�ded>eddfd?d@�Z&d�dCedDedefdEdF�Z'dedefdGdH�Z(d#ejej)ej*fdedej+ee,ffdIdJ�Z-dKe,deddfdLdM�Z.d#ejdefdNdO�Z/dedefdPdQ�Z0d�dRdS�Z1deddfdTdU�Z2d�dVdW�Z3dXeddfdYdZ�Z4dXeddfd[d\�Z5d�d]d^�Z6defd_d`�Z7defdadb�Z8dedefdcdd�Z9dXedefdedf�Z:d�dgdh�Z;deddfdidj�Z<	d�d#ej=dejeddfdkdl�Z>d#ej?deddfdmdn�Z@d#ejAdeddfdodp�ZBd#ejCdeddfdqdr�ZDd#ejejEejFfdeddfdsdt�ZGd#ejEdeddfdudv�ZHd#ejFdeddfdwdx�ZId#ejJdeddfdydz�ZKd#ejLdeddfd{d|�ZMd#ej)deddfd}d~�ZNd#ej*deddfdd��ZOd#ejPdeddfd�d��ZQd#ejRdeddfd�d��ZSd#ejTdeddfd�d��ZUGd�d��d�ejV�ZWeXd�ej"dej"fd�d���ZYdZZejeWe[d�<deWfd�d��Z\d�ejej"defd�d��Z]d#ej^ded�eWdefd�d��Z_d#ej^ded�eWddfd�d��Z`d#ej^ded�eWddfd�d��Zad#ejbdeddfd�d��Zcd#ejddeddfd�d��Zed#ejfdeddfd�d��Zgd#ejhdeddfd�d��Zid#ejjdeddfd�d��Zkd#ejldeddfd�d��Zmd#ejndeddfd�d��Zod#ej+deddfd�d��Zpd#ejqdeddfd�d��Zrd#ejsdeddfd�d��Zteud��Zveud��Zweud��Zxeud��Zyeud��Zzeud��Z{eud��Z|eud��Z}eud��Z~ed��Z�ed��Z�ed��Z�e�d#ej�deddfd�d���Z�e�d#ej�deddfd�d���Z�d#ej�deddfd�d��Z�e�d#ej�deddfd�d���Z�e�d#ej�deddfd�d���Z�d#ej�deddfd�d„Z�e�d#ejejej fded�edej�dfd�dń�Z�e�d#ejdeddfd�dDŽ�Z�e�d#ej deddfd�dɄ�Z�e�d#ej�deddfd�d˄�Z�e�	d�d#ejded�eddfd�d΄�Z�d#ej�deddfd�dЄZ�d#ej�deddfd�d҄Z�d#ej�deddfd�dԄZ�d#ej�deddfd�dքZ�d#ej�deddfd�d؄Z�d#ej�deddfd�dڄZ�d#ej�deddfd�d܄Z�d#ej�deddfd�dބZ�d#ej�deddfd�d�Z�d#ej�deddfd�d�Z�d#ej�deddfd�d�Z�d#ej�deddfd�d�Z�d#ej�deddfd�d�Z�d#ej�deddfd�d�Z�d#ej�deddfd�d�Z�dS)�r"NFTr:rrGrHrIrJrKr cCs�|durt�}||_||_||_||_d|_||_d|_|r#t|�|_i|_	i|_
d|_d|_d|_
i|_i|_g|_d|_d|_d|_d|_d|_d|_g|_g|_dg|_dS)NFrr	T�context)rr:rGrHrIZcreated_block_contextrJr(r�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)r!r:rGrHrIrJrKr-r-r.rv-s8	
zCodeGenerator.__init__cCs
|jduSr')r(r�r-r-r.rKvs
zCodeGenerator.optimized�msg�linenozte.NoReturncCst|||j|j��)z*Fail with a :exc:`TemplateAssertionError`.)rrGrH)r!r�r�r-r-r.�fail|�zCodeGenerator.failcCs|jd7_d|j��S)zGet a new unique identifier.r	Zt_)r�r�r-r-r.�temporary_identifier�sz"CodeGenerator.temporary_identifierr$cCs |��|_|�|j�d��dS)z7Enable buffering for the frame from that point onwards.z = []N)r�r��	writeline�r!r$r-r-r.r��s
zCodeGenerator.buffer�force_unescapedcCs�|sF|jjr6|�d�|��|�d|j�d��|��|�d�|��|�d|j�d��|��dS|jjrF|�d|j�d��dS|�d|j�d��dS)z(Return the buffer contents of the frame.zif context.eval_ctx.autoescape:zreturn Markup(concat(�))�else:zreturn concat(r9N)r)r*r��indentr��outdent�
autoescape)r!r$r�r-r-r.�return_buffer_contents�s

z$CodeGenerator.return_buffer_contentscCs|jd7_dS)zIndent by one.r	N�r�r�r-r-r.r��r�zCodeGenerator.indentr	�stepcCs|j|8_dS)zOutdent by step.Nr�)r!r�r-r-r.r��r�zCodeGenerator.outdentr#cCs2|jdur
|�d|�dS|�|j�d�|�dS)z%Yield or write into the frame buffer.N�yield �.append()r�r�)r!r$r#r-r-r.�start_write�s
zCodeGenerator.start_writecCs|jdur|�d�dSdS)z1End the writing process started by `start_write`.Nr9)r�r<r�r-r-r.�	end_write�s
�zCodeGenerator.end_write�scCs$|�||�|�|�|�|�dS)z4Simple shortcut for start_write + write + end_write.N)r�r<r�)r!r�r$r#r-r-r.�simple_write�s
zCodeGenerator.simple_writer
cCs<z|�d�|D]}|�||�qWdStyYdSw)z�Visit 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�r+r�)r!r
r$r#r-r-r.�
blockvisit�s
��zCodeGenerator.blockvisit�xcCs�|jr8|js)|j�d|j�|j|j7_|jdur)|j�|j|jf�d|_d|_|j�d|j�d|_|j�|�dS)z&Write a string into the output stream.�
NFz    r)	r�r�rIr<r�r�r��appendr�)r!r�r-r-r.r<�s
zCodeGenerator.writer�extracCs|�||�|�|�dS)z!Combination of newline and write.N)�newliner<)r!r�r#r�r-r-r.r��szCodeGenerator.writelinecCsBt|jd|�|_|dur|j|jkr|j|_|j|_dSdSdS)z/Add one or more newlines before the next write.r	N)�maxr�r�r�r�)r!r#r�r-r-r.r��s
�zCodeGenerator.newline�extra_kwargsc	Cs�tdd�tdd�|jD�|pd�D��}|jD]
}|�d�|�||�q|sP|jD]
}|�d�|�||�q*|durP|��D]\}}|�d|�d|���q@|jr_|�d�|�|j|�|r�|jdurl|�d	�n|�d
�|jD]}|�|j	�d��|�|j
|�|�d�qt|dur�|��D]\}}|�|�d|�d��q�|jdur�|�d�|�|j|�|�d
�dS|�d�dS|jdur�|�d�|�|j|�dSdS)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.
        css �|]}tt�t|��VqdSr')�is_python_keywordr1�castrb)rUrYr-r-r.rW�s
��
�z*CodeGenerator.signature.<locals>.<genexpr>cs��|]}|jVqdSr')�key�rUr�r-r-r.rW���r-r6N�=z, *z
, **dict({z, **{�: z}, **r9�}z, **)�anyrr&�argsr<r+riZdyn_argsZ
dyn_kwargsr�rR)	r!r#r$r�Zkwarg_workaround�arg�kwargr�rRr-r-r.�	signature�sH�











�zCodeGenerator.signaturec
Cst�}|D]}|�|�q|j|jdf|j|jdffD]h\}}}t|�D]^}||vr0|��||<|�d�|��|�||�d|�d|�d��|��|�d�|��|�d�|�d	||�d
��|��|�d|dd
��d|�d��|��|��q$qdS)a�Find all filter and test names used in the template and
        assign them to variables in the compiled namespace. Checking
        that the names are registered with the environment is done when
        compiling the Filter and Test nodes. If the node is in an If or
        CondExpr node, the check is done at runtime instead.

        .. versionchanged:: 3.0
            Filters and tests in If and CondExpr nodes are checked at
            runtime instead of compile time.
        r�r��try:z = environment.�[�]zexcept KeyError:z
@internalcode�def z
(*unused):zraise TemplateRuntimeError("No N���� named z	 found."))	r�r+r�r��sortedr�r�r�r�)r!r
rAr#Zid_maprkZ
dependencyrGr-r-r.�pull_dependenciess<��
 

��
��zCodeGenerator.pull_dependenciesc	Cs�g}|jj��D]<\}\}}|tkrq|tkr(|�|�d|���d|�d��q|tkr7|�|�d|���q|tkrA|�	|�qt
d��|rT|�d�|��d��dSdS)N� = r7r9zunknown load instruction�
 = missing)r��loadsrirrr��get_resolve_funcr
rr��NotImplementedError�join)r!r$�undefs�target�action�paramr-r-r.�enter_frameHs"�zCodeGenerator.enter_frame�with_python_scopecCsF|sg}|jjD]}|�|�q|r!|�d�|��d��dSdSdS)Nr�r�)r�r�r�r�r�)r!r$rr�rr-r-r.�leave_frameXs�zCodeGenerator.leave_frame�async ��async_value�
sync_valuecCs|jjr|S|Sr')r:�is_async)r!rr	r-r-r.�choose_async`�zCodeGenerator.choose_asynccCs|���d|��S)Nr�)r)r!rGr-r-r.�funccszCodeGenerator.funccCs�|��}|j�|�t|�}d}t�}g}t|j�D] \}}|jdkr%|}|jdvr0|�|j�|�	|j�
|j��qt|jd�}	d|	vrr|durfz|j
|t|j�Wntye|�d|j�Yn
w|�	|j�d��d|_d|	vr�d|vr�|�	|j�d��d|_d|	vr�d|vr�|�	|j�d��d|_d	|_|j�|�|�|�d
��dd�|��d
�|�|��|�|�|�|�|�|�t|j�D]V\}}|j�
|j�}
|�d|
�d��|��z|j
|t|j�}Wnt�y|�|
�d|j�d|j�d��Ynw|�|
�d��|�||�|�|
�|� �q�|�!�|�"|j|�|j#|dd�|j$|dd�|� �||fS)z/Dump the function def of a macro or call block.N�caller)r&�varargs)rr&rzhWhen defining macros or call blocks the special "caller" argument must be omitted or be given a default.Tr&rFZmacror7r6�):�if � is missing:z = undefined("parameter z was not provided", name=r9r�)r��r)%r�r��analyze_noderpre�	enumerater�rGr�r��refro�body�defaults�len�
IndexErrorr�r��declare_parameterrrrsrtr�r�r
r�r�r�r�push_parameter_definitionsr+�mark_parameter_storedr��pop_parameter_definitionsr�r�r)r!r#r$�	macro_refZexplicit_callerZskip_special_paramsr��idxr�rnr�defaultr-r-r.�
macro_bodyfsz

��$


���

zCodeGenerator.macro_bodyrc
Csrd�dd�|jjD��}t|jdd�}t|jj�dkr|d7}|�d|�d	|�d
|j�d|j�d|j�d��dS)z<Dump the macro definition for the def created by macro_body.r6css�|]}t|j�VqdSr')�reprrGr�r-r-r.rW�s�z*CodeGenerator.macro_def.<locals>.<genexpr>rGNr	�,zMacro(environment, macro, z, (z), z, context.eval_ctx.autoescape))	r�r#r��getattrrr<rsrtrr)r!rr$Z	arg_tuplerGr-r-r.�	macro_def�s����zCodeGenerator.macro_defcCs*d|j��}|jdur|�d|j��}|S)z.Return a human readable position for the node.zline N� in )r�rG)r!r#r�r-r-r.�position�s
zCodeGenerator.positioncCs*d�dd�|j����D��}d|�d�S)Nr6css"�|]\}}|�d|��VqdS�r�Nr-)rUrGrr-r-r.rW�s
��
�z3CodeGenerator.dump_local_context.<locals>.<genexpr>�{r�)r�r�Zdump_storesri)r!r$Zitems_kvr-r-r.�dump_local_context�s
�z CodeGenerator.dump_local_contextcCs6|�d�|�d�|�d�|�d�|�d�dS)z�Writes 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.undefinedzconcat = environment.concatzcond_expr_undefined = Undefinedzif 0: yield NoneN�r�r�r-r-r.�
write_commons�s




zCodeGenerator.write_commonscCs|j�|j���dS)aQPushes 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�r�Zdump_param_targetsr�r-r-r.r�sz(CodeGenerator.push_parameter_definitionscCs|j��dS)z+Pops the current parameter definitions set.N)r��popr�r-r-r.r�sz'CodeGenerator.pop_parameter_definitionsrcCs|jr
|jd�|�dSdS)z�Marks a parameter in the current parameter definitions as stored.
        This will skip the enforced undefined checks.
        r�N)r�r��r!rr-r-r.r�s�z#CodeGenerator.mark_parameter_storedcCs|j�|�dSr')r�r�r/r-r-r.�push_context_reference�rz$CodeGenerator.push_context_referencecCs|j��dSr')r�r.r�r-r-r.�pop_context_reference�sz#CodeGenerator.pop_context_referencecCs
|jdS)Nr��r�r�r-r-r.�get_context_ref�s
zCodeGenerator.get_context_refcCs |jd}|dkrdS|�d�S)Nr�r��resolvez.resolver2r/r-r-r.r��s

zCodeGenerator.get_resolve_funccCs|���d|�|��d�S)Nz	.derived(r9)r3r+r�r-r-r.�derive_contextszCodeGenerator.derive_contextcCs|jsdS||jdvS)z4Checks if a given target is an undeclared parameter.Fr�)r�r/r-r-r.�parameter_is_undeclaredsz%CodeGenerator.parameter_is_undeclaredcCs|j�t��dS)z+Pushes a new layer for assignment tracking.N)r�r�rer�r-r-r.�push_assign_trackingr�z"CodeGenerator.push_assign_trackingcCs�|j��}|js|js|jr|sdSdd�|D�}t|�dkrWtt|��}|j�	|�}|jr;|�
d|�d|���dS|jrK|�
d|�d|���dS|�
d|�d|���n>|jr`|�
d	�n|jri|�
d
�n|�
d�tt|��D]\}}|r|�
d�|j�	|�}|�
|�d
|���qt|�
d�|js�|js�|r�t|�dkr�|�
d|d�d��dSd�ttt|���}|�
d|�d��dSdSdSdS)zoPops the topmost level for assignment tracking and updates the
        context variables if necessary.
        NcSs g|]}|dd�dkr|�qS)Nr	�_r-r�r-r-r.�
<listcomp>s z5CodeGenerator.pop_assign_tracking.<locals>.<listcomp>r	z_loop_vars[�] = z_block_vars[�
context.vars[z_loop_vars.update({z_block_vars.update({�context.vars.update({r6r��})�context.exported_vars.add(rr9zcontext.exported_vars.update((r�)r�r.r�r�r�r�next�iterr�rr�rr�r<r��mapr#)r!r$�varsZpublic_namesrGrr �	names_strr-r-r.�pop_assign_trackingsL
����


�z!CodeGenerator.pop_assign_trackingc	Cs8|dusJd��t|j|j�}ddlm}ddlm}|jjr&t||�}nt|�}|�dd�	|��|j
r9dnd}|�tj
�du}|�tj�D]}	|	j|jvr]|�d	|	j�d
�|	j�|	|j|	j<qI|�tj�D]:}
|
j|jvr�|
j}|��|j|<}d|vr�|�dd�\}
}|�d|
�d
|�d|���qj|�d|�d|���qj|�d|j���|j|�d��d|�d�dd�|��|��t|�}dt|jd�vr�|j�d�}|�|�d��|j� |�d|_!|_"|o�|j#|_$|r�|�d�|�%|�|�&|j�|�'|j|�|j(|dd�|�)�|�rh|j#�s'|��|�d�|��|jj�s6|�d�n)|�d�|�d�|��|�d�|��|�d �|�)�|�)�|�d!�|�)d|j#�|j�*�D]�\}}	|�|�d"|��d|�d�|	d�|��|��t|�}d|_+t|	jd#�}d|v�r�|j�d�}|�|�d��d$|v�r�|j�d$�}|�|�d%|�d&|�d'��|j� |	�||_,|�d(�|�%|�|�&|	j�|�'|	j|�|j(|dd�|�)��qmd�	d)d*�|jD��}|jd+|�d,�dd�d-�	d.d*�|j-D��}|�d/|���dS)0Nzno root frame allowedr	)�async_exported)�exportedzfrom jinja2.runtime import r6rz, environment=environmentzblock z defined twice�.zfrom z import z as zimport zname = �rootz(context, missing=missingr)r�r!r�z = TemplateReference(context)Tzparent_template = Noner�if parent_template is not None:z4yield from parent_template.root_render_func(context)z0agen = parent_template.root_render_func(context)r�zasync for event in agen:zyield eventzfinally: await agen.aclose()Zblock_)r!�superrJz = context.super(z, block_r9z_block_vars = {}css�|]
}|�d|��VqdS)z: block_Nr-r�r-r-r.rW�s�z/CodeGenerator.visit_Template.<locals>.<genexpr>z
blocks = {r��&css"�|]\}}|�d|��VqdS)r�Nr-rXr-r-r.rW�s� z
debug_info = ).rr:rGZruntimerErFr
r�r�r�rJ�findr
�Extends�find_allr�r�r�r��ImportedName�
importnamer�r��rsplitr
r�r-r%rorr�rrr�r�r�r�rr�r�rr�rir�r�r�)r!r#r$r)rErFZexported_namesZenvenvZhave_extendsr��import_�imp�alias�module�objrrGr�rnZ
blocks_kv_strZdebug_kv_strr-r-r.�visit_Template=s���








�



zCodeGenerator.visit_TemplatecCsPd}|jr|jr
dS|jdkr|�d�|��|d7}|jr%|�|�}n|��}|jrJ|�d|j	�d�|�|��|�d|j	�d�|�|�
�|jjsb|j
durb|�d	|j	�d
|�d�|�n?|�d|j	�d
|�d��|�d
�|��|�|���d�|�|��|�d|�|�
�|�
�|�d|�dd����|�
|�dS)z.Call a block and register it for the template.rN�if parent_template is None:r	zif len(context.blocks[z]) <= 1:z+raise TemplateRuntimeError("Required block z not found")zyield from context.blocks[z][0](r9zgen = context.blocks[r��for event in gen:�event�	finally: �await gen.aclose()�gen.close())r�r�r�r�r��scopedr5r3�requiredrGr�r:r
r�rr�)r!r#r$r~r�r-r-r.r��sL

��
��zCodeGenerator.visit_BlockcCs�|js
|�d|j�|jdkr*|js|�d�|��|�d�|jr&t��|��|�d|�|�	|j
|�|�d|j�d��|�d�|��|�d	�|��|j
rYd
|_|jd7_dS)
zCalls the extender.z,cannot use extend from a non top-level scoperrIz5raise TemplateRuntimeError("extended multiple times")z+parent_template = environment.get_template(r6r9z9for name, parent_block in parent_template.blocks.items():z8context.blocks.setdefault(name, []).append(parent_block)Tr	N)r�r�r�r�r�r�r�r�r�r+�templater<rGr�r?r-r-r.�
visit_Extends�s(




zCodeGenerator.visit_Extendscs�|jr��d����d}t|jtj�r+t|jjt�rd}nt|jjt	t
f�r*d}nt|jtjtjf�r7d}��d|�d�|���
|j����d�j�d��|jrt�����d	������d
������d����d��fdd�}|jr���d�����d����d����������d��|������d��dd����n�jjr���d�|�n��d�|jr͈��d
Sd
S)zHandles includes.r�Zget_or_select_templateZget_templateZselect_templateztemplate = environment.r7r6r9zexcept TemplateNotFound:r�r�r Ncs �����d�����dS)NrZ)r�r�r�r-�r$r!r-r.�	loop_body-sz.CodeGenerator.visit_Include.<locals>.loop_bodyzNgen = template.root_render_func(template.new_context(context.get_all(), True, r�rYr[r\r]zGfor event in (await template._get_default_module_async())._body_stream:z6yield from template._get_default_module()._body_streamr�)Zignore_missingr�r�rLr`r
�ConstrRrbrcrd�Tuple�Listr+r<rGr��with_contextr+rr:r
)r!r#r$�	func_namercr-rbr.�
visit_Includes^
�


��
��
�zCodeGenerator.visit_IncludecCs�|�|�d��d��|�|j|�|�d|j�d��|jr7d|�d���}|�|�d|�|��d��dS|�d	|�d��d
��dS)N�await zenvironment.get_template(r6z).Zmake_moduleZ_asyncz(context.get_all(), True, r9Z_get_default_modulez	(context))r<rr+r`rGrgr+)r!r#r$Zf_namer-r-r.�_import_commonLs�zCodeGenerator._import_commoncCst|�|j�|j��d�|�|jr|�d|j�d��|�||�|jr6|j�d�s8|�d|j�d��dSdSdS)zVisit regular imports.r�r;r:r8�context.exported_vars.discard(r9N)r�r�rrr�r<rk�
startswithr?r-r-r.�visit_Import[s�zCodeGenerator.visit_Importc	s�|�|�|�d�|�|��g}g}|jD]k}t|t�r#|\}}n|}|��j�|��d|�d��|�d�j�|��d��|�	�|�
|��dd��dd	�}d
|�d|��}|��j�|��d|�d
|�d��|���j
r�|�|�|�d�s�|�|�q|r�t|�dkr�|d}|�d|�d�j�|����nd��fdd�|D��}	|�d|	�d��|r�t|�dkr�|�d|d�d��dSd�tt|��}
|�d|
�d��dSdS)zVisit named imports.zincluded_template = z = getattr(included_template, z
, missing)rrr*z{{r�z}}z9the template {included_template.__name__!r} (imported on z%) does not export the requested name z = undefined(fz, name=r9r8r	rr;r:r6c3s&�|]}|�d�j�|���VqdSr))r�r)rUrG�r$r-r.rW�s�
�z1CodeGenerator.visit_FromImport.<locals>.<genexpr>r<r=rlz)context.exported_vars.difference_update((r�N)r�r<rkrkrLrcr�r�rr�r(�replacer�r�r�rmrr�rAr#)r!r#r$Z	var_namesZdiscarded_namesrGrTr(�messageZnames_kvrCr-ror.�visit_FromImportfs`




������


� �
��zCodeGenerator.visit_FromImportcCs||��}d|_|��}|��}|jp)dt|jdd�d�vp)tdd�|�tj�D��}d}|r4|j	�
d�}|j	j|dd	�|jrG|j	j|d
d	�|j
r�|��}|j	j|dd	�|�|�|��d�|j
�|��|�|�|�|�d
d��|�|j|�|�d�|�|�dd��|�d�|��|�d|j
�|�|j
|�|�d�|��|�d�|�|j|�|�d�|j|dd�|jr�|�|�d��d�|�|��|�|�|j|_|r�|�|�d��|�tj�D]}	|	jdk�r|	jdk�r|�d|	j�q�|j�r|��}
|�|
�d��|�|�d
d�|�|�|j|�|�r8|�d|�d|�d��d��n|�d�|j
�rI|�|�d��|j�rS|�d �n!|jj �r`|�s`|�d!�|�|j!|�|jj �rt|�st|�d"�|j
�r}|�d"�|j�r�|�d#�n
|�|�r�d$nd�|��|�|�|�d%�|�"|j#|�|j�r�|�|
�d&��|��|j||j�o�|jd�|j�r�|�d|
�d��|��|�|�|�"|j|�|�|�|��|j�r,|�$|�|��|�%||�|�|�d'��d(��|jj �r|�d!�|�|j!|�|jj �r"|�d"�|�d)�|�&|�|j'�r<|j'd*�(|j	j)�dSdS)+NT�loop)r)Zonly)rscsr�r')r^)rUr�r-r-r.rW�r�z*CodeGenerator.visit_For.<locals>.<genexpr>r)Z
for_branch�else�testz(fiter):z
async for zfor r'zauto_aiter(fiter)Zfiter�:rr��rz%(reciter, loop_render_func, depth=0):r��storez8Can't assign to special loop variable in for-loop targetz = 1r6ZAsynczLoopContext(r7Zreciterzauto_aiter(r9z&, undefined, loop_render_func, depth):z
, undefined):z_loop_vars = {}z = 0rjzloop(z, loop)r�)*r�r��	recursiveroZiter_child_nodesr�rNr
r�r�rr�else_rur�r�r
r�rrr+rr<r�rr�r�r�rGr�r�r:r
r@r�rr�r�r�r��difference_updateZstores)r!r#r$r�Z
test_frameZ
else_frameZ
extended_loopZloop_refZloop_filter_funcrGZiteration_indicatorr-r-r.�	visit_For�s����





�
�� 





�








�zCodeGenerator.visit_ForcCs�|��}|�d|�|�|j|�|�d�|��|�|j|�|��|j	D]#}|�d|�|�|j|�|�d�|��|�|j|�|��q(|j
re|�d�|��|�|j
|�|��dSdS)Nrrvzelif r�)r�r�r+rur<r�r�rr��elif_rz)r!r#r$Zif_framer}r-r-r.�visit_If(s(




�zCodeGenerator.visit_IfcCs||�||�\}}|��|jr)|j�d�s|�d|j�d��|�d|j�d��|�|j�|j��d��|�	||�dS)Nr8r>r9r;r:r�)
r"r�r�rGrmr<r�r�rr&)r!r#r$Zmacro_framerr-r-r.�visit_Macro=szCodeGenerator.visit_MacrocCsR|�||�\}}|�d�|�||�|�||�|j|j|dd�|�|�dS)Nz	caller = T)�forward_caller)r"r�r&r��
visit_Call�callr�)r!r#r$Z
call_framerr-r-r.�visit_CallBlockGs
zCodeGenerator.visit_CallBlockcCsh|��}|j�|�|�|�|�|�|�|j|�|�||�|�|j	|�|�
|�|�|�dSr')r�r�rrr�r�rr�r��filterr�r)r!r#r$Zfilter_framer-r-r.�visit_FilterBlockOs


zCodeGenerator.visit_FilterBlockcCs||��}|j�|�|�|�t|j|j�D]\}}|��|�||�|�	d�|�||�q|�
|j|�|�|�dS)Nr�)
r�r�rr�zip�targets�valuesr�r+r<r�rr)r!r#r$Z
with_framer�exprr-r-r.�
visit_WithZs

zCodeGenerator.visit_WithcCs|�|�|�|j|�dSr')r�r+r#r?r-r-r.�visit_ExprStmtfr�zCodeGenerator.visit_ExprStmtc@s4eZdZUejejdefed<ejeed<dS)zCodeGenerator._FinalizeInfo.�const�srcN)rwrxryr1r��Callablerb�__annotations__r-r-r-r.�
_FinalizeInfojs
r�rRcCst|�S)z�The default finalize function if the environment isn't
        configured with one. Or, if the environment has one, this is
        called on that function's output for constants.
        )rbrjr-r-r.�_default_finalizenszCodeGenerator._default_finalize�	_finalizecs��jdur�jS�j}�d}�jjrYd}�jj�tjdtjdtjdi�t����}d}|dur?dt	j
dt	j
f��fdd	�}n|�|�d
�}|dkrYdt	j
dt	j
f���fdd	�}��||��_�jS)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.
        Nzenvironment.finalize(r��context.eval_ctxr:rRr cs��|��Sr'r-rj)r!�env_finalizer-r.�finalize�sz.CodeGenerator._make_finalize.<locals>.finalizer6cs���j|��Sr')r:rj�r!r�r!r-r.r��r)r�r�r:r�rr��eval_context�get�from_objr1r2r�)r!r�r��pass_argr-r�r.�_make_finalizexs.


���zCodeGenerator._make_finalize�groupcCstt|��S)z�Given a group of constant values converted from ``Output``
        child nodes, produce a string to write to the template module
        source.
        )r#r)r!r�r-r-r.�_output_const_repr�sz CodeGenerator._output_const_reprr�cCs:|�|j�}|jjrt|�}t|tj�rt|�S|�|�S)aCTry 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�rrLr
�TemplateDatarbr�)r!r#r$r�r�r-r-r.�_output_child_to_const�s

z$CodeGenerator._output_child_to_constcCsP|jjr
|�d�n|jjr|�d�n|�d�|jdur&|�|j�dSdS)zXOutput extra source code before visiting a child of an
        ``Output`` node.
        z1(escape if context.eval_ctx.autoescape else str)(zescape(zstr(N)r)r*r<r�r��r!r#r$r�r-r-r.�_output_child_pre�s

�zCodeGenerator._output_child_precCs&|�d�|jdur|�d�dSdS)zWOutput extra source code after visiting a child of an
        ``Output`` node.
        r9N)r<r�r�r-r-r.�_output_child_post�s

�z CodeGenerator._output_child_postc	
Cs�|jr|jrdS|�d�|��|��}g}|jD]A}z|js*t|tj�s*t�	��|�
|||�}Wntj	tfyC|�|�Yqw|rUt|dt
�rU|d�|�q|�|g�q|jdur~t|�dkrq|�|j�d��n	|�|j�d��|��|D]P}t|t
�r�|�|�}|jdur�|�d|�q�|�|d�q�|jdur�|�d|�n|�|�|�|||�|�||�|�|||�|jdur�|�d�q�|jdur�|��|�t|�dkr�dnd	�|jr�|��dSdS)
NrXr�r	r�z	.extend((r�r$r9r�)r�r�r�r�r�r
r�rLr��
Impossibler��	Exceptionr�rdr�rr�r�r�r+r�r<r�)	r!r#r$r�r�childr��item�valr-r-r.�visit_Output�s`

�
�
�







�
�zCodeGenerator.visit_OutputcCs�|��t�}|�tj�D]+}|j|vrq
|�|j�|j�|j�}|�	d|�d��|�
�|�	d�|��q
|�|�|�
|j|�|�d�|�
|j|�|�|�dS)Nzif not isinstance(z
, Namespace):zMraise TemplateRuntimeError("cannot assign attribute on non-namespace object")r�)r7rerNr
�NSRefrGr�r�rr�r�r�r�r+rr<r#rD)r!r#r$Z	seen_refsZnsrefrr-r-r.�visit_Assign.s$
�


zCodeGenerator.visit_AssigncCs�|��|��}d|_|j�|�|�|�|�|�|�|j|�|�	|�|�
|j|�|�d�|j
dur@|�|j
|�n
|�d|j�d��|�d�|�|�|�|�dS)NFz9 = (Markup if context.eval_ctx.autoescape else identity)(�concat(r9)r7r�r�r�rrr�r�rr�r+rr<r�r�rDr)r!r#r$r�r-r-r.�visit_AssignBlockMs 






zCodeGenerator.visit_AssignBlockc	Cs�|jdkr|js|js|jr|jr|jd�|j�|j�|j�}|jdkrM|j�	|�}|dur;|dt
kr;|�|�rM|�d|j�d|�d|�d��dS|�|�dS)	Nrxr�r�rz(undefined(name=z) if z is missing else r9)
r�r�r�r�r�r�rGr�rZ	find_loadrr6r<)r!r#r$rr�r-r-r.r�es*
���
��zCodeGenerator.visit_NamecCs*|j�|j�}|�|�d|j�d��dS)Nr�r�)r�rrGr��attr)r!r#r$rr-r-r.�visit_NSRef~szCodeGenerator.visit_NSRefcCs:|�|j�}t|t�r|�t|��dS|�t|��dSr')r�r)rLr_r<rbr#)r!r#r$r�r-r-r.�visit_Const�s
zCodeGenerator.visit_ConstcCsHz|�t|�|j���WdStjy#|�d|j�d��YdSw�Nz6(Markup if context.eval_ctx.autoescape else identity)(r9)r<r#r�r)r
r��datar?r-r-r.�visit_TemplateData�s
��z CodeGenerator.visit_TemplateDatacCs\|�d�d}t|j�D]\}}|r|�d�|�||�q|�|dkr)d�dSd�dS)Nr7r�r6rz,)r9�r<rrir+�r!r#r$r r�r-r-r.�visit_Tuple�s

 zCodeGenerator.visit_TuplecCsF|�d�t|j�D]\}}|r|�d�|�||�q
|�d�dS)Nr�r6r�r�r�r-r-r.�
visit_List�s

zCodeGenerator.visit_ListcCs`|�d�t|j�D]\}}|r|�d�|�|j|�|�d�|�|j|�q
|�d�dS)Nr*r6r�r�)r<rrir+r�rRr�r-r-r.�
visit_Dict�s


zCodeGenerator.visit_Dict�+�-�*�/z//z**�%�and�orznot cCs`|jjrd}n	|jjrd}nd}|�|�d��|jD]
}|�||�|�d�q|�d�dS)Nz8(markup_join if context.eval_ctx.volatile else str_join)Zmarkup_joinZstr_joinz((r6r�)r)r*r�r<r
r+)r!r#r$rhr�r-r-r.�visit_Concat�s
zCodeGenerator.visit_ConcatcCs>|�d�|�|j|�|jD]}|�||�q|�d�dS)Nr7r9)r<r+r��ops)r!r#r$r4r-r-r.�
visit_Compare�s


zCodeGenerator.visit_ComparecCs*|�dt|j�d��|�|j|�dS)Nr8)r<�	operatorsr4r+r�r?r-r-r.�
visit_Operand�szCodeGenerator.visit_OperandcCsX|jjr	|�d�|�d�|�|j|�|�d|j�d��|jjr*|�d�dSdS)N�(await auto_await(zenvironment.getattr(r6r9r�)r:r
r<r+r#r�r?r-r-r.�
visit_Getattr�s

�zCodeGenerator.visit_GetattrcCs�t|jtj�r!|�|j|�|�d�|�|j|�|�d�dS|jjr*|�d�|�d�|�|j|�|�d�|�|j|�|�d�|jjrR|�d�dSdS)Nr�r�r�zenvironment.getitem(r6r9r�)	rLr�r
�Slicer+r#r<r:r
r?r-r-r.�
visit_Getitem�s




�zCodeGenerator.visit_GetitemcCsd|jdur|�|j|�|�d�|jdur|�|j|�|jdur0|�d�|�|j|�dSdS)Nrv)�startr+r<�stopr�r?r-r-r.�visit_Slice�s




�zCodeGenerator.visit_Slice�	is_filterccs�|jjr
|�d�|r!|�|j|j�d��|jj�|j�}n|�|j|j�d��|jj�|j�}|durQ|jsQ|r@dnd}|�d|�d|j�d�|j	�t
jdt
jd	t
jd
i�t
�
|��}|durn|�|�d��dV|�||�|�d�|jjr�|�d
�dSdS)Nr�r7r�ruzNo r�rGr�r�r:r6r9r�)r:r
r<r�rGr�r�r�r�r�rr�r�r�r�)r!r#r$r�r
�	type_namer�r-r-r.�_filter_test_commons6�
���
�z!CodeGenerator._filter_test_commoncCs�|�||d��Z|jdur|�|j|�n4|jjr(|�d|j�d|j�d��n)|jjr7|�d|j�d��n"|�d|j�d��Wd�dSWd�dSWd�dSWd�dS1sdwYdS)NTz(Markup(concat(z.)) if context.eval_ctx.autoescape else concat(r�zMarkup(concat(r�r9)r�r#r+r)r*r<r�r�r?r-r-r.r�,s&

�����"�zCodeGenerator.visit_FiltercCsB|�||d��|�|j|�Wd�dS1swYdSrq)r�r+r#r?r-r-r.r�=s"�zCodeGenerator.visit_Testcsh����d���fdd�}��d����j����d����j����d�|���d�dS)	Nr cs8�jdur���j��dS��d�����d��dS)Nz1cond_expr_undefined("the inline if-expression on z6 evaluated to false and no else section was defined."))Zexpr2r+r<r(r-�r$r#r!r-r.�write_expr2Fs
��z1CodeGenerator.visit_CondExpr.<locals>.write_expr2r7z if z else r9r�)r�r<r+Zexpr1ru)r!r#r$r�r-r�r.�visit_CondExprBs


zCodeGenerator.visit_CondExprr�cCs�|jjr	|�d�|jjr|�d�n|�d�|�|j|�|r%ddind}|jr.ddini}|jr7ddini}|rE|j|fi|��n|sI|rQt	|fi|��}|�
|||�|�d�|jjrh|�d�dSdS)	Nr�zenvironment.call(context, z
context.call(rZ
_loop_varsZ_block_varsr9r�)r:r
r<r;r+r#r�r�r�rhr�)r!r#r$r�r�Zloop_kwargsZblock_kwargsr-r-r.r�Ys$


�zCodeGenerator.visit_CallcCs"|�|jd�|�|j|�dS)Nr�)r<r�r+rRr?r-r-r.�
visit_KeywordpszCodeGenerator.visit_KeywordcC�&|�d�|�|j|�|�d�dS)NzMarkup(r9�r<r+r�r?r-r-r.�visit_MarkSafevs
zCodeGenerator.visit_MarkSafecCr�r�r�r?r-r-r.�visit_MarkSafeIfAutoescape{s
z(CodeGenerator.visit_MarkSafeIfAutoescapecCs|�d|j�dS)Nzenvironment.�r<rGr?r-r-r.�visit_EnvironmentAttribute��z(CodeGenerator.visit_EnvironmentAttributecCs|�d|j�d|j���dS)Nzenvironment.extensions[z].)r<Z
identifierrGr?r-r-r.�visit_ExtensionAttribute�sz&CodeGenerator.visit_ExtensionAttributecCs|�|j|j�dSr')r<r�rPr?r-r-r.�visit_ImportedName�sz CodeGenerator.visit_ImportedNamecCs|�|j�dSr'r�r?r-r-r.�visit_InternalName�rz CodeGenerator.visit_InternalNamecCs|�d�dS)Nr�)r<r?r-r-r.�visit_ContextReference�sz$CodeGenerator.visit_ContextReferencecCs|�|�|��dSr')r<r5r?r-r-r.�visit_DerivedContextReference�r�z+CodeGenerator.visit_DerivedContextReferencecC�|�d|�dS)N�continuer,r?r-r-r.�visit_Continue�rzCodeGenerator.visit_ContinuecCr�)N�breakr,r?r-r-r.�visit_Break�rzCodeGenerator.visit_BreakcCs:|��}|j�|�|�|�|�|j|�|�|�dSr')r�r�rrr�rr)r!r#r$�scope_framer-r-r.�visit_Scope�s

zCodeGenerator.visit_ScopecCs�|��}|�|�d|�|����|�|�d��|�|j|�|�|�|jdd�}|j�|�|�	|�|�
|j|�|�|�|�
�dS)Nr�z.vars = T)r�)r�r�r5r+r�r0r�r�rrr�rrr1)r!r#r$r�r�r-r-r.�visit_OverlayScope�s


z CodeGenerator.visit_OverlayScopec	Csr|jD]3}|�d|j�d��|�|j|�z	|j�|j�}Wntjy-d|j_	Yqwt
|j|j|�qdS)Nzcontext.eval_ctx.r�T)�optionsr�r�r+rRr�r)r
r�r*�setattr)r!r#r$�keywordr�r-r-r.�visit_EvalContextModifier�s
��z'CodeGenerator.visit_EvalContextModifiercCsh|��}|j��}|�|�d��|�||�|jD]}|�||�q|j�|�|�d|�d��dS)Nz = context.eval_ctx.save()zcontext.eval_ctx.revert(r9)r�r)Zsaver�r�rr+Zrevert)r!r#r$Zold_ctx_nameZ	saved_ctxr�r-r-r.�visit_ScopedEvalContextModifier�s

z-CodeGenerator.visit_ScopedEvalContextModifier�NFTr�r�)r	r')Nr)rr)�rwrxryr1r�rb�TextIOr]rv�propertyrKr^r�r�r%r�r�r�r�r
�Noder�r�r�r�r�r<r�r�rzZCallr�r��Mappingr2r�r�rrrr
r{r|rerpr"r&r(r+r-rrrr0r1r3r�r5r6r7rDrMrWr�r�rMraZIncluderiZImportZ
FromImportrkrnrrZForr|ZIfr~rr�ZFilterBlockr�ZWithr�ZExprStmtr�Z
NamedTupler��staticmethodr�r�r�r�r�r0r�r�r�ZOutputr�ZAssignr�ZAssignBlockr�r�r�r�r�rdr�r�r�r�rfr�ZDictr�rDZ	visit_AddZ	visit_SubZ	visit_MulZ	visit_DivZvisit_FloorDivZ	visit_PowZ	visit_ModZ	visit_AndZvisit_OrrFZ	visit_PosZ	visit_NegZ	visit_Notr3ZConcatr�ZComparer�ZOperandr�ZGetattrr�ZGetitemr�r�r�r�Iteratorr�r�r�ZCondExprr�r�ZKeywordr�ZMarkSafer�ZMarkSafeIfAutoescaper�ZEnvironmentAttributer�ZExtensionAttributer�rOr�ZInternalNamer�ZContextReferencer�ZDerivedContextReferencer��Continuer�ZBreakr�ZScoper�ZOverlayScoper�ZEvalContextModifierr�ZScopedEvalContextModifierr�r-r-r-r.r",s"
����
���
�I���
�
 ���
�
���
��
� ����
�9.��
�S

	

.���
�z1*:��
�7
0���
����
����
�O	


����)�������
���
���
���
���
���
�
���r�)Fr��typingr1�
contextlibr�	functoolsr�ior�	itertoolsrr�rr�Z
markupsaferrrr
�
exceptionsrZ
idtrackingrr
rrrrr(r�utilsrrrArZ
TYPE_CHECKINGZtyping_extensions�ter:r�TypeVarr�r2rr�r3rbrBrDrErFrMr�r�r]rQrTr�r��Setrorpr%�RuntimeErrorrmr�rlr�r�r"r-r-r-r.�<module>s��$�
������
���
�
��
�S