Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/compiler.cpython-37.pyc

B

ף�a�
@srdZddlZddlmZddlmZddlmZddl	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,e+e+d$�d%d&�Z-e.ej)d'ej/d(gdfd)�d*d+�Z0e.ej)d'ej1d(gdfd)�d,d-�Z2dFej3d0ej4e.ej4e.ej4ej5e6e6ej4e.d1�d2d3�Z7ej*e6d4�d5d6�Z8ej9ej:ej9e.ej;e.d7�d8d9�Z<Gd:d;�d;�Z=Gd<d(�d(�Z>Gd=d>�d>e?�Z@Gd?d@�d@e"�ZAGdAdB�dBe"�ZBGdCdD�dDeC�ZDGdEd'�d'e"�ZEdS)Gz0Compiles 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.)�boundz==z!=�>z>=�<z<=�inznot in)�eq�ne�gtZgteq�ltZlteqrZnotin)�f�returncs2dtjdtjtjd��fdd�}tt�t|���S)N�
CodeGenerator�Frame)�self�node�frame�kwargsr!csF|jdk	r6|jjs6|j�||j�}||kr6|�||�S�|||f|�S)N)�	optimizer�eval_ctx�volatile�visit)r$r%r&r'�new_node)r ��@/opt/alt/python37/lib/python3.7/site-packages/jinja2/compiler.py�new_func,s
zoptimizeconst.<locals>.new_func)r
�Expr�t�Anyr�castr)r r/r-)r r.�
optimizeconst+s
r4r"r#)�opr!cs"tdtjtdd��fdd��}|S)Nr")r$r%r&r!cs�|jjrN�|jjkrN|�d��d��|�|j|�|�d�|�|j|�n8|�d�|�|j|�|�d��d��|�|j|�|�d�dS)Nz environment.call_binop(context, z, �(� �))�environment�	sandboxedZintercepted_binops�writer+�left�right)r$r%r&)r5r-r.�visitor<s

z_make_binop.<locals>.visitor)r4r
�BinExprr#)r5r>r-)r5r.�_make_binop;sr@cs"tdtjtdd��fdd��}|S)Nr")r$r%r&r!cs`|jjr6�|jjkr6|�d��d��|�|j|�n|�d��|�|j|�|�d�dS)Nzenvironment.call_unop(context, z, r6r8)r9r:Zintercepted_unopsr;r+r%)r$r%r&)r5r-r.r>Tsz_make_unop.<locals>.visitor)r4r
�	UnaryExprr#)r5r>r-)r5r.�
_make_unopQs
rBFTr)r%r9�name�filename�stream�
defer_init�	optimizedr!cCsHt|tj�std��|�||||||�}|�|�|dkrD|j��SdS)z+Generate the python source for a node tree.z Can't compile non template nodesN)�
isinstancer
�Template�	TypeErrorZcode_generator_classr+rE�getvalue)r%r9rCrDrErFrG�	generatorr-r-r.�generatees


