%PDF- %PDF-
Mini Shell

Mini Shell

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

B

��RY��	@srdZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZmZmZdd
lmZmZmZmZmZmZmZddd
dddddd�Zeed�r�dZndZdd�Z e!e"e �dd��Z d1dd�Z#dd�Z$dd �Z%Gd!d"�d"e&�Z'Gd#d$�d$e&�Z(Gd%d&�d&e)�Z*Gd'd(�d(e
�Z+Gd)d*�d*e
�Z,Gd+d,�d,e
�Z-Gd-d.�d.e.�Z/Gd/d0�d0e
�Z0dS)2z�
    jinja2.compiler
    ~~~~~~~~~~~~~~~

    Compiles nodes into python code.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
�)�chain)�deepcopy)�	iskeyword)�nodes)�EvalContext)�NodeVisitor)�TemplateAssertionError)�Markup�concat�escape)�
range_type�next�	text_type�string_types�	iteritems�NativeStringIO�imapz==z!=�>z>=�<z<=�inznot in)�eq�ne�gtZgteq�ltZlteqrZnotinr�itemscsd��fdd�}|S)N�*csdS)N�r)�xr�@/opt/alt/python37/lib/python3.7/site-packages/jinja2/compiler.py�f-sz&unoptimize_before_dead_code.<locals>.fr)rr)rr�unoptimize_before_dead_code+sr �__closure__NFcCsDt|tj�std��t|||||�}|�|�|dkr@|j��SdS)z+Generate the python source for a node tree.z Can't compile non template nodesN)�
isinstancerZTemplate�	TypeError�
CodeGenerator�visit�stream�getvalue)�node�environment�name�filenamer&�
defer_init�	generatorrrr�generate7s
r.cCs�|dks|tks|tkrdSt|ttttttft	�r:dSt|t
ttt
f�rjx|D]}t|�sRdSqRWdSt|t�r�x,t|�D] \}}t|�s�dSt|�s~dSq~WdSdS)z)Does the node have a safe representation?NTF)�NotImplemented�Ellipsisr"�bool�int�float�complexrr	r�tuple�list�set�	frozenset�
has_safe_repr�dictr)�value�item�keyrrrr9Bs$

r9cCs@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�names�visitorr(rrr�find_undeclaredXs
rCc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Identifiersz+Tracks the status of identifiers in frames.cCs,t�|_t�|_t�|_t�|_t�|_dS)N)r7�declared�outer_undeclaredr@�declared_locally�declared_parameter)�selfrrr�__init__hs
zIdentifiers.__init__cCs|j�|�|j�|�dS)z$Register a special name like `loop`.N)r@�discardrE�add)rIr*rrr�add_special{szIdentifiers.add_specialcCs"||jks||jkrdS||jkS)z6Check if a name is declared in this or an outer scope.T)rGrHrE)rIr*rrr�is_declared�szIdentifiers.is_declaredcCst|�S)N)r)rIrrr�copy�szIdentifiers.copyN)�__name__�
__module__�__qualname__�__doc__rJrMrNrOrrrrrDes
rDc@sHeZdZdZddd�Zdd�Zdd�Zdd
d�Zdd
�Zdd�Z	eZ
dS)�Framez&Holds compile time information for us.NcCs�||_t�|_d|_d|_|o"|j|_d|_|r6|jp8d|_t�|_	||_
|dk	r�|jj�|jj|jj
B|j	B�|jj�|jj|jj�|j|_dS)NF)�eval_ctxrD�identifiers�toplevel�	rootlevel�require_output_check�buffer�blockr7�assigned_names�parentrE�updaterHrFr@)rIrUr]rrrrJ�s"
zFrame.__init__cCs@t�|j�}|j�|j�t�|jj�|_|jj�|jj�|S)z!Create a copy of the current one.)�object�__new__�	__class__�__dict__r^rV)rI�rvrrrrO�s
z
Frame.copycCs&t|j�}x|D]}|�|�qWdS)z�Walk the node and check for identifiers.  If the scope is hard (eg:
        enforce on a python level) overrides from outer scopes are tracked
        differently.
        N)�FrameIdentifierVisitorrVr%)rIrrBr(rrr�inspect�s

z
Frame.inspectrcs4|j��j�jB�j�jB@t�fdd�|D��BS)z�Find all the shadowed names.  extra is an iterable of variables
        that may be defined with `add_special` which may occour scoped.
        c3s|]}��|�r|VqdS)N)rN)�.0r)�irr�	<genexpr>�sz&Frame.find_shadowed.<locals>.<genexpr>)rVrErFrGrHr7)rI�extrar)rgr�
find_shadowed�s
zFrame.find_shadowedcCst|j|�S)zReturn an inner frame.)rTrU)rIrrr�inner�szFrame.innercCs|��}d|_|S)z�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.
        F)rOrX)rIrcrrr�soft�sz
Frame.soft)N)r)rPrQrRrSrJrOrerjrkrl�__copy__rrrrrT�s
+	
		rTc@seZdZdZdS)r?z?Exception used by the `UndeclaredNameVisitor` to signal a stop.N)rPrQrRrSrrrrr?�sr?c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�DependencyFinderVisitorz.A visitor that collects filter and test calls.cCst�|_t�|_dS)N)r7�filters�tests)rIrrrrJ�sz DependencyFinderVisitor.__init__cCs|�|�|j�|j�dS)N)�
generic_visitrorLr*)rIr(rrr�visit_Filter�s
z$DependencyFinderVisitor.visit_FiltercCs|�|�|j�|j�dS)N)rqrprLr*)rIr(rrr�
visit_Test�s
z"DependencyFinderVisitor.visit_TestcCsdS)zStop visiting at blocks.Nr)rIr(rrr�visit_Block�sz#DependencyFinderVisitor.visit_BlockN)rPrQrRrSrJrrrsrtrrrrrn�s
rnc@s(eZdZdZdd�Zdd�Zdd�ZdS)	r>z�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)r7rAr@)rIrArrrrJ�s
zUndeclaredNameVisitor.__init__cCsJ|jdkr8|j|jkr8|j�|j�|j|jkrFt��n|j�|j�dS)N�load)�ctxr*rAr@rLr?rK)rIr(rrr�
visit_Names
z UndeclaredNameVisitor.visit_NamecCsdS)zStop visiting a blocks.Nr)rIr(rrrrtsz!UndeclaredNameVisitor.visit_BlockN)rPrQrRrSrJrwrtrrrrr>�sr>c@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)rdzA visitor for `Frame.inspect`.cCs
||_dS)N)rV)rIrVrrrrJszFrameIdentifierVisitor.__init__cCsd|jdkr|jj�|j�nD|jdkr8|jj�|j�n(|jdkr`|j�|j�s`|jj�|j�dS)z2All assignments to names go through this function.�storeZparamruN)rvrVrGrLr*rHrNr@)rIr(rrrrws


z!FrameIdentifierVisitor.visit_Namecsr��|j��j��j�jB����fdd�}||j�}||jpBd�}�j�|�	|��j
��j�||B�dS)NcsR|s
t�S����_x|D]}��|�qW�jj�}�j��jj���_|S)N)r7rOrVr%rGr@r^)rZsubnoderc)�	old_names�real_identifiersrIrr�inner_visit&s

z4FrameIdentifierVisitor.visit_If.<locals>.inner_visitr)r%�testrVrGrH�body�else_r@r^�symmetric_differencerE)rIr(r{r}r~r)ryrzrIr�visit_Ifs

zFrameIdentifierVisitor.visit_IfcCs|jj�|j�dS)N)rVrGrLr*)rIr(rrr�visit_Macro>sz"FrameIdentifierVisitor.visit_MacrocCs|�|�|jj�|j�dS)N)rqrVrGrL�target)rIr(rrr�visit_ImportAs
z#FrameIdentifierVisitor.visit_ImportcCsJ|�|�x:|jD]0}t|t�r4|jj�|d�q|jj�|�qWdS)N�)rqrAr"r5rVrGrL)rIr(r*rrr�visit_FromImportEs


z'FrameIdentifierVisitor.visit_FromImportcCs|�|j�|�|j�dS)z'Visit assignments in the correct order.N)r%r(r�)rIr(rrr�visit_AssignMsz#FrameIdentifierVisitor.visit_AssigncCs|�|j�dS)zqVisiting stops at for blocks.  However the block sequence
        is visited as part of the outer scope.
        N)r%�iter)rIr(rrr�	visit_ForRsz FrameIdentifierVisitor.visit_ForcCs|�|j�dS)N)r%�call)rIr(rrr�visit_CallBlockXsz&FrameIdentifierVisitor.visit_CallBlockcCs|�|j�dS)N)r%�filter)rIr(rrr�visit_FilterBlock[sz(FrameIdentifierVisitor.visit_FilterBlockcCsdS)zStop visiting at scopes.Nr)rIr(rrr�visit_Scope^sz"FrameIdentifierVisitor.visit_ScopecCsdS)zStop visiting at blocks.Nr)rIr(rrrrtasz"FrameIdentifierVisitor.visit_BlockN)rPrQrRrSrJrwr�r�r�r�r�r�r�r�r�rtrrrrrds
rdc@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)rPrQrRrSrrrrr�esr�c@s�eZdZd�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zd�dd�Z	d�dd�Z
dd�Zd�dd�Zdd�Z
dd�Zd�dd�Zd�dd �Zd�d!d"�Zd#d$�Zd%d&�Zd'd(�Zd�d*d+�Zd,d-�Zd�d/d0�Zd�d1d2�Zd3d4�Zd5d6�Zd�d7d8�Zd9d:�Zd;d<�Zd=d>�Zd?d@�ZdAdB�Z dCdD�Z!dEdF�Z"dGdH�Z#dIdJ�Z$dKdL�Z%dMdN�Z&dOdP�Z'dQdR�Z(dSdT�Z)dUdV�Z*dWdX�Z+dYdZ�Z,d[d\�Z-d]d^�Z.d�d_d`�Z/d�dadb�Z0e/dc�Z1e/dd�Z2e/de�Z3e/df�Z4e/dg�Z5e/dh�Z6e/di�Z7e/djddk�Z8e/dlddk�Z9e0dc�Z:e0dd�Z;e0dmddk�Z<[/[0dndo�Z=dpdq�Z>drds�Z?dtdu�Z@dvdw�ZAdxdy�ZBdzd{�ZCd|d}�ZDd~d�ZEd�d�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSdS)�r$NFcCs�|dkrt�}||_||_||_||_d|_||_i|_i|_d|_	d|_
d|_i|_i|_
g|_d|_d|_d|_d|_d|_d|_dS)NFrr�T)rr)r*r+r&Zcreated_block_contextr,�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)rIr)r*r+r&r,rrrrJns,zCodeGenerator.__init__cCst|||j|j��dS)z*Fail with a :exc:`TemplateAssertionError`.N)rr*r+)rI�msg�linenorrr�fail�szCodeGenerator.failcCs|jd7_d|jS)zGet a new unique identifier.r�zt_%d)r�)rIrrr�temporary_identifier�sz"CodeGenerator.temporary_identifiercCs|��|_|�d|j�dS)z7Enable buffering for the frame from that point onwards.z%s = []N)r�rZ�	writeline)rI�framerrrrZ�s
zCodeGenerator.buffercCs�|jjr^|�d�|��|�d|j�|��|�d�|��|�d|j�|��n*|jjrx|�d|j�n|�d|j�dS)z(Return the buffer contents of the frame.zif context.eval_ctx.autoescape:zreturn Markup(concat(%s))zelse:zreturn concat(%s)N)rU�volatiler��indentrZ�outdent�
autoescape)rIr�rrr�return_buffer_contents�s