rM)�valuer!cCs�|dks|tks|tkrdSt|�ttttttt	hkr:dSt|�t
ttt
hkr`tdd�|D��St|�tkr�tdd�|��D��SdS)z)Does the node have a safe representation?NTcss|]}t|�VqdS)N)�
has_safe_repr)�.0�vr-r-r.�	<genexpr>�sz has_safe_repr.<locals>.<genexpr>css"|]\}}t|�ot|�VqdS)N)rO)rP�krQr-r-r.rR�sF)�NotImplemented�Ellipsis�type�bool�int�float�complex�range�strr�tuple�list�set�	frozenset�all�dict�items)rNr-r-r.rO}srO)r
�namesr!cCs@t|�}yx|D]}|�|�qWWntk
r8YnX|jS)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
rdr>r%r-r-r.�find_undeclared�s
rhc@s*eZdZejejejfdd�dd�ZdS)�MacroRefN)r%r!cCs||_d|_d|_d|_dS)NF)r%�accesses_caller�accesses_kwargs�accesses_varargs)r$r%r-r-r.�__init__�szMacroRef.__init__)	�__name__�
__module__�__qualname__r1�Unionr
�Macro�	CallBlockrmr-r-r-r.ri�sric@sdeZdZdZdeejdejedd�dd�Zdd�dd�Z	de
dd
�dd�Zdd�d
d�Ze	Z
dS)r#z&Holds compile time information for us.N)r)�parent�levelr!cCs~||_||_|dkr4t|d�|_d|_d|_d|_n(t|j|d�|_|j|_|j|_|j|_d|_d|_d|_	d|_
d|_dS)N)ruF)r)rtr�symbols�require_output_check�buffer�block�toplevel�	rootlevel�
loop_frame�block_frame�
soft_frame)r$r)rtrur-r-r.rm�s zFrame.__init__)r!cCs2t�tt�|j��}|j�|j�|j�	�|_|S)z!Create a copy of the current one.)
r1r3r#�object�__new__�	__class__�__dict__�updaterv�copy)r$�rvr-r-r.r��sz
Frame.copyF)�isolatedr!cCs&|rt|j|jjdd�St|j|�S)zReturn an inner frame.r	)ru)r#r)rvru)r$r�r-r-r.�inner�szFrame.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-r.�soft�sz
Frame.soft)NN)F)rnrorp�__doc__rr1�OptionalrXrmr�rWr�r��__copy__r-r-r-r.r#�s.
c@seZdZdZdS)rfz?Exception used by the `UndeclaredNameVisitor` to signal a stop.N)rnrorpr�r-r-r-r.rf�srfc@sTeZdZdZdd�dd�Zejdd�dd�Zejdd�d	d
�Z	ej
dd�dd�ZdS)
�DependencyFinderVisitorz.A visitor that collects filter and test calls.N)r!cCst�|_t�|_dS)N)r_�filters�tests)r$r-r-r.rm�sz DependencyFinderVisitor.__init__)r%r!cCs|�|�|j�|j�dS)N)�
generic_visitr��addrC)r$r%r-r-r.�visit_Filters
z$DependencyFinderVisitor.visit_FiltercCs|�|�|j�|j�dS)N)r�r�r�rC)r$r%r-r-r.�
visit_Tests
z"DependencyFinderVisitor.visit_TestcCsdS)zStop visiting at blocks.Nr-)r$r%r-r-r.�visit_Blocksz#DependencyFinderVisitor.visit_Block)rnrorpr�rmr
�Filterr��Testr��Blockr�r-r-r-r.r��s
r�c@sJeZdZdZejedd�dd�Zej	dd�dd�Z
ejdd�d	d
�ZdS)rez�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.
    N)rdr!cCst|�|_t�|_dS)N)r_rdrg)r$rdr-r-r.rms
zUndeclaredNameVisitor.__init__)r%r!cCsJ|jdkr8|j|jkr8|j�|j�|j|jkrFt��n|j�|j�dS)N�load)�ctxrCrdrgr�rf�discard)r$r%r-r-r.�
visit_Names
z UndeclaredNameVisitor.visit_NamecCsdS)zStop visiting a blocks.Nr-)r$r%r-r-r.r�!sz!UndeclaredNameVisitor.visit_Block)
rnrorpr�r1�Iterabler\rmr
�Namer�r�r�r-r-r-r.resrec@seZdZdZdS)�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.
    N)rnrorpr�r-r-r-r.r�%sr�c	@sJeZdZUd�dejeejeejejeedd�dd�Ze	ed�d	d
��Z
eedd�d
d�Zed�dd�Z
edd�dd�Zd�eedd�dd�Zdd�dd�Zd�edd�dd�Zd�eejejdd�dd�Zedd�d d!�Zd�eeejejdd"�d#d$�Zejejedd%�d&d'�Zedd(�d)d*�Zd�eejejedd,�d-d.�Zd�ejejedd/�d0d1�Zd�ejejejej feejej!eej"fdd2�d3d4�Z#ejejdd5�d6d7�Z$edd�d8d9�Z%d�eedd:�d;d<�Z&d�eeed?�d@dA�Z'eedB�dCdD�Z(ejej)ej*feej+ee,fdE�dFdG�Z-e,eddH�dIdJ�Z.ejedK�dLdM�Z/eed�dNdO�Z0dd�dPdQ�Z1edd�dRdS�Z2dd�dTdU�Z3eddV�dWdX�Z4eddV�dYdZ�Z5dd�d[d\�Z6ed�d]d^�Z7ed�d_d`�Z8eed�dadb�Z9eedV�dcdd�Z:dd�dedf�Z;edd�dgdh�Z<d�ej=ejeddE�didj�Z>ej?eddE�dkdl�Z@ejAeddE�dmdn�ZBejCeddE�dodp�ZDejejEejFfeddE�dqdr�ZGejEeddE�dsdt�ZHejFeddE�dudv�ZIejJeddE�dwdx�ZKejLeddE�dydz�ZMej)eddE�d{d|�ZNej*eddE�d}d~�ZOejPeddE�dd��ZQejReddE�d�d��ZSejTeddE�d�d��ZUGd�d��d�ejV�ZWeXej"ej"d��d�d���ZYdZZejeWe[d�<eWd�d�d��Z\ejej"ed��d�d��Z]ej^eeWed��d�d��Z_ej^eeWdd��d�d��Z`ej^eeWdd��d�d��ZaejbeddE�d�d��ZcejdeddE�d�d��ZeejfeddE�d�d��ZgejheddE�d�d��ZiejjeddE�d�d��ZkejleddE�d�d��ZmejneddE�d�d��Zoej+eddE�d�d��ZpejqeddE�d�d��ZrejseddE�d�d��Zteud��Zveud��Zweud��Zxeud��Zyeud��Zzeud��Z{eud��Z|eud��Z}eud��Z~ed��Z�ed��Z�ed��Z�e�ej�eddE�d�d���Z�e�ej�eddE�d�d���Z�ej�eddE�d�d��Z�e�ej�eddE�d�d���Z�e�ej�eddE�d�d���Z�ej�eddE�d�d��Z�e�ejejej feeej�dd��d�dÄ�Z�e�ejeddE�d�dń�Z�e�ej eddE�d�dDŽ�Z�e�ej�eddE�d�dɄ�Z�e�d�ejeeddʜd�d̄�Z�ej�eddE�d�d΄Z�ej�eddE�d�dЄZ�ej�eddE�d�d҄Z�ej�eddE�d�dԄZ�ej�eddE�d�dքZ�ej�eddE�d�d؄Z�ej�eddE�d�dڄZ�ej�eddE�d�d܄Z�ej�eddE�d�dބZ�ej�eddE�d�d�Z�ej�eddE�d�d�Z�ej�eddE�d�d�Z�ej�eddE�d�d�Z�ej�eddE�d�d�Z�ej�eddE�d�d�Z�dS)�r"NFTr)r9rCrDrErFrGr!cCs�|dkrt�}||_||_||_||_d|_||_d|_|rFt|�|_i|_	i|_
d|_d|_d|_
i|_i|_g|_d|_d|_d|_d|_d|_d|_g|_g|_dg|_dS)NFrr	T�context)rr9rCrDrEZcreated_block_contextrFr(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$r9rCrDrErFrGr-r-r.rm-s8	
zCodeGenerator.__init__)r!cCs
|jdk	S)N)r()r$r-r-r.rGvszCodeGenerator.optimizedzte.NoReturn)�msg�linenor!cCst|||j|j��dS)z*Fail with a :exc:`TemplateAssertionError`.N)rrCrD)r$r�r�r-r-r.�fail|szCodeGenerator.failcCs|jd7_d|j��S)zGet a new unique identifier.r	Zt_)r�)r$r-r-r.�temporary_identifier�sz"CodeGenerator.temporary_identifier)r&r!cCs |��|_|�|j�d��dS)z7Enable buffering for the frame from that point onwards.z = []N)r�rx�	writeline)r$r&r-r-r.rx�s
zCodeGenerator.buffer)r&�force_unescapedr!cCs�|s�|jjrl|�d�|��|�d|j�d��|��|�d�|��|�d|j�d��|��dS|jjr�|�d|j�d��dS|�d|j�d��dS)z(Return the buffer contents of the frame.zif context.eval_ctx.autoescape:zreturn Markup(concat(z))zelse:zreturn concat(r8N)r)r*r��indentrx�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��szCodeGenerator.indentr	)�stepr!cCs|j|8_dS)zOutdent by step.N)r�)r$r�r-r-r.r��szCodeGenerator.outdent)r&r%r!cCs0|jdkr|�d|�n|�|j�d�|�dS)z%Yield or write into the frame buffer.Nzyield z.append()rxr�)r$r&r%r-r-r.�start_write�s
zCodeGenerator.start_writecCs|jdk	r|�d�dS)z1End the writing process started by `start_write`.Nr8)rxr;)r$r&r-r-r.�	end_write�s
zCodeGenerator.end_write)�sr&r%r!cCs$|�||�|�|�|�|�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_write)r
r&r!cCsBy(|�d�x|D]}|�||�qWWntk
r<YnXdS)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)�xr!cCs�|jrp|jsR|j�d|j�|j|j7_|jdk	rR|j�|j|jf�d|_d|_|j�d|j�d|_|j�|�dS)z&Write a string into the output stream.�
NFz    r)	r�r�rEr;r�r�r��appendr�)r$r�r-r-r.r;�s
zCodeGenerator.writer)r�r%�extrar!cCs|�||�|�|�dS)z!Combination of newline and write.N)�newliner;)r$r�r%r�r-r-r.r��szCodeGenerator.writeline)r%r�r!cCs:t|jd|�|_|dk	r6|j|jkr6|j|_|j|_dS)z/Add one or more newlines before the next write.r	N)�maxr�r�r�r�)r$r%r�r-r-r.r��szCodeGenerator.newline)r%r&�extra_kwargsr!c	Cs�tdd�tdd�|jD�|pd�D��}x$|jD]}|�d�|�||�q0W|s�x$|jD]}|�d�|�||�qZW|dk	r�x*|��D]\}}|�d|�d|���q�W|jr�|�d�|�|j|�|�r�|jdk	r�|�d	�n
|�d
�x8|jD].}|�|j	�d��|�|j
|�|�d�q�W|dk	�rbx,|��D] \}}|�|�d|�d���q>W|jdk	�r�|�d�|�|j|�|�d
�n
|�d�n$|jdk	�r�|�d�|�|j|�dS)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|��VqdS)N)�is_python_keywordr1r3r\)rPrSr-r-r.rR�sz*CodeGenerator.signature.<locals>.<genexpr>css|]}|jVqdS)N)�key)rPr�r-r-r.rR�sr-z, N�=z, *z
, **dict({z, **{z: z}, **r8�}z, **)�anyrr'�argsr;r+rcZdyn_argsZ
dyn_kwargsr�rN)	r$r%r&r�Zkwarg_workaround�arg�kwargr�rNr-r-r.�	signature�sF 