z$CodeGenerator.return_buffer_contentscCs|jd7_dS)zIndent by one.r�N)r�)rIrrrr��szCodeGenerator.indentr�cCs|j|8_dS)zOutdent by step.N)r�)rI�steprrrr��szCodeGenerator.outdentcCs.|jdkr|�d|�n|�d|j|�dS)z%Yield or write into the frame buffer.Nzyield z
%s.append()rZr�)rIr�r(rrr�start_write�s
zCodeGenerator.start_writecCs|jdk	r|�d�dS)z1End the writing process started by `start_write`.N�))rZ�write)rIr�rrr�	end_write�s
zCodeGenerator.end_writecCs$|�||�|�|�|�|�dS)z4Simple shortcut for start_write + write + end_write.N)r�r�r�)rI�sr�r(rrr�simple_write�s
zCodeGenerator.simple_writecCsX|jdkr|�d�n
|�d�yx|D]}|�||�q(WWntk
rRYnXdS)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
        unless the force_generator parameter is set to False.
        Nzif 0: yield None�pass)rZr�r%r�)rIrr�r(rrr�
blockvisit�s


zCodeGenerator.blockvisitcCs�|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�r&r�r�r�r��appendr�)rIrrrrr��s


zCodeGenerator.writercCs|�||�|�|�dS)z!Combination of newline and write.N)�newliner�)rIrr(rirrrr��szCodeGenerator.writelinecCs: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�)rIr(rirrrr�szCodeGenerator.newlinec	Cs�d}x0tdd�|jD�|pd�D]}t|�r d}Pq Wx$|jD]}|�d�|�||�q>W|s�x$|jD]}|�d�|�||�qhW|dk	r�x&t|�D]\}}|�d||f�q�W|jr�|�d	�|�|j|�|�r�|jdk	r�|�d
�n
|�d�x8|jD].}|�d|j	�|�|j
|�|�d��qW|dk	�rhx(t|�D]\}}|�d
||f��qHW|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 occour.  The extra keyword arguments should be given
        as python dict.
        Fcss|]}|jVqdS)N)r=)rfrrrrrhsz*CodeGenerator.signature.<locals>.<genexpr>rTz, Nz, %s=%sz, *z
, **dict({z, **{z%r: z%r: %s, z}, **r��}z, **)r�kwargs�is_python_keyword�argsr�r%rZdyn_argsZ
dyn_kwargsr=r;)	rIr(r��extra_kwargsZkwarg_workaroundZkwarg�argr=r;rrr�	signaturesJ	 







zCodeGenerator.signaturecCs(x"|jjD]}|�d||f�q
WdS)z9Pull all the references identifiers into the local scope.zl_%s = context.resolve(%r)N)rVr@r�)rIr�r*rrr�pull_locals<szCodeGenerator.pull_localscCszt�}x|D]}|�|�qWxVdD]N}t||�}x>t||�D]0}||krV|��||<|�d||||f�q>Wq$WdS)zPull all the dependencies.)rorpz%s = environment.%s[%r]N)rnr%�getattrr�r�)rIrrBr(Z
dependency�mappingr*rrr�pull_dependenciesAs


zCodeGenerator.pull_dependenciescCs:|jjr6|�dtrdpdd�dd�|jjD��f�dS)z+Disable Python optimizations for the frame.z%sdummy(%s)zif 0: �z, css|]}d|VqdS)�l_Nr)rfr*rrrrhWsz1CodeGenerator.unoptimize_scope.<locals>.<genexpr>N)rVrEr�r �join)rIr�rrr�unoptimize_scopeNs
zCodeGenerator.unoptimize_scopercCs�i}x4|�|�D]&}|��||<}|�d||f�qWt�}x&|jjD]}||krJ|�d|�qJW|r�|�d�|�d�|S)a�This function returns all the shadowed variables in a dict
        in the form name: alias and will write the required assignments
        into the current scope.  No indentation takes place.

        This also predefines locally declared variables from the loop
        body because under some circumstances it may be the case that

        `extra_vars` is passed to `Frame.find_shadowed`.
        z	%s = l_%sr�z = z
 = missing)rjr�r�r7rVrGrLr�)rIr�Z