zCodeGenerator.signature)r
r!c
Cst�}x|D]}|�|�qWx�|j|jdf|j|jdffD]�\}}}x�t|�D]�}||krh|��||<|�d�|��|�||�d|�d|�d��|��|�d�|��|�d�|�d	||�d
��|��|�d|dd
��d|�d��|��|��qPWq<Wd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�ztry:z = environment.�[�]zexcept KeyError:z
@internalcodezdef z
(*unused):zraise TemplateRuntimeError("No N���z named z	 found."))	r�r+r�r��sortedr�r�r�r�)r$r
r>r%Zid_maprdZ
dependencyrCr-r-r.�pull_dependenciess.

 

zCodeGenerator.pull_dependenciesc	Cs�g}x�|jj��D]z\}\}}|tkr(q|tkrR|�|�d|���d|�d��q|tkrp|�|�d|���q|tkr�|�	|�qt
d��qW|r�|�d�|��d��dS)Nz = r6r8zunknown load instructionz
 = missing)rv�loadsrcrrr��get_resolve_funcr
rr��NotImplementedError�join)r$r&�undefs�target�action�paramr-r-r.�enter_frameEs"zCodeGenerator.enter_frame)r&�with_python_scoper!cCsB|s>g}x|jjD]}|�|�qW|r>|�d�|��d��dS)Nz = z
 = missing)rvr�r�r�r�)r$r&r�r�r�r-r-r.�leave_frameUszCodeGenerator.leave_frame�async �)�async_value�
sync_valuer!cCs|jjr|S|S)N)r9�is_async)r$r�r�r-r-r.�choose_async]szCodeGenerator.choose_async)rCr!cCs|���d|��S)Nzdef )r�)r$rCr-r-r.�func`szCodeGenerator.func)r%r&r!cCs�|��}|j�|�t|�}d}t�}g}xNt|j�D]@\}}|jdkrL|}|jdkrb|�|j�|�	|j�
|j��q6Wt|jd�}	d|	kr�|dk	r�y|j
|t|j�Wq�tk
r�|�d|j�Yq�Xn|�	|j�d��d|_d|	k�rd|k�r|�	|j�d��d|_d|	k�rDd|k�rD|�	|j�d��d|_d	|_|j�|�|�|�d
��dd�|��d
�|�|��|�|�|�|�|�|�x�t|j�D]�\}}|j�
|j�}
|�d|
�d��|��y|j
|t|j�}Wn6tk
�r*|�|
�d|j�d|j�d��YnX|�|
�d��|�||�|�|
�|� ��q�W|�!�|�"|j|�|j#|dd�|j$|dd�|� �||fS)z/Dump the function def of a macro or call block.N�caller)r'�varargs)r�r'r�zhWhen defining macros or call blocks the special "caller" argument must be omitted or be given a default.Tr'r�F�macror6z, z):zif z is missing:z = undefined("parameter z was not provided", name=r8z = )r�)r�)%r�rv�analyze_noderir_�	enumerater�rCr�r��refrh�body�defaults�len�
IndexErrorr�r��declare_parameterrjrkrlrwr�r�r�r�rxr��push_parameter_definitionsr+�mark_parameter_storedr��pop_parameter_definitionsr�r�r�)r$r%r&�	macro_refZexplicit_callerZskip_special_paramsr��idxr�rgr��defaultr-r-r.�
macro_bodycsn

$


"
zCodeGenerator.macro_body)r�r&r!c
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.z, css|]}t|j�VqdS)N)�reprrC)rPr�r-r-r.rR�sz*CodeGenerator.macro_def.<locals>.<genexpr>rCNr	�,zMacro(environment, macro, z, (z), z, context.eval_ctx.autoescape))	r�r%r��getattrr�r;rkrlrj)r$r�r&Z	arg_tuplerCr-r-r.�	macro_def�szCodeGenerator.macro_def)r%r!cCs*d|j��}|jdk	r&|�d|j��}|S)z.Return a human readable position for the node.zline Nz in )r�rC)r$r%r�r-r-r.�position�s
zCodeGenerator.positioncCs*d�dd�|j����D��}d|�d�S)Nz, css |]\}}|�d|��VqdS)z: Nr-)rPrCr�r-r-r.rR�sz3CodeGenerator.dump_local_context.<locals>.<genexpr>�{r�)r�rvZdump_storesrc)r$r&Zitems_kvr-r-r.�dump_local_context�sz CodeGenerator.dump_local_contextcCs,|�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.undefinedzcond_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�rvZdump_param_targets)r$r&r-r-r.r��sz(CodeGenerator.push_parameter_definitionscCs|j��dS)z+Pops the current parameter definitions set.N)r��pop)r$r-r-r.r��sz'CodeGenerator.pop_parameter_definitions)r�r!cCs|jr|jd�|�dS)z�Marks a parameter in the current parameter definitions as stored.
        This will skip the enforced undefined checks.
        r�N)r�r�)r$r�r-r-r.r��sz#CodeGenerator.mark_parameter_storedcCs|j�|�dS)N)r�r�)r$r�r-r-r.�push_context_reference�sz$CodeGenerator.push_context_referencecCs|j��dS)N)r�r)r$r-r-r.�pop_context_reference�sz#CodeGenerator.pop_context_referencecCs
|jdS)Nr�)r�)r$r-r-r.�get_context_ref�szCodeGenerator.get_context_refcCs |jd}|dkrdS|�d�S)Nr�r��resolvez.resolve)r�)r$r�r-r-r.r��s
zCodeGenerator.get_resolve_funccCs|���d|�|��d�S)Nz	.derived(r8)rr�)r$r&r-r-r.�derive_context�szCodeGenerator.derive_contextcCs|js
dS||jdkS)z4Checks if a given target is an undeclared parameter.Fr�)r�)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�r_)r$r-r-r.�push_assign_trackingsz"CodeGenerator.push_assign_trackingcCs�|j��}|js|js|jr |s$dSdd�|D�}t|�dkr�tt|��}|j�	|�}|jrv|�
d|�d|���dS|jr�|�
d|�d|���dS|�
d|�d|���n||jr�|�
d	�n|jr�|�
d
�n
|�
d�xBt|�D]6\}}|r�|�d�|j�	|�}|�|�d
|���q�W|�d�|j�s�|j�s�|�r�t|�dk�rf|�
d|d�d��n"d�
tt|��}|�
d|�d��dS)zoPops the topmost level for assignment tracking and updates the
        context variables if necessary.
        NcSs g|]}|dd�dkr|�qS)Nr	�_r-)rPr�r-r-r.�
<listcomp>sz5CodeGenerator.pop_assign_tracking.<locals>.<listcomp>r	z_loop_vars[z] = z_block_vars[z
context.vars[z_loop_vars.update({z_block_vars.update({zcontext.vars.update({z, z: z})zcontext.exported_vars.add(rr8zcontext.exported_vars.update((z)))r�rr}r|rzr��next�iterrvr�r�r�r;r��mapr�)r$r&�varsZpublic_namesrCr�r��	names_strr-r-r.�pop_assign_trackingsB



z!CodeGenerator.pop_assign_trackingc	Cs$|dkstd��t|j|j�}ddlm}m}|jjrDt||�}nt|�}|�	d�|�	dd�
|��|jrtdnd}|�t
j�dk	}xD|�t
j�D]4}	|	j|jkr�|�d	|	j�d
�|	j�|	|j|	j<q�Wx�|�t
j�D]v}
|
j|jkr�|
j}|��|j|<}d|k�r<|�dd�\}
}|�	d|
�d
|�d|���q�|�	d|�d|���q�W|�	d|j���|j	|�d��d|�d�dd�|��|��t|�}dt|jd�k�r�|j� d�}|�	|�d��|j�!|�d|_"|_#|�o�|j$|_%|�r|�	d�|�&|�|�'|j�|�(|j|�|j)|dd�|�*�|�r�|j$�s`|��|�	d�|��|jj�s~|�	d�n$|�	d�|��|�	d�|�*�|�*d|j$��x|j�+�D�]\}}	|�	|�d|��d|�d�|	d�|��|��t|�}d|_,t|	jd �}d|k�r@|j� d�}|�	|�d��d!|k�rr|j� d!�}|�	|�d"|�d#|�d$��|j�!|	�||_-|�	d%�|�&|�|�'|	j�|�(|	j|�|j)|dd�|�*��q�Wd�
d&d'�|jD��}|j	d(|�d)�dd�d*�
d+d'�|j.D��}|�	d,|���dS)-Nzno root frame allowedr	)�exported�async_exportedz%from __future__ import generator_stopzfrom jinja2.runtime import z, r�z, environment=environmentzblock z defined twice�.zfrom z import z as zimport zname = �rootz(context, missing=missingz):)r�r$)r$z = TemplateReference(context)Tzparent_template = None)r�zif parent_template is not None:z4yield from parent_template.root_render_func(context)z=async for event in parent_template.root_render_func(context):zyield eventZblock_)r$�superrz = context.super(z, block_r8z_block_vars = {}css|]}|�d|��VqdS)z: block_Nr-)rPr�r-r-r.rR�sz/CodeGenerator.visit_Template.<locals>.<genexpr>z
blocks = {r��&css |]\}}|�d|��VqdS)r�Nr-)rPrSrQr-r-r.rR�sz
debug_info = )/�AssertionErrorrr9rCZruntimerrr�r�r�r�rF�findr
�Extends�find_allr�r�r�r��ImportedName�
importnamer�r��rsplitr�r�r�r#rhr�rvr�r�rzr{r�rwr�r�r�r�r�rcr}ryr�)r$r%r&r)rrZexported_namesZenvenvZhave_extendsry�import_�imp�alias�module�objr�rCr}rgZ
blocks_kv_strZdebug_kv_strr-r-r.�visit_Template9s�










zCodeGenerator.visit_TemplatecCsd}|jr8|jrdS|jdkr8|�d�|��|d7}|jrJ|�|�}n|��}|jr�|�d|j	�d�|�|��|�d|j	�d�|�|�
�|jjs�|j
dkr�|�d	|j	�d
|�d�|�n@|�|���d|j	�d
|�d
�|�|��|�d|�|�
�|�
|�dS)z.Call a block and register it for the template.rNzif 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](r8zfor event in context.blocks[z):�event)rzr�r�r�r��scopedrr�requiredrCr�r9r�rxr�r�)r$r%r&rur�r-r-r.r��s8

zCodeGenerator.visit_BlockcCs�|js|�d|j�|jdkrV|js6|�d�|��|�d�|jrNt��n|��|�d|�|�	|j
|�|�d|j�d��|�d�|��|�d	�|��|j
r�d
|_|jd7_dS)
zCalls the extender.z,cannot use extend from a non top-level scoperzif parent_template is not None:z5raise TemplateRuntimeError("extended multiple times")z+parent_template = environment.get_template(z, r8z9for name, parent_block in parent_template.blocks.items():z8context.blocks.setdefault(name, []).append(parent_block)Tr	N)rzr�r�r�r�r�r�r�r�r+�templater;rCr{)r$r%r&r-r-r.�
visit_Extends�s(




zCodeGenerator.visit_ExtendscCsp|jr|�d�|��d}t|jtj�rVt|jjt�r>d}qnt|jjt	t
f�rnd}nt|jtjtjf�rnd}|�d|�d�|�|�
|j|�|�d|j�d��|jr�|��|�d	�|��|�d
�|��|�d�|��d}|j�r|�|���d
|�|��d��n$|jj�r,|�d�n|�d�d}|�s\|��|�d|�|��|j�rl|��dS)zHandles includes.ztry:Zget_or_select_templateZget_templateZselect_templateztemplate = environment.r6z, r8zexcept TemplateNotFound:r�zelse:FzUfor 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_streamTr#N)Zignore_missingr�r�rHr&r
�ConstrNr\r]r^�Tuple�Listr+r;rCr��with_contextr�r�r9r�r�)r$r%r&�	func_nameZskip_event_yieldr-r-r.�
visit_IncludesJ





zCodeGenerator.visit_IncludecCs�|�|�d��d��|�|j|�|�d|j�d��|jrld|�d���}|�|�d|�|��d��n|�d	|�d��d
��dS)Nzawait zenvironment.get_template(z, z).Zmake_moduleZ_asyncz(context.get_all(), True, r8Z_get_default_modulez	(context))r;r�r+r&rCr+r�)r$r%r&�f_namer-r-r.�_import_common9szCodeGenerator._import_commoncCsl|�|j�|j��d�|�|jr6|�d|j�d��|�||�|jrh|j�d�sh|�d|j�d��dS)zVisit regular imports.z = z
context.vars[z] = rzcontext.exported_vars.discard(r8N)r�rvr�r�rzr;r/�
startswith)r$r%r&r-r-r.�visit_ImportHszCodeGenerator.visit_Importc
	s�|�|�|�d�|�|��g}g}x�|jD]�}t|t�rH|\}}n|}|��j�|��d|�d��|�d�j�|��d��|�	�d|�
|��d|��}|��j�|��d|�d	|�d
��|���jr0|�
|�|�d�s0|�
|�q0W|�r\t|�dk�r2|d
}|�d|�d�j�|����n*d��fdd�|D��}|�d|�d��|�r�t|�dk�r�|�d|d
�d
��n"d�tt|��}	|�d|	�d��dS)zVisit named imports.zincluded_template = z = getattr(included_template, z
, missing)zif z is missing:z9the template {included_template.__name__!r} (imported on z%) does not export the requested name z = undefined(fz, name=r8rr	rz
context.vars[z] = z, c3s$|]}|�d�j�|���VqdS)z: N)rvr�)rPrC)r&r-r.rRysz1CodeGenerator.visit_FromImport.<locals>.<genexpr>zcontext.vars.update({z})zcontext.exported_vars.discard(z)context.exported_vars.difference_update((z))N)r�r;r/rdrHr]r�rvr�r�r�r�rzr�r0r�r�rr�)
r$r%r&Z	var_namesZdiscarded_namesrCr�messageZnames_kvrr-)r&r.�visit_FromImportSsD



 

 zCodeGenerator.visit_FromImportcCs�|��}d|_|��}|��}|jpRdt|jdd�d�kpRtdd�|�tj�D��}d}|rh|j	�
d�}|j	j|dd	�|jr�|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�|j�r�|�|�d��d�|�|��|�|�|j|_|�r�|�|�d��x<|�tj�D],}	|	jdk�r�|	jdk�r�|�d|	j��q�W|j�r4|��}
|�|
�d��|�|�d
d�|�|�|j|�|�r||�d|�d|�d��d��n
|�d�|j
�r�|�|�d��|j�r�|�d �nB|jj �r�|�s�|�d!�|�|j!|�|jj �r�|�s�|�d"�|j
�r|�d"�|j�r|�d#�n|�|�r(d$nd�|��|�|�|�d%�|�"|j#|�|j�rp|�|
�d&��|��|j||j�o�|jd�|j�r�|�d|
�d��|��|�|�|�"|j|�|�|�|��|j�rd|�$|�|��|�%||�|�|�d'��d(��|jj �r.|�d!�|�|j!|�|jj �rP|�d"�|�d)�|�&|�|j'�r�|j'd*�(|j	j)�dS)+NT�loop)r�)�only)r4css|]}|jVqdS)N)r$)rPryr-r-r.rR�sz*CodeGenerator.visit_For.<locals>.<genexpr>r�)Z
for_branch�else�testz(fiter):z
async for zfor z in zauto_aiter(fiter)Zfiter�:zif zyield �)r�z%(reciter, loop_render_func, depth=0):z
 = missing�storez8Can't assign to special loop variable in for-loop targetz = 1z, ZAsynczLoopContext(r6Zreciterzauto_aiter(r8z&, undefined, loop_render_func, depth):z