extra_vars�aliasesr*ZidentZ
to_declarerrr�
push_scopeZs
zCodeGenerator.push_scopecCsrx&t|�D]\}}|�d||f�q
Wt�}x&|jjD]}||kr8|�d|�q8W|rn|�d�|�d�dS)z0Restore all aliases and delete unused variables.z	l_%s = %sr�z = z
 = missingN)rr�r7rVrGrLr�)rIr�r�r*�aliasZ	to_deleterrr�	pop_scopepszCodeGenerator.pop_scopeTc	Cs4|dkr|��}t|�}|��}|�|�|jj|jj@|jj|jjB@}|rj|�	dd�
t|��|j�|jj|jj|jj@8_|s�|Sd|_
d|_d|_dd�|jD�|_}t|d�}d|kr�d	|_|j�d�|�d
�d|k�r
d	|_
|j�d�|�d�d
|k�r0d	|_|j�d
�|�d�|S)aMIn Jinja a few statements require the help of anonymous
        functions.  Those are currently macros and call blocks and in
        the future also recursive loops.  As there is currently
        technical limitation that doesn't allow reading and writing a
        variable in a scope where the initial value is coming from an
        outer scope, this function tries to fall back with a common
        error message.  Additionally the frame passed is modified so
        that the argumetns are collected and callers are looked up.

        This will return the modified frame.
        NzXIt's not possible to set and access variables derived from an outer scope! (affects: %s)z, FcSsg|]}d|j�qS)r�)r*)rfrrrr�
<listcomp>�sz2CodeGenerator.function_scoping.<locals>.<listcomp>)�callerr��varargsr�TZl_callerr�Zl_kwargsr�Z	l_varargs)�iter_child_nodesr6rkrerVr@rErGrHr�r��sortedr��accesses_kwargs�accesses_varargs�accesses_callerr��	argumentsrCrMr�)	rIr(r��children�find_specialZ
func_frameZoverridden_closure_varsr�r@rrr�function_scoping~sD







zCodeGenerator.function_scopingcCs�|�|||�}d|_|j}d|jjkr0|dg}|�dd�|�|�|��|�|�|�	|�|�
|j|�|�|�|�
�|S)z/Dump the function def of a macro or call block.F�loopz
l_loop=l_loopzdef macro(%s):z, )r�rYr�rVrEr�r�r�rZr�r�r}r�r�)rIr(r�r�r�rrr�
macro_body�s



zCodeGenerator.macro_bodycCs�d�dd�|jD��}t|dd�}t|j�dkr8|d7}|�d||f�x$|jD]}|�||�|�d�qRW|�d	t|j�t|j	�t|j
�f�dS)
z<Dump the macro definition for the def created by macro_body.z, css|]}t|j�VqdS)N)�reprr*)rfrrrrrh�sz*CodeGenerator.macro_def.<locals>.<genexpr>r*Nr��,z%Macro(environment, macro, %r, (%s), (z), %r, %r, %r))r�r�r��lenr��defaultsr%r1r�r�r�)rIr(r�Z	arg_tupler*r�rrr�	macro_def�szCodeGenerator.macro_defcCs*d|j}|jdk	r&|dt|j�7}|S)z.Return a human readable position for the node.zline %dNz in )r�r*r�)rIr(rcrrr�position�s

zCodeGenerator.positioncCsb|dkstd��t|j|j�}ddlm}|�d�|�dd�|��tsV|�d�|j	rbdpdd	}|�
tj�dk	}x@|�
tj�D]0}|j|jkr�|�d
|j|j�||j|j<q�Wxz|�
tj�D]j}|j|jkr�|j}	|��|j|	<}
d|	k�r|	�dd�\}}|�d
|||
f�q�|�d|	|
f�q�W|�d|j�|jd|dd�t|�}|�|j�d|_|_|�o�|j|_|��|�r�|�d�dt|jd�k�r�|j �!d�|�d�|�"|�|�#|j�|�$|j|�|�%�|�rH|j�s|��|�d�|��|�d�|��|�d�|�%d|j�x�t&|j�D]�\}
}t|�}|�|j�|
|_'|�d|
|f|d�|��t|jd�}d|k�r�|j �!d�|�d�d|k�r�|j �!d�|�d|
|
f�|�"|�|�#|j�|�$|j|�|�%��qTW|jdd�d d!�|jD��dd�|�d"d#�d$d!�|j(D���dS)%Nzno root frame allowedr)�__all__zfrom __future__ import divisionzfrom jinja2.runtime import z, zdummy = lambda *x: Nonez, environment=environmentr�zblock %r defined twice�.r�zfrom %s import %s as %szimport %s as %sz	name = %rzdef root(context%s):)riTzparent_template = NonerI)rIz#l_self = TemplateReference(context)zif parent_template is not None:z7for event in parent_template.root_render_func(context):zyield event�zdef block_%s(context%s):)rI�superr�z%l_super = context.super(%r, block_%s)z
blocks = {%s}css|]}d||fVqdS)z%r: block_%sNr)rfrrrrrhPsz/CodeGenerator.visit_Template.<locals>.<genexpr>zdebug_info = %r�&css|]}d|VqdS)z%s=%sNr)rfrrrrrhUs))�AssertionErrorrr)r*Zjinja2.runtimer�r�r�r r,�findrZExtends�find_allZBlockr�r�r�ZImportedName�
importnamer�r��rsplitrTrer}rWrXr�rYr�rCrVrMr�r�r�r�rr[r�)rIr(r�rUZexportedZenvenvZhave_extendsr[�import_Zimpr��module�objr*Zblock_framer@rrr�visit_Template�s�












zCodeGenerator.visit_TemplatecCs~d}|jr8|jrdS|jdkr8|�d�|��|d7}|jrBdpDd}|�d|j|f|�|��|�d|�|�|�dS)	z.Call a block and register it for the template.r�Nrzif parent_template is None:zcontext.derived(locals())�contextz'for event in context.blocks[%r][0](%s):�event)	rWr�r�r�r�Zscopedr*r�r�)rIr(r��levelr�rrrrtXs