, undefined):z_loop_vars = {}z = 0zawait zloop(z, loop)r�)*r�r|�	recursiverh�iter_child_nodesr�rr
r�rvr�r��else_r7r�r�r�r�r�r�r+r�r;r�r�rxr�r�rCr�r�r9r�rr�r�r�r�r�r��difference_updateZstores)r$r%r&r|Z
test_frameZ
else_frameZ
extended_loopZloop_refZloop_filter_funcrCZiteration_indicatorr-r-r.�	visit_For�s�






 














zCodeGenerator.visit_ForcCs�|��}|�d|�|�|j|�|�d�|��|�|j|�|��xP|j	D]F}|�d|�|�|j|�|�d�|��|�|j|�|��qRW|j
r�|�d�|��|�|j
|�|��dS)Nzif r8zelif zelse:)r�r�r+r7r;r�r�r�r��elif_r=)r$r%r&Zif_framer@r-r-r.�visit_Ifs&


zCodeGenerator.visit_IfcCs||�||�\}}|��|jrR|j�d�s>|�d|j�d��|�d|j�d��|�|j�|j��d��|�	||�dS)Nrzcontext.exported_vars.add(r8z
context.vars[z] = z = )
r�r�rzrCr0r;r�rvr�r�)r$r%r&Zmacro_framer�r-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_framer�r-r-r.�visit_CallBlock/s
zCodeGenerator.visit_CallBlockcCsh|��}|j�|�|�|�|�|�|�|j|�|�||�|�|j	|�|�
|�|�|�dS)N)r�rvr�r�rxr�r�r�r��filterr�r�)r$r%r&Zfilter_framer-r-r.�visit_FilterBlock7s


zCodeGenerator.visit_FilterBlockcCs�|��}|j�|�|�|�xDt|j|j�D]2\}}|��|�||�|�	d�|�||�q.W|�
|j|�|�|�dS)Nz = )
r�rvr�r��zip�targets�valuesr�r+r;r�r�r�)r$r%r&Z
with_framer��exprr-r-r.�
visit_WithBs

zCodeGenerator.visit_WithcCs|�|�|�|j|�dS)N)r�r+r%)r$r%r&r-r-r.�visit_ExprStmtNs
zCodeGenerator.visit_ExprStmtc@s4eZdZUejejdefed<ejeed<dS)zCodeGenerator._FinalizeInfo.�const�srcN)rnrorpr1r��Callabler\�__annotations__r-r-r-r.�
_FinalizeInfoRs
rS)rNr!cCst|�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.
        )r\)rNr-r-r.�_default_finalizeVszCodeGenerator._default_finalize�	_finalizecs��jdk	r�jS�j}�d}�jjr�d}�jj�tjdtjdtjdi�t����}d}|dkr|t	j
t	j
d���fdd�}n2|�|�d	�}|dkr�t	j
t	j
d����fd
d�}��||��_�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�zcontext.eval_ctxr9)rNr!cs��|��S)Nr-)rN)r��env_finalizer-r.�finalize�sz.CodeGenerator._make_finalize.<locals>.finalizez, cs���j|��S)N)r9)rN)r�rVr$r-r.rW�s)rUrTr9rWrr��eval_context�get�from_objr1r2rS)r$rWrP�pass_argr-)r�rVr$r.�_make_finalize`s&


zCodeGenerator._make_finalize)�groupr!cCs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�sz CodeGenerator._output_const_repr)r%r&rWr!cCs:|�|j�}|jjrt|�}t|tj�r0t|�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�rrHr
�TemplateDatar\rO)r$r%r&rWrOr-r-r.�_output_child_to_const�s
z$CodeGenerator._output_child_to_constcCsL|jjr|�d�n|jjr(|�d�n
|�d�|jdk	rH|�|j�dS)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�rP)r$r%r&rWr-r-r.�_output_child_pre�s

zCodeGenerator._output_child_precCs"|�d�|jdk	r|�d�dS)zWOutput extra source code after visiting a child of an
        ``Output`` node.
        r8N)r;rP)r$r%r&rWr-r-r.�_output_child_post�s

z CodeGenerator._output_child_postc	
Cs�|jr"|jrdS|�d�|��|��}g}x�|jD]�}y,|jsVt|tj�sVt�	��|�
|||�}Wn&tj	tfk
r�|�|�w6YnX|r�t|dt
�r�|d�|�q6|�|g�q6W|jdk	�rt|�dkr�|�|j�d��n|�|j�d��|��x�|D]�}t|t
��rR|�|�}|jdk�rB|�d|�n|�|d�nb|jdk�rl|�d|�n
|�|�|�|||�|�||�|�|||�|jdk	�r|�d��qW|jdk	�r�|��|�t|�dk�r�dnd	�|j�r�|��dS)
Nzif parent_template is None:r�r	z.append(z	.extend((zyield r�r8z)))rwr�r�r�r\r
rOrHr`�
Impossiblera�	Exceptionr�r^rxr�r^r�rbr+rcr;r�)	r$r%r&rWr��childrO�item�valr-r-r.�visit_Output�sV




zCodeGenerator.visit_OutputcCsF|��|�|�|�|j|�|�d�|�|j|�|�|�dS)Nz = )rr�r+r�r;r%r)r$r%r&r-r-r.�visit_Assigns

zCodeGenerator.visit_AssigncCs�|��|��}d|_|j�|�|�|�|�|�|�|j|�|�	|�|�
|j|�|�d�|j
dk	r�|�|j
|�n|�d|j�d��|�d�|�|�|�|�dS)NFz9 = (Markup if context.eval_ctx.autoescape else identity)(zconcat(r8)rr�rwrvr�r�rxr�r�r�r+r�r;rGr�rr�)r$r%r&r}r-r-r.�visit_AssignBlocks 






zCodeGenerator.visit_AssignBlockc	Cs�|jdkr4|js|js|jr4|jr4|jd�|j�|j�|j�}|jdkr�|j�	|�}|dk	rv|dt
krv|�|�r�|�d|j�d|�d|�d��dS|�|�dS)	Nr:r�r�rz(undefined(name=z) if z is missing else r8)
r�rzr|r}r�r�rCrvr�Z	find_loadrrr;)r$r%r&r�r�r-r-r.r�6s


zCodeGenerator.visit_NamecCsV|j�|j�}|�d|�d��|��|�d�|��|�|�d|j�d��dS)Nzif not isinstance(z
, Namespace):zMraise TemplateRuntimeError("cannot assign attribute on non-namespace object")r�r�)rvr�rCr�r�r��attr)r$r%r&r�r-r-r.�visit_NSRefOszCodeGenerator.visit_NSRefcCs8|�|j�}t|t�r&|�t|��n|�t|��dS)N)r_r)rHrYr;r\r�)r$r%r&rhr-r-r.�visit_Const]s
zCodeGenerator.visit_ConstcCsJy|�t|�|j���Wn*tjk
rD|�d|j�d��YnXdS)Nz6(Markup if context.eval_ctx.autoescape else identity)(r8)r;r�r_r)r
rd�data)r$r%r&r-r-r.�visit_TemplateDatads
z CodeGenerator.visit_TemplateDatacCsZ|�d�d}x0t|j�D]"\}}|r0|�d�|�||�qW|�|dkrPdnd�dS)Nr6r�z, rz,)r8)r;r�rcr+)r$r%r&r�rgr-r-r.�visit_Tuplels

zCodeGenerator.visit_TuplecCsJ|�d�x0t|j�D]"\}}|r,|�d�|�||�qW|�d�dS)Nr�z, r�)r;r�rcr+)r$r%r&r�rgr-r-r.�
visit_Listus

zCodeGenerator.visit_ListcCsd|�d�xJt|j�D]<\}}|r,|�d�|�|j|�|�d�|�|j|�qW|�d�dS)Nr�z, z: r�)r;r�rcr+r�rN)r$r%r&r�rgr-r-r.�
visit_Dict}s


zCodeGenerator.visit_Dict�+�-�*�/z//z**�%�and�orznot cCsd|jjrd}n|jjrd}nd}|�|�d��x$|jD]}|�||�|�d�q8W|�d�dS)Nz8(markup_join if context.eval_ctx.volatile else str_join)Zmarkup_joinZstr_joinz((z, z)))r)r*r�r;r
r+)r$r%r&r,r�r-r-r.�visit_Concat�szCodeGenerator.visit_ConcatcCsB|�d�|�|j|�x|jD]}|�||�q W|�d�dS)Nr6r8)r;r+rLZops)r$r%r&r5r-r-r.�
visit_Compare�s

zCodeGenerator.visit_ComparecCs*|�dt|j�d��|�|j|�dS)Nr7)r;�	operatorsr5r+rL)r$r%r&r-r-r.�
visit_Operand�szCodeGenerator.visit_OperandcCsT|jjr|�d�|�d�|�|j|�|�d|j�d��|jjrP|�d�dS)Nz(await auto_await(zenvironment.getattr(z, r8z)))r9r�r;r+r%rl)r$r%r&r-r-r.�
visit_Getattr�s

zCodeGenerator.visit_GetattrcCs�t|jtj�r@|�|j|�|�d�|�|j|�|�d�n^|jjrR|�d�|�d�|�|j|�|�d�|�|j|�|�d�|jjr�|�d�dS)Nr�r�z(await auto_await(zenvironment.getitem(z, r8z)))	rHr�r
�Slicer+r%r;r9r�)r$r%r&r-r-r.�
visit_Getitem�s