zCodeGenerator.visit_BlockcCs�|js|�d|j�|jdkrZ|js6|�d�|��|�dd�|jrRt��n|��|�d|�|�	|j
|�|�d|j�|�dt
�|��|�d	�|��|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)Tr�N)rWr�r�r�r�r�r�r�r�r%�templater�r*�dict_item_iterrX)rIr(r�rrr�
visit_Extendsks.


zCodeGenerator.visit_ExtendscCs>|jr|�|�|jr(|�d�|��d}t|jtj�rft|jj	t
�rNd}q~t|jj	ttf�r~d}nt|jtj
tjf�r~d}|�d||�|�|j|�|�d|j�|jr�|��|�d�|��|�d�|��|�d	�|��|j�r|�d
�n
|�d�|��|�d|�|��|j�r:|��d
S)zHandles includes.ztry:Zget_or_select_templateZget_templateZselect_templateztemplate = environment.%s(z, %r)zexcept TemplateNotFound:r�zelse:z]for event in template.root_render_func(template.new_context(context.parent, True, locals())):z*for event in template.module._body_stream:r�N)�with_contextr�Zignore_missingr�r�r"r�rZConstr;rr5r6ZTupleZListr%r�r*r�r�)rIr(r��	func_namerrr�
visit_Include�s@





zCodeGenerator.visit_IncludecCs�|jr|�|�|�d|j|�|jr8|�d|j�|�d�|�|j|�|�d|j�|jrr|�d�n
|�d�|jr�|j�	d�s�|�d|j�|j
�|j�d	S)
zVisit regular imports.zl_%s = zcontext.vars[%r] = zenvironment.get_template(z, %r).z+make_module(context.parent, True, locals())r��_z!context.exported_vars.discard(%r)N)r�r�r�r�rWr�r%r�r*�
startswithr\rL)rIr(r�rrrr��s


zCodeGenerator.visit_Importc	Cs�|�|�|�d�|�|j|�|�d|j�|jrD|�d�n
|�d�g}g}x�|jD]�}t|t�rv|\}}n|}|�	d||f�|�	d|�|�
�|�	d|d|�|�t|�f|f�|�
�|jr�|�|�|�d	�s�|�|�|j�|�q^W|�rRt|�d
k�r4|d}|�	d||f�n|�	d
d�dd�|D���|�r�t|�d
k�rz|�	d|d�n|�	dd�tt|���dS)zVisit named imports.z-included_template = environment.get_template(z, %r).z!make_module(context.parent, True)r�z.l_%s = getattr(included_template, %r, missing)zif l_%s is missing:zGl_%s = environment.undefined(%r %% included_template.__name__, name=%r)zGthe template %%r (imported on %s) does not export the requested name %sr�r�rzcontext.vars[%r] = l_%szcontext.vars.update({%s})z, css|]}d||fVqdS)z%r: l_%sNr)rfr*rrrrhsz1CodeGenerator.visit_FromImport.<locals>.<genexpr>z!context.exported_vars.discard(%r)z-context.exported_vars.difference_update((%s))N)r�r�r%r�r*r�rAr"r5r�r�r�r�r�rWr�r�r\rLr�r�r)rIr(r�Z	var_namesZdiscarded_namesr*r�rrrr��sP