zCodeGenerator.visit_GetitemcCs`|jdk	r|�|j|�|�d�|jdk	r:|�|j|�|jdk	r\|�d�|�|j|�dS)Nr8)�startr+r;�stopr�)r$r%r&r-r-r.�visit_Slice�s




zCodeGenerator.visit_Slice)r%r&�	is_filterr!ccs|jjr|�d�|r@|�|j|j�d��|jj�|j�}n(|�|j|j�d��|jj�|j�}|dkr�|js�|r~dnd}|�d|�d|j�d�|j	�t
jdt
jd	t
jd
i�t
�
|��}|dk	r�|�|�d��dV|�||�|�d�|jj�r
|�d�dS)
Nzawait auto_await(r6rGr7zNo z named rr�zcontext.eval_ctxr9z, r8)r9r�r;r�rCrYr�r~r�r�rr�rXrZr�)r$r%r&r�r�Z	type_namer[r-r-r.�_filter_test_common�s*



z!CodeGenerator._filter_test_commonc	Cs�|�||d��x|jdk	r*|�|j|�nX|jjrP|�d|j�d|j�d��n2|jjrn|�d|j�d��n|�d|j�d��WdQRXdS)NTz(Markup(concat(z.)) if context.eval_ctx.autoescape else concat(z))zMarkup(concat(zconcat(r8)r�r%r+r)r*r;rxr�)r$r%r&r-r-r.r�s
zCodeGenerator.visit_Filterc	Cs,|�||d��|�|j|�WdQRXdS)NF)r�r+r%)r$r%r&r-r-r.r�szCodeGenerator.visit_Testcsl����dd����fdd�}��d����j����d����j����d�|���d�dS)N)r!cs8�jdk	r���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_expr2s

z1CodeGenerator.visit_CondExpr.<locals>.write_expr2r6z if z else r8)r�r;r+Zexpr1r7)r$r%r&r�r-)r&r%r$r.�visit_CondExprs


zCodeGenerator.visit_CondExpr)r%r&rCr!cCs�|jjr|�d�|jjr&|�d�n
|�d�|�|j|�|rJddind}|jr\ddini}|jrnddini}|r�|j|f|�n|s�|r�t	|f|�}|�
|||�|�d�|jjr�|�d�dS)Nzawait auto_await(zenvironment.call(context, z
context.call(r�Z
_loop_varsZ_block_varsr8)r9r�r;r:r+r%r|r}r�rbr�)r$r%r&rCr�Zloop_kwargsZblock_kwargsr-r-r.rD0s"


zCodeGenerator.visit_CallcCs"|�|jd�|�|j|�dS)Nr�)r;r�r+rN)r$r%r&r-r-r.�
visit_KeywordGszCodeGenerator.visit_KeywordcCs&|�d�|�|j|�|�d�dS)NzMarkup(r8)r;r+rL)r$r%r&r-r-r.�visit_MarkSafeMs
zCodeGenerator.visit_MarkSafecCs&|�d�|�|j|�|�d�dS)Nz6(Markup if context.eval_ctx.autoescape else identity)(r8)r;r+rL)r$r%r&r-r-r.�visit_MarkSafeIfAutoescapeRs
z(CodeGenerator.visit_MarkSafeIfAutoescapecCs|�d|j�dS)Nzenvironment.)r;rC)r$r%r&r-r-r.�visit_EnvironmentAttributeYsz(CodeGenerator.visit_EnvironmentAttributecCs|�d|j�d|j���dS)Nzenvironment.extensions[z].)r;�
identifierrC)r$r%r&r-r-r.�visit_ExtensionAttribute^sz&CodeGenerator.visit_ExtensionAttributecCs|�|j|j�dS)N)r;r�r)r$r%r&r-r-r.�visit_ImportedNamecsz CodeGenerator.visit_ImportedNamecCs|�|j�dS)N)r;rC)r$r%r&r-r-r.�visit_InternalNamefsz CodeGenerator.visit_InternalNamecCs|�d�dS)Nr�)r;)r$r%r&r-r-r.�visit_ContextReferenceisz$CodeGenerator.visit_ContextReferencecCs|�|�|��dS)N)r;r)r$r%r&r-r-r.�visit_DerivedContextReferencensz+CodeGenerator.visit_DerivedContextReferencecCs|�d|�dS)N�continue)r�)r$r%r&r-r-r.�visit_ContinuesszCodeGenerator.visit_ContinuecCs|�d|�dS)N�break)r�)r$r%r&r-r-r.�visit_BreakvszCodeGenerator.visit_BreakcCs:|��}|j�|�|�|�|�|j|�|�|�dS)N)r�rvr�r�r�r�r�)r$r%r&�scope_framer-r-r.�visit_Scopeys

zCodeGenerator.visit_ScopecCs�|��}|�|�d|�|����|�|�d��|�|j|�|�|�|jdd�}|j�|�|�	|�|�
|j|�|�|�|�
�dS)Nz = z.vars = T)r�)r�r�rr+r�rr�rvr�r�r�r�r�r)r$r%r&r�r�r-r-r.�visit_OverlayScope�s


z CodeGenerator.visit_OverlayScopec	Csxxr|jD]h}|�d|j�d��|�|j|�y|j�|j�}Wntjk
r^d|j_	YqXt
|j|j|�qWdS)Nzcontext.eval_ctx.z = T)�optionsr�r�r+rNr_r)r
rdr*�setattr)r$r%r&�keywordrhr-r-r.�visit_EvalContextModifier�sz'CodeGenerator.visit_EvalContextModifiercCsl|��}|j��}|�|�d��|�||�x|jD]}|�||�q6W|j�|�|�d|�d��dS)Nz = context.eval_ctx.save()zcontext.eval_ctx.revert(r8)r�r)Zsaver�r�r�r+Zrevert)r$r%r&Zold_ctx_nameZ	saved_ctxrfr-r-r.�visit_ScopedEvalContextModifier�s
z-CodeGenerator.visit_ScopedEvalContextModifier)NFT)F)r	)N)N)Nr)Nr)N)F)r�r�)N)F)�rnrorpr1r�r\�TextIOrWrm�propertyrGrXr�r�r#rxr�r�r�r
�Noder�r�r�r�r�r;r�r�rq�Callr�r��Mappingr2r�r�r�r�r�r�rrrsr)rir�r�r�r�r�r�r�r�rrrr�rrrrrIr"r�r�rr'�Includer-�ImportZ
FromImportr/r1r3�Forr?�IfrArBrFZFilterBlockrH�WithrMZExprStmtrN�
NamedTuplerS�staticmethodrTrUrRr\r^r0rarbrcZOutputri�AssignrjZAssignBlockrkr�r�ZNSRefrmr(rnr`rprqr*rr�Dictrsr@Z	visit_AddZ	visit_SubZ	visit_MulZ	visit_DivZvisit_FloorDivZ	visit_PowZ	visit_ModZ	visit_AndZvisit_OrrBZ	visit_PosZ	visit_NegZ	visit_Notr4ZConcatr{�Comparer|ZOperandr~ZGetattrrZGetitemr�r�r�r�Iteratorr�r�r�ZCondExprr�rD�Keywordr�ZMarkSafer�ZMarkSafeIfAutoescaper�ZEnvironmentAttributer�ZExtensionAttributer�rr�ZInternalNamer�ZContextReferencer�ZDerivedContextReferencer��Continuer��Breakr�ZScoper�ZOverlayScoper�ZEvalContextModifierr�ZScopedEvalContextModifierr�r-r-r-r.r",s
"A,4+Q	.u++4
2
0	O	


'
)NFT)Fr��typingr1�
contextlibr�	functoolsr�ior�	itertoolsrr�rr�Z
markupsaferrr�r
�
exceptionsrZ
idtrackingrr
rrrrr(r�utilsrrr>r�
TYPE_CHECKINGZtyping_extensions�ter9r�TypeVarrQr2rr}r4r\r?r@rArBrIr�r�rWrMrOr�r��Setrhrir#�RuntimeErrorrfr�rerer�r"r-r-r-r.�<module>sd" &
S

Hacked By AnonymousFox1.0, Coded By AnonymousFox