zCodeGenerator.visit_FromImportc
Cs~|jdd�}|jr&|j|||dd�}n|��}|�|�|jpRdt|jdd�d�k}|jsh|�|d�}n"|�d	|�|��|�	|�i}|r�|�d
�|j
�d�x6|�t
j�D]&}|jdkr�|jdkr�|�d|j�q�W|�|�|j�r|��}|�d
|�d|k�r>dt|jdd�d�k�r>|�dd|�|��|�d|�|�|j|�|�|�rhd�pjd�|�r|jdk	�r|�d�|�|j|�|�d�|�|j|�|�d�|j�r�|�d�n|�|j|�|�d�|��}	|�|j|	�|�d�n"|j�r|�d�n|�|j|�|j�r>|�d�n|�|�rNd�pPd�|�s�|jdk	�r�|��|�d�|�|j|�|�d�|��|�d�|�d�|��|�|j|�|j�r�|�d|�|��|j�r|�d |�|��|�|j|�|��|j�s(|� ||�|j�rz|�!|�|��|�"||�|�d!�|�|j|�|�d"�|�#|�dS)#N)r�)�excludeF)r�r�)r})Zonly)r�z-def loop(reciter, loop_render_func, depth=0):zl_loop = missingrxz8Can't assign to special loop variable in for-loop targetz%s = 1)r~r|z/l_loop = environment.undefined(%r, name='loop')z�'loop' is undefined. the filter section of a loop as well as the else block don't have access to the special 'loop' variable of the current loop.  Because there is no parent loop it's undefined.  Happened in loop on %szfor z, l_loop in LoopContext(z in �(z for Zreciterz if (z))z, loop_render_func, depth):z):�:zif not �continuer�z%s = 0zif %s:zloop(z, loop))$r��	recursiver�rkrerCr�r�r�rZrVrMr�r�Namervr*r�r�r�r~r�r�r%r�r�r|r�rOr�r�r}r�r�r�r�)
rIr(r�r�Z
loop_frameZ
extended_loopr�r*Ziteration_indicatorZ
test_framerrrr�s�
















zCodeGenerator.visit_ForcCs||��}|�d|�|�|j|�|�d�|��|�|j|�|��|j	rx|�d�|��|�|j	|�|��dS)Nzif r�zelse:)
rlr�r%r|r�r�r�r}r�r~)rIr(r�Zif_framerrrr��s

zCodeGenerator.visit_IfcCst|�||�}|��|jrF|j�d�s6|�d|j�|�d|j�|�d|j�|�||�|j�	|j�dS)Nr�zcontext.exported_vars.add(%r)zcontext.vars[%r] = zl_%s = )
r�r�rWr*r�r�r�r�r\rL)rIr(r�Zmacro_framerrrr��szCodeGenerator.visit_MacrocCs\|jdd�}|�|||�}|�d�|�||�|�||�|j|j|dd�|�|�dS)N)r�)r�z	caller = T)�forward_caller)r�r�r�r�r��
visit_Callr�r�)rIr(r�r�Z
call_framerrrr��s
zCodeGenerator.visit_CallBlockcCsv|��}|�|���|�|�}|�|�|�|�|�|j|�|�||�|�	|j
|�|�|�|�||�dS)N)
rkrer�r�r�rZr�r}r�rrr�r�r�)rIr(r�Zfilter_framer�rrrr��s



zCodeGenerator.visit_FilterBlockcCs|�|�|�|j|�dS)N)r�r%r()rIr(r�rrr�visit_ExprStmt�s
zCodeGenerator.visit_ExprStmtc	s��jr|jrdS�jjr&�fdd�}nt}d}|jrJ��d����d}g}x�|jD]�}y|�|j	�}Wn"tj
k
r�|�|�wVYnXy0|j	jr�t
|d�r�|��}nt|�}||�}Wn tk
r�|�|�wVYnX|�rt|dt��r|d�|�qV|�|g�qVWt|�dk�s0|jdk	�r�|jdk	�rtt|�d	k�r\��d
|j�n��d|j�����x|D]�}t|t��r�tt|��}	|jdk�r���d|	�n��|	d
�n�|jdk�rވ�d|�n
��|�d	}
|j	j�r��d�n |j	j�r��d�n
��d��jjdk	�rB��d�|
d	7}
��||���d|
�|jdk	�r|��d
��q|W|jdk	�r҈����t|�d	k�r�d�p�d��n$g}g}xF|D]>}t|t��r�|�t|��dd��n|�d�|�|��q�W��d���tt|��d�d}
���x�|D]�}��|�d}
|j	j�r`��d�|
d	7}
n|j	j�r|��d�|
d	7}
�jjdk	�r���d�|
d	7}
��||���d|
d
��q0W�����d�|�r���dS)Ncst�j�|��S)N)rr)�finalize)r)rIrr�<lambda>��z,CodeGenerator.visit_Output.<locals>.<lambda>Fzif parent_template is None:T�__html__����r�z
%s.append(z%s.extend((zyield z, z6(context.eval_ctx.autoescape and escape or to_string)(zescape(z
to_string(zenvironment.finalize(r�z))�%z%%z%sz % (r)r�rYr)r�rr�r�r�as_constrU�
Impossibler�r��hasattrr�r�	Exceptionr"r6r�rZr�r
r�r�r�r%r��replace)rIr(r�r�Z
outdent_laterr}�child�constr<�val�close�formatr��idxZargumentr)rIr�visit_Output�s�









"











zCodeGenerator.visit_OutputcCs&|�|�|jr"|��}t�|_n|}|�|j|�|�d�|�|j|�|j�r"dd�|jD�}t	|j�dkr�t
t|j��}|�d||f�nL|�d�x6t
|j�D](\}}|r�|�d�|�d||f�q�W|�d	�|�r"t	|�dk�r|�d
|d�n|�dd�tt|���dS)
Nz = cSsg|]}|�d�s|�qS)r�)r�)rfrrrrr�Hsz.CodeGenerator.visit_Assign.<locals>.<listcomp>r�zcontext.vars[%r] = l_%szcontext.vars.update({z, z%r: l_%sz})zcontext.exported_vars.add(%r)rz"context.exported_vars.update((%s)))r�rWrOr7�toplevel_assignmentsr%r�r�r(r�r
r�r��	enumerater�rr�)rIr(r�Zassignment_frameZpublic_namesr*r
rrrr�7s2





zCodeGenerator.visit_AssigncCs@|jdkr|jr|j�|j�|�d|j�|j�|j�dS)Nrxr�)rvrWrrLr*r�r\)rIr(r�rrrrw^szCodeGenerator.visit_NamecCs2|j}t|t�r |�t|��n|�t|��dS)N)r;r"r3r��strr�)rIr(r�r
rrr�visit_Constds
zCodeGenerator.visit_ConstcCsFy|�t|�|j���Wn&tjk
r@|�d|j�YnXdS)Nz8(context.eval_ctx.autoescape and Markup or identity)(%r))r�r�rrUrr�data)rIr(r�rrr�visit_TemplateDataks
z CodeGenerator.visit_TemplateDatacCsZ|�d�d}x0t|j�D]"\}}|r0|�d�|�||�qW|�|dkrPdpRd�dS)Nr�rz, rz,)r�)r�rrr%)rIr(r�r
r<rrr�visit_Tuplers

zCodeGenerator.visit_TuplecCsJ|�d�x0t|j�D]"\}}|r,|�d�|�||�qW|�d�dS)N�[z, �])r�rrr%)rIr(r�r
r<rrr�
visit_List{s

zCodeGenerator.visit_ListcCsd|�d�xJt|j�D]<\}}|r,|�d�|�|j|�|�d�|�|j|�qW|�d�dS)N�{z, z: r�)r�rrr%r=r;)rIr(r�r
r<rrr�
visit_Dict�s


zCodeGenerator.visit_Dictcs�fdd�}|S)Ncs�|jjrJ�|jjkrJ|�d��|�|j|�|�d�|�|j|�n4|�d�|�|j|�|�d��|�|j|�|�d�dS)Nz$environment.call_binop(context, %r, z, r�z %s r�)r)�	sandboxedZintercepted_binopsr�r%�left�right)rIr(r�)�operatorrrrB�s

z$CodeGenerator.binop.<locals>.visitorr)r�
interceptablerBr)rr�binop�s
zCodeGenerator.binopcs�fdd�}|S)Ncs\|jjr2�|jjkr2|�d��|�|j|�n|�d��|�|j|�|�d�dS)Nz#environment.call_unop(context, %r, r�r�)r)rZintercepted_unopsr�r%r()rIr(r�)rrrrB�sz#CodeGenerator.uaop.<locals>.visitorr)rrrBr)rr�uaop�s	zCodeGenerator.uaop�+�-�*�/z//z**r�and)r�orznot cCsb|jjrd}n|jjrd}nd}|�d|�x$|jD]}|�||�|�d�q6W|�d�dS)Nz;(context.eval_ctx.volatile and markup_join or unicode_join)Zmarkup_joinZunicode_joinz%s((z, z)))rUr�r�r�rr%)rIr(r�r�r�rrr�visit_Concat�szCodeGenerator.visit_ConcatcCs.|�|j|�x|jD]}|�||�qWdS)N)r%�exprZops)rIr(r��oprrr�
visit_Compare�szCodeGenerator.visit_ComparecCs&|�dt|j�|�|j|�dS)Nz %s )r��	operatorsr*r%r))rIr(r�rrr�
visit_Operand�szCodeGenerator.visit_OperandcCs,|�d�|�|j|�|�d|j�dS)Nzenvironment.getattr(z, %r))r�r%r(�attr)rIr(r�rrr�
visit_Getattr�s
zCodeGenerator.visit_GetattrcCs~t|jtj�r@|�|j|�|�d�|�|j|�|�d�n:|�d�|�|j|�|�d�|�|j|�|�d�dS)Nrrzenvironment.getitem(z, r�)r"r�rZSlicer%r(r�)rIr(r�rrr�
visit_Getitem�s


zCodeGenerator.visit_GetitemcCs`|jdk	r|�|j|�|�d�|jdk	r:|�|j|�|jdk	r\|�d�|�|j|�dS)Nr�)�startr%r��stopr�)rIr(r�rrr�visit_Slice�s




zCodeGenerator.visit_SlicecCs|�|j|jd�|jj�|j�}|dkrB|�d|j|j�t|dd�rZ|�d�n.t|dd�rr|�d�nt|dd�r�|�d	�|jdk	r�|�	|j|�nJ|j
jr�|�d
|j|jf�n*|j
j
r�|�d|j�n|�d|j�|�||�|�d
�dS)Nr�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�)r�ror*r)�getr�r�r�r(r%rUr�rZr�r�)rIr(r��funcrrrrr�s(

zCodeGenerator.visit_FiltercCs`|�|j|jd�|j|jjkr8|�d|j|j�|�|j|�|�||�|�d�dS)Nr�zno test named %rr�)	r�rpr*r)r�r�r%r(r�)rIr(r�rrrrsszCodeGenerator.visit_Testcs^���fdd�}��d����j����d����j����d�|���d�dS)Ncs4�jdk	r���j��S��dd�����dS)Nzenvironment.undefined(%r)zRthe inline if-expression on %s evaluated to false and no else section was defined.)Zexpr2r%r�r�r)r�r(rIrr�write_expr2s
z1CodeGenerator.visit_CondExpr.<locals>.write_expr2r�z if z else r�)r�r%Zexpr1r|)rIr(r�r6r)r�r(rIr�visit_CondExprs


zCodeGenerator.visit_CondExprcCsX|jjr|�d�n
|�d�|�|j|�|r8ddip:d}|�|||�|�d�dS)Nzenvironment.call(context, z
context.call(r�r�)r)rr�r%r(r�)rIr(r�r�r�rrrr�s
zCodeGenerator.visit_CallcCs"|�|jd�|�|j|�dS)N�=)r�r=r%r;)rIr(r�rrr�
visit_Keyword(szCodeGenerator.visit_KeywordcCs&|�d�|�|j|�|�d�dS)NzMarkup(r�)r�r%r))rIr(r�rrr�visit_MarkSafe.s
zCodeGenerator.visit_MarkSafecCs&|�d�|�|j|�|�d�dS)Nz5(context.eval_ctx.autoescape and Markup or identity)(r�)r�r%r))rIr(r�rrr�visit_MarkSafeIfAutoescape3s
z(CodeGenerator.visit_MarkSafeIfAutoescapecCs|�d|j�dS)Nzenvironment.)r�r*)rIr(r�rrr�visit_EnvironmentAttribute8sz(CodeGenerator.visit_EnvironmentAttributecCs|�d|j|jf�dS)Nzenvironment.extensions[%r].%s)r�Z
identifierr*)rIr(r�rrr�visit_ExtensionAttribute;sz&CodeGenerator.visit_ExtensionAttributecCs|�|j|j�dS)N)r�r�r�)rIr(r�rrr�visit_ImportedName>sz CodeGenerator.visit_ImportedNamecCs|�|j�dS)N)r�r*)rIr(r�rrr�visit_InternalNameAsz CodeGenerator.visit_InternalNamecCs|�d�dS)Nr�)r�)rIr(r�rrr�visit_ContextReferenceDsz$CodeGenerator.visit_ContextReferencecCs|�d|�dS)Nr�)r�)rIr(r�rrr�visit_ContinueGszCodeGenerator.visit_ContinuecCs|�d|�dS)N�break)r�)rIr(r�rrr�visit_BreakJszCodeGenerator.visit_BreakcCsH|��}|�|���|�|�}|�|�|�|j|�|�||�dS)N)rkrer�r�r�r�r}r�)rIr(r�Zscope_framer�rrrr�Ms

zCodeGenerator.visit_Scopec	Cstxn|jD]d}|�d|j�|�|j|�y|j�|j�}Wntjk
rZd|j_	YqXt
|j|j|�qWdS)Nzcontext.eval_ctx.%s = T)Zoptionsr�r=r%r;rrUrrr��setattr)rIr(r��keywordr
rrr�visit_EvalContextModifierUsz'CodeGenerator.visit_EvalContextModifiercCsf|��}|j��}|�d|�|�||�x|jD]}|�||�q4W|j�|�|�d|�dS)Nz%s = context.eval_ctx.save()zcontext.eval_ctx.revert(%s))r�rUZsaver�rFr}r%Zrevert)rIr(r�Zold_ctx_nameZ	safed_ctxrrrr�visit_ScopedEvalContextModifier`s
z-CodeGenerator.visit_ScopedEvalContextModifier)NF)r�)N)N)Nr)Nr)N)r)NT)N)N)T)T)F)TrPrQrRrJr�r�rZr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rtr�r�r�r�r�r�r�r�r�r�rr�rwrrrrrr r!Z	visit_AddZ	visit_SubZ	visit_MulZ	visit_DivZvisit_FloorDivZ	visit_PowZ	visit_ModZ	visit_AndZvisit_OrZ	visit_PosZ	visit_NegZ	visit_Notr(r+r-r/r0r3rrrsr7r�r9r:r;r<r=r>r?r@rArCr�rFrGrrrrr$ls�
6





5


D
	
c/+5~	{'	





r$)NF)1rS�	itertoolsrrOrrErr�Zjinja2rZjinja2.nodesrZjinja2.visitorrZjinja2.exceptionsrZjinja2.utilsr	r
rZjinja2._compatrr
rrrrrr,rr:r�r r1r�r.r9rCr_rDrT�RuntimeErrorr?rnr>rdrr�r$rrrr�<module>
sF$



%XV

Zerion Mini Shell 1.0