Şuanki Dizin: /proc/self/root/usr/lib/python3.9/site-packages/jinja2/__pycache__/ |
Şuanki Dosya : //proc/self/root/usr/lib/python3.9/site-packages/jinja2/__pycache__/compiler.cpython-39.pyc |
a �`�� @sBdZddlmZddlmZddlmZddlmZ ddl mZddl mZdd l mZdd lmZddlmZddlmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%dddddd d!d"d#�Z&e'e(d$��rLd$Z)nd%Z)d&gZ*ze+d'�e*�,d(�Wne-�y�Yn0ze+d)�Wne-�y�d*Z.Yn0d+Z.d,d-�Z/dCd/d0�Z0d1d2�Z1d3d4�Z2Gd5d6�d6e3�Z4Gd7d8�d8e3�Z5Gd9d:�d:e6�Z7Gd;d<�d<e%�Z8Gd=d>�d>e%�Z9Gd?d@�d@e:�Z;GdAdB�dBe%�Z<d.S)Dz0Compiles nodes from the parser into Python code.�)� namedtuple��update_wrapper)�chain)� iskeyword)�escape)�Markup�)�nodes)�imap)� iteritems)�izip)�NativeStringIO)� range_type)�string_types)� text_type)�TemplateAssertionError)�Symbols)�VAR_LOAD_ALIAS)�VAR_LOAD_PARAMETER)�VAR_LOAD_RESOLVE)�VAR_LOAD_UNDEFINED)�EvalContext)� Optimizer)�concat)�NodeVisitorz==z!=�>z>=�<z<=�inznot in)�eq�ne�gtZgteq�ltZlteqrZnotinr�itemsZdivisionz%from __future__ import generator_stopZgenerator_stopzdef f(): yield from x()FTcs�fdd�}t|��S)NcsF|jr2|jjs2|j�||j�}||kr2|�||�S�|||fi|��S�N)� optimized�eval_ctx�volatile� optimizer�visit)�self�node�frame�kwargsZnew_node��f��3/usr/lib/python3.9/site-packages/jinja2/compiler.py�new_funcCs zoptimizeconst.<locals>.new_funcr)r/r2r0r.r1� optimizeconstBsr3NcCsHt|tj�std��|�||||||�}|�|�|durD|j��SdS)z+Generate the python source for a node tree.z Can't compile non template nodesN)� isinstancer ZTemplate� TypeErrorZcode_generator_classr)�stream�getvalue)r+�environment�name�filenamer6� defer_initr%� generatorr0r0r1�generateNs� r=cCs�|dus|tus|turdSt|�ttttttft vr<dSt|�t ttt fvrl|D]}t|�sTdSqTdSt|�tur�t|�D]$\}}t|�s�dSt|�s�dSq�dSdS)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�keyr0r0r1rI\s"rIcCs:t|�}z|D]}|�|�qWnty2Yn0|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+r0r0r1�find_undeclaredqsrSc@seZdZdd�ZdS)�MacroRefcCs||_d|_d|_d|_dS)NF)r+�accesses_caller�accesses_kwargs�accesses_varargs�r*r+r0r0r1�__init__szMacroRef.__init__N)�__name__� __module__�__qualname__rYr0r0r0r1rT~srTc@s8eZdZdZddd�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|_||_|durb|j|_dS)N��levelF) r&r�symbols�toplevel� rootlevel�require_output_check�buffer�block�parent)r*r&rfr_r0r0r1rY�szFrame.__init__cCs*t�|j�}|j�|j�|j��|_|S)z!Create a copy of the current one.)�object�__new__� __class__�__dict__�updater`�copy�r*�rvr0r0r1rl�sz Frame.copyFcCs&|rt|j|jjdd�St|j|�S)zReturn an inner frame.r r^)r]r&r`r_)r*�isolatedr0r0r1�inner�szFrame.innercCs|��}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)rlrbrmr0r0r1�soft�sz Frame.soft)NN)F) rZr[r\�__doc__rYrlrprq�__copy__r0r0r0r1r]�s r]c@seZdZdZdS)rOz?Exception used by the `UndeclaredNameVisitor` to signal a stop.N�rZr[r\rrr0r0r0r1rO�srOc@s0eZdZdZdd�Zdd�Zdd�Zdd �Zd S)�DependencyFinderVisitorz.A visitor that collects filter and test calls.cCst�|_t�|_dSr$)rG�filters�tests�r*r0r0r1rY�sz DependencyFinderVisitor.__init__cCs|�|�|j�|j�dSr$)� generic_visitrv�addr9rXr0r0r1�visit_Filter�s z$DependencyFinderVisitor.visit_FiltercCs|�|�|j�|j�dSr$)ryrwrzr9rXr0r0r1� visit_Test�s z"DependencyFinderVisitor.visit_TestcCsdS)zStop visiting at blocks.Nr0rXr0r0r1�visit_Block�sz#DependencyFinderVisitor.visit_BlockN)rZr[r\rrrYr{r|r}r0r0r0r1ru�s ruc@s(eZdZdZdd�Zdd�Zdd�ZdS) rNz�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�|_dSr$)rGrQrP)r*rQr0r0r1rY�s zUndeclaredNameVisitor.__init__cCsJ|jdkr8|j|jvr8|j�|j�|j|jkrFt��n|j�|j�dS)N�load)�ctxr9rQrPrzrO�discardrXr0r0r1� visit_Name�s z UndeclaredNameVisitor.visit_NamecCsdS)zStop visiting a blocks.Nr0rXr0r0r1r}�sz!UndeclaredNameVisitor.visit_BlockN)rZr[r\rrrYr�r}r0r0r0r1rN�srNc@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. Nrtr0r0r0r1r��sr�c@s�eZdZd�dd�Zdd�Zdd �Zd d�Zd�dd �Zdd�Zd�dd�Z d�dd�Z dd�Zd�dd�Zdd�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�Z2e3dfdg�Z4e5Z6dZ7dhdi�Z8djdk�Z9dldm�Z:dndo�Z;dpdq�Z<drds�Z=dtdu�Z>dvdw�Z?dxdy�Z@dzd{�ZAd|d}�ZBd~d�ZCd�d��ZDd�d��ZEd�d��ZFd�d�d��ZGd�d�d��ZHeGd��ZIeGd��ZJeGd��ZKeGd��ZLeGd��ZMeGd��ZNeGd��ZOeGd�dd��ZPeGd�dd��ZQeHd��ZReHd��ZSeHd�dd��ZT[G[HeUd�d���ZVeUd�d���ZWd�d��ZXeUd�d���ZYeUd�d���ZZd�d��Z[eUd�d���Z\eUd�d���Z]eUd�d���Z^eUd�d�d���Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�dZld�dĄZmd�dƄZndS)�� CodeGeneratorNFTcCs�|durt�}||_||_||_||_d|_||_||_|rFt|�|_ i|_ i|_d|_d|_ d|_i|_i|_g|_d|_d|_d|_d|_d|_d|_g|_g|_dg|_dS)NFrr T�context)rr8r9r:r6Zcreated_block_contextr;r%rr(�import_aliases�blocks�extends_so_far�has_known_extends�code_linenorwrv� debug_info�_write_debug_info� _new_lines� _last_line�_first_write�_last_identifier�_indentation� _assign_stack�_param_def_block�_context_reference_stack)r*r8r9r:r6r;r%r0r0r1rY�s8 zCodeGenerator.__init__cCst|||j|j��dS)z*Fail with a :exc:`TemplateAssertionError`.N)rr9r:)r*�msg�linenor0r0r1�fail<szCodeGenerator.failcCs|jd7_d|jS)zGet a new unique identifier.r zt_%d)r�rxr0r0r1�temporary_identifier@sz"CodeGenerator.temporary_identifiercCs|��|_|�d|j�dS)z7Enable buffering for the frame from that point onwards.z%s = []N)r�rd� writeline�r*r,r0r0r1rdEs zCodeGenerator.buffercCs�|s�|jjrd|�d�|��|�d|j�|��|�d�|��|�d|j�|��dS|jjr�|�d|j�dS|�d|j�dS)z(Return the buffer contents of the frame.zif context.eval_ctx.autoescape:zreturn Markup(concat(%s))�else:zreturn concat(%s)N)r&r'r��indentrd�outdent� autoescape)r*r,�force_unescapedr0r0r1�return_buffer_contentsJs z$CodeGenerator.return_buffer_contentscCs|jd7_dS)zIndent by one.r N�r�rxr0r0r1r�\szCodeGenerator.indentr cCs|j|8_dS)zOutdent by step.Nr�)r*�stepr0r0r1r�`szCodeGenerator.outdentcCs.|jdur|�d|�n|�d|j|�dS)z%Yield or write into the frame buffer.N�yield � %s.append()rdr�)r*r,r+r0r0r1�start_writeds zCodeGenerator.start_writecCs|jdur|�d�dS)z1End the writing process started by `start_write`.N�))rd�writer�r0r0r1� end_writeks zCodeGenerator.end_writecCs$|�||�|�|�|�|�dS)z4Simple shortcut for start_write + write + end_write.N)r�r�r�)r*�sr,r+r0r0r1�simple_writeps zCodeGenerator.simple_writecCs<z$|�d�|D]}|�||�qWnty6Yn0dS)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+r0r0r1� blockvisitvs zCodeGenerator.blockvisitcCs�|jrp|jsR|j�d|j�|j|j7_|jdurR|j�|j|jf�d|_d|_|j�d|j�d|_|j�|�dS)z&Write a string into the output stream.� NFz r) r�r�r6r�r�r�r��appendr�)r*�xr0r0r1r��s zCodeGenerator.writercCs|�||�|�|�dS)z!Combination of newline and write.N)�newliner�)r*r�r+�extrar0r0r1r��szCodeGenerator.writelinecCs:t|jd|�|_|dur6|j|jkr6|j|_|j|_dS)z/Add one or more newlines before the next write.r N)�maxr�r�r�r�)r*r+r�r0r0r1r��szCodeGenerator.newlinec Cs�d}tdd�|jD�|pd�D]}t|�rd}q4q|jD]}|�d�|�||�q:|s�|jD]}|�d�|�||�q`|dur�t|�D]\}}|�d||f�q�|jr�|�d �|�|j|�|�r�|jdur�|�d �n |�d�|jD],}|�d|j �|�|j |�|�d�q�|du�rPt|�D]\}}|�d ||f��q2|jdu�r�|�d�|�|j|�|�d�n |�d�n$|jdu�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. Fcss|]}|jVqdSr$)rM��.0r�r0r0r1� <genexpr>��z*CodeGenerator.signature.<locals>.<genexpr>r0T�, Nz, %s=%sz, *z , **dict({z, **{z%r: z%r: %s, z}, **r��}z, **)rr-�is_python_keyword�argsr�r)rZdyn_argsZ dyn_kwargsrMrK) r*r+r,�extra_kwargsZkwarg_workaround�kwarg�argrMrKr0r0r1� signature�sJ zCodeGenerator.signaturecCsnt�}|D]}|�|�q dD]J}t||�}t||�D]0}||vrN|��||<|�d||||f�q6qdS)zPull all the dependencies.)rvrwz%s = environment.%s[%r]N)rur)�getattrr�r�)r*r rRr+Z dependency�mappingr9r0r0r1�pull_dependencies�s �zCodeGenerator.pull_dependenciescCs�g}t|jj�D]p\}\}}|tkr&q|tkrH|�d||��|f�q|tkrd|�d||f�q|tkrx|� |�qt d��q|r�|�dd�|��dS)Nz%s = %s(%r)�%s = %szunknown load instruction�%s = missing� = )rr`�loadsrrr��get_resolve_funcrrr��NotImplementedError�join)r*r,�undefs�target�actionZparamr0r0r1�enter_frame�s zCodeGenerator.enter_framecCsD|s@g}t|jj�D]\}}|�|�q|r@|�dd�|��dS)Nr�r�)rr`r�r�r�r�)r*r,�with_python_scoper�r��_r0r0r1�leave_frame�szCodeGenerator.leave_framecCs|jjrd|Sd|S)Nzasync def %szdef %s)r8�is_async)r*r9r0r0r1�func�szCodeGenerator.funcc Cs�|��}|j�|�t|�}d}t�}g}t|j�D]@\}}|jdkrJ|}|jdvr`|�|j�|� |j� |j��q4t|jd�} d| vr�|dur�z|j |t|j�Wq�ty�|�d|j�Yq�0n|� |j�d��d|_d| v�rd|v�r|� |j�d��d|_d| v�r>d|v�r>|� |j�d��d|_d |_|j�|�|�d |�d�d�|�f|�|��|�|�|�|�|�|�t|j�D]�\}}|j� |j�} |�d | �|��z|j |t|j�}Wn0t�y|�d| d|j|jf�Yn0|�d| �|�||�|�| �|� ��q�|�!�|�"|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�Fz%s(%s):Zmacror��if %s is missing:z%s = undefined(%r, name=%r)zparameter %r was not provided�%s = )r��r�)%rpr`�analyze_noderTrG� enumerater�r9rzr��refrS�body�defaults�len� IndexErrorr�r��declare_parameterrUrVrWrcr�r�r�r�rdr��push_parameter_definitionsr)�mark_parameter_storedr��pop_parameter_definitionsr�r�r�)r*r+r,� macro_refZexplicit_callerZskip_special_paramsr��idxr�rPr��defaultr0r0r1� macro_body�sv � �� zCodeGenerator.macro_bodycCs`d�dd�|jjD��}t|jdd�}t|jj�dkr>|d7}|�d|||j|j|jf�dS) z<Dump the macro definition for the def created by macro_body.r�css|]}t|j�VqdSr$)�reprr9r�r0r0r1r�Mr�z*CodeGenerator.macro_def.<locals>.<genexpr>r9Nr �,zLMacro(environment, macro, %r, (%s), %r, %r, %r, context.eval_ctx.autoescape)) r�r+r�r�r�r�rVrWrU)r*r�r,Z arg_tupler9r0r0r1� macro_defKs���zCodeGenerator.macro_defcCs*d|j}|jdur&|dt|j�7}|S)z.Return a human readable position for the node.zline %dN� in )r�r9r�)r*r+rnr0r0r1�position]s zCodeGenerator.positioncCs"dd�dd�t|j���D��S)Nz{%s}r�css|]\}}d||fVqdS��%r: %sNr0)r�r9r�r0r0r1r�es�z3CodeGenerator.dump_local_context.<locals>.<genexpr>)r�rr`Zdump_storesr�r0r0r1�dump_local_contextds�z 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�rxr0r0r1� write_commonsjs 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�r0r0r1r�vsz(CodeGenerator.push_parameter_definitionscCs|j��dS)z+Pops the current parameter definitions set.N)r��poprxr0r0r1r�sz'CodeGenerator.pop_parameter_definitionscCs|jr|jd�|�dS)z�Marks a parameter in the current parameter definitions as stored. This will skip the enforced undefined checks. ���N)r�r��r*r�r0r0r1r��sz#CodeGenerator.mark_parameter_storedcCs|j�|�dSr$)r�r�r�r0r0r1�push_context_reference�sz$CodeGenerator.push_context_referencecCs|j��dSr$)r�r�rxr0r0r1�pop_context_reference�sz#CodeGenerator.pop_context_referencecCs |jdS)Nr��r�rxr0r0r1�get_context_ref�szCodeGenerator.get_context_refcCs|jd}|dkrdSd|S)Nr�r��resolvez %s.resolver�r�r0r0r1r��s zCodeGenerator.get_resolve_funccCsd|��|�|�fS)Nz%s.derived(%s))r�r�r�r0r0r1�derive_context�s�zCodeGenerator.derive_contextcCs|js dS||jdvS)z4Checks if a given target is an undeclared parameter.Fr�)r�r�r0r0r1�parameter_is_undeclared�sz%CodeGenerator.parameter_is_undeclaredcCs|j�t��dS)z+Pushes a new layer for assignment tracking.N)r�r�rGrxr0r0r1�push_assign_tracking�sz"CodeGenerator.push_assign_trackingcCs�|j��}|jr|sdSdd�|D�}t|�dkr^tt|��}|j�|�}|�d||f�nR|�d�t |�D]4\}}|r�|� d�|j�|�}|� d||f�qp|� d �|r�t|�dkr�|�d |d�n|�dd�tt |���dS) zoPops the topmost level for assignment tracking and updates the context variables if necessary. NcSs g|]}|dd�dkr|�qS)Nr r�r0r�r0r0r1� <listcomp>�r�z5CodeGenerator.pop_assign_tracking.<locals>.<listcomp>r �context.vars[%r] = %szcontext.vars.update({r�r�z})�context.exported_vars.add(%r)rz"context.exported_vars.update((%s)))r�r�rar��next�iterr`r�r�r�r�r�rr�)r*r,�varsZpublic_namesr9r�r�r0r0r1�pop_assign_tracking�s. ��z!CodeGenerator.pop_assign_trackingcCs�|dusJd��t|j|j�}ddlm}|�dd�t��|�dd�|��|jjrd|�d�|j rpdprd }|� tj�du}|� tj�D]0}|j|jvr�|�d |j|j�||j|j<q�|� tj�D]j}|j|jvr�|j} |��|j| <} d| v�r&| �dd�\}}|�d||| f�q�|�d | | f�q�|�d|j�|jd|�d�|fdd�|��|��t|�}dt|jd�v�r�|j�d�} |�d| �|j�|�d|_ |_!|�o�|j"|_#|�r�|�d�|�$|�|�%|j�|�&|j|�|j'|dd�|�(�|�r�|j"�s<|��|�d�|��t)�r`|jj�s`|�d�n8|�d|jj�rvd�pxd �|��|�d�|�(�|�(d|j"�t*|j�D]�\}}|�d|�d|�|f|d�|��|��t|�}t|jd�}d|v�r$|j�d�} |�d| �d|v�rN|j�d�} |�d | ||f�|j�|�||_+|�$|�|�%|j�|�&|j|�|j'|dd�|�(��q�|jd!d�d"d#�|jD��dd�|�d$d%�d&d#�|j,D���dS)'Nzno root frame allowedr )�exportedzfrom __future__ import %sr�zfrom jinja2.runtime import zHfrom jinja2.asyncsupport import auto_await, auto_aiter, AsyncLoopContextz, environment=environment�zblock %r defined twice�.zfrom %s import %s as %szimport %s as %sz name = %rz%s(context, missing=missing%s):�root)r�r*rxz%s = TemplateReference(context)Tzparent_template = Noner��if parent_template is not None:z4yield from parent_template.root_render_func(context)z9%sfor event in parent_template.root_render_func(context):zasync zyield eventZblock_)r*�superrz %s = context.super(%r, block_%s)z blocks = {%s}css|]}d||fVqdS)z%r: block_%sNr0r�r0r0r1r�;r�z/CodeGenerator.visit_Template.<locals>.<genexpr>zdebug_info = %r�&css|]}d|VqdS)z%s=%sNr0r�r0r0r1r�Ar�)-rr8r9Zruntimerr�r�� code_featuresr�r;�findr ZExtends�find_allZBlockr�r�r�ZImportedName� importnamer�r��rsplitr�r�r�r]rSr�r`r�r�rarbr�rcr�r�r�r�r��supports_yield_fromrrer�)r*r+r,r&rZenvenvZhave_extendsre�import_�imp�alias�module�objr�r9�block_framerPr0r0r1�visit_Template�s�� � �� �� ��zCodeGenerator.visit_TemplatecCs�d}|jr8|jrdS|jdkr8|�d�|��|d7}|jrJ|�|�}n|��}tr�|j j s�|jdur�|�d|j|f|�nD|j j r�dp�d}|�d||j|f|�|��|� d |�|��|�|�dS) z.Call a block and register it for the template.rN�if parent_template is None:r z$yield from context.blocks[%r][0](%s)� async for�forz&%s event in context.blocks[%r][0](%s):�event)rar�r�r�r�Zscopedr�r�r r8r�rdr9r�r�)r*r+r,r_r��loopr0r0r1r}Ds: �����zCodeGenerator.visit_BlockcCs�|js|�d|j�|jdkrZ|js6|�d�|��|�dd�|jrRt��n|��|�d|�|� |j |�|�d|j�|�dt �|��|�d �|��|jr�d |_|jd7_dS) zCalls the extender.z,cannot use extend from a non top-level scoperr�raise TemplateRuntimeError(%r)zextended multiple timesz+parent_template = environment.get_template(�, %r)z6for name, parent_block in parent_template.blocks.%s():z8context.blocks.setdefault(name, []).append(parent_block)Tr N)rar�r�r�r�r�r�r�r�r)�templater�r9�dict_item_iterrb�r*r+r,r0r0r1� visit_Extendsjs, � zCodeGenerator.visit_ExtendscCs�|jr|�d�|��d}t|jtj�rVt|jjt�r>d}qnt|jjt t f�rnd}nt|jtjtjf�rnd}|�d||�|� |j|�|�d|j�|jr�|��|�d�|��|�d�|��|�d �|��d }|j�r|jjr�dp�d}|�d ||�|�f�n6|jj�r,|�d�n t�rB|�d�d}n |�d�|�sn|��|�d|�|��|j�r~|��dS)zHandles includes.ztry:Zget_or_select_templateZget_templateZselect_templateztemplate = environment.%s(rzexcept TemplateNotFound:r�r�FrrzY%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:rN)Zignore_missingr�r�r4rr ZConstrKrrErF�Tuple�Listr)r�r9r��with_contextr8r�r�r r�)r*r+r,� func_nameZskip_event_yieldrr0r0r1� visit_Include�s\ �� � �zCodeGenerator.visit_IncludecCs�|�d|j�|j�|�|jr0|�d|j�|jjrB|�d�|�d�|�|j |�|�d|j �|jr�|�d|jjr�dp�d|�|�f�n|jjr�|�d �n |�d �|jr�|j� d�s�|�d|j�d S)zVisit regular imports.r��context.vars[%r] = �await zenvironment.get_template(�, %r).�*make_module%s(context.get_all(), True, %s)�_asyncr�_get_default_module_async()�_get_default_module()r��!context.exported_vars.discard(%r)N)r�r`r�r�rar�r8r�r)rr9r"r�� startswithrr0r0r1�visit_Import�s* ��� zCodeGenerator.visit_Importc s�|�|�|�d|jjrdpd�|�|j��|�d|j�|jrn|�d|jjrZdp\d|���f�n|jjr�|�d�n |�d�g}g}|j D]�}t |t�r�|\}}n|}|�d �j �|�|f�|�d �j �|��|��|�d�j �|�d|�|�t|�f|f�|���jr�|�|�|�d �s�|�|�q�|�r�t|�dk�r�|d}|�d|�j �|�f�n"|�dd��fdd�|D���|�r�t|�dk�r�|�d|d�n|�dd�tt|���dS)zVisit named imports.z/included_template = %senvironment.get_template(r&rr'r(r)r*r+z,%s = getattr(included_template, %r, missing)r�z9%s = undefined(%r %% included_template.__name__, name=%r)zGthe template %%r (imported on %s) does not export the requested name %sr�r rr�zcontext.vars.update({%s})r�c3s"|]}d|�j�|�fVqdSr�)r`r�)r�r9�r,r0r1r�(sz1CodeGenerator.visit_FromImport.<locals>.<genexpr>r,z-context.exported_vars.difference_update((%s))N)r�r�r8r�r)rr9r"r�rQr4rEr�r`r�r�r�r�r�rar�r-r�r�r)r*r+r,Z var_namesZdiscarded_namesr9rr0r/r1�visit_FromImport�s� ����� �� ���� ������zCodeGenerator.visit_FromImportcCsN|��}|��}|��}|jp2dt|jdd�d�v}d}|rH|j�d�}|jj|dd�|jrn|jj|dd�|j�rl|� �}|jj|dd�|� d |�|�|j�|��|� |�|� |jjr�d p�d�|�|j|�|�d�|�|jjr�d p�d�|�d�|��|� d|j�|�|j|�|�d�|��|� d�|�|j|�|�d�|j|dd�|j�r�|� d|�d�|�|��|�|�|j|_|�r�|� d|�|�tj�D],} | jdk�r�| jdk�r�|�d| j��q�|j�r|� �} |� d| �|� |jj�r$d �p&d|�|�|j|�|�rj|jj�rZ|�d|�n|�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|�|�rd!�pd�|��|� |�|�|j|�|j�rR|� d"| �|��|j||j�on|jd�|j�r�|� d#| �|��|� |�|�|j|�|�|�|��|j�rJ|� |�|��|�!||�|jj�r�|�d$�|�d%�|jj�r|�d�|�|j|�|jj�r6|�d�|�d&�|�"|�dS)'Nr)r�)Zonly)rr�)Z for_branch�else�testz %s(fiter):z async for zfor r�zauto_aiter(fiter)Zfiter�:�if r��Tr�z'%s(reciter, loop_render_func, depth=0):r��storez8Can't assign to special loop variable in for-loop targetz%s = 1z, %s in AsyncLoopContext(z, %s in LoopContext(z%s(Zreciterzauto_aiter(r�z&, undefined, loop_render_func, depth):z , undefined):z%s = 0zif %s:r&zloop(z, loop))#rp� recursiverSZiter_child_nodesr`r�r��else_r2r�r�r�r�r�r8r�r)r�r�r�r�rdr r �Namerr9r�r�r�r�r�r�r�r�)r*r+r,Z loop_frameZ test_frameZ else_frameZ extended_loopZloop_refZloop_filter_funcr9Ziteration_indicatorr0r0r1� visit_For5s� � � � � zCodeGenerator.visit_ForcCs�|��}|�d|�|�|j|�|�d�|��|�|j|�|��|j D]F}|�d|�|�|j|�|�d�|��|�|j|�|��qP|j r�|�d�|��|�|j |�|��dS)Nr4r3zelif r�)rqr�r)r2r�r�r�r�r��elif_r8)r*r+r,Zif_framer;r0r0r1�visit_If�s& zCodeGenerator.visit_IfcCsr|�||�\}}|��|jrJ|j�d�s:|�d|j�|�d|j�|�d|j�|j��|� ||�dS)Nr�r�r%r�) r�r�rar9r-r�r�r`r�r�)r*r+r,Zmacro_framer�r0r0r1�visit_Macro�szCodeGenerator.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�r0r0r1�visit_CallBlock�s zCodeGenerator.visit_CallBlockcCsh|��}|j�|�|�|�|�|�|�|j|�|�||�|�|j |�|� |�|�|�dSr$)rpr`r�r�rdr�r�r�r{�filterr�r�)r*r+r,Zfilter_framer0r0r1�visit_FilterBlock�s zCodeGenerator.visit_FilterBlockcCs||��}|j�|�|�|�t|j|j�D]2\}}|��|�||�|� d�|�||�q,|� |j|�|�|�dS�Nr�) rpr`r�r�r �targets�valuesr�r)r�r�r�r�)r*r+r,Z with_framer��exprr0r0r1� visit_With�s zCodeGenerator.visit_WithcCs|�|�|�|j|�dSr$)r�r)r+rr0r0r1�visit_ExprStmt�s zCodeGenerator.visit_ExprStmt� _FinalizeInfo)�const�srccs��jdur�jS�j}�d}�jjr�d}�jj���fdd�}t�dd�dur^|d7}d}nFt�d d�dur||d 7}d}n(t�dd�dur�|d7}���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(cs��|��Sr$r0�rK)r��env_finalizer0r1�finalizesz.CodeGenerator._make_finalize.<locals>.finalizeZcontextfunctionFT� context, Zevalcontextfunction�context.eval_ctx, Zenvironmentfunction� environment, cs���j|��Sr$)r8rM�r�rNr*r0r1rO's)� _finalize�_default_finalizer8rOr�rJ)r*rOrLr0rSr1�_make_finalizes& zCodeGenerator._make_finalizecCstt|��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*�groupr0r0r1�_output_const_repr-sz CodeGenerator._output_const_reprcCs:|�|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�rr4r �TemplateDatarrK)r*r+r,rOrKr0r0r1�_output_child_to_const4sz$CodeGenerator._output_child_to_constcCsL|jjr|�d�n|jjr(|�d�n |�d�|jdurH|�|j�dS)zXOutput extra source code before visiting a child of an ``Output`` node. z7(escape if context.eval_ctx.autoescape else to_string)(zescape(z to_string(N)r&r'r�r�rL�r*r+r,rOr0r0r1�_output_child_preGs zCodeGenerator._output_child_precCs"|�d�|jdur|�d�dS)zWOutput extra source code after visiting a child of an ``Output`` node. r�N)r�rLr\r0r0r1�_output_child_postUs z CodeGenerator._output_child_postc Cs�|jr"|jrdS|�d�|��|��}g}|jD]�}z,|jsTt|tj�sTt� ��|� |||�}Wn&tj tfy�|�|�Yq4Yn0|r�t|dt �r�|d�|�q4|�|g�q4|jdur�t|�dkr�|�d|j�n|�d|j�|��|D]�}t|t ��rF|�|�}|jdu�r6|�d|�n|�|d�nb|jdu�r`|�d|�n |�|�|�|||�|�||�|�|||�|jdu�r|�d��q|jdu�r�|��|�t|�dk�r�dnd �|j�r�|��dS) Nrr�r r�z%s.extend((r�r�r��)))rcr�r�r�rVr rKr4rZ� Impossibler[� Exceptionr�rFrdr�rXr�r]r)r^r�r�) r*r+r,rOr��childrKrL�valr0r0r1�visit_Output^sZ � � zCodeGenerator.visit_OutputcCsF|��|�|�|�|j|�|�d�|�|j|�|�|�dSrD)r�r�r)r�r�r+rrr0r0r1�visit_Assign�s zCodeGenerator.visit_AssigncCs�|��|��}d|_|j�|�|�|�|�|�|�|j|�|� |�|� |j|�|�d�|j dur�|�|j |�n|�d|j�|�d�|�|�|�|�dS)NFz9 = (Markup if context.eval_ctx.autoescape else identity)(� concat(%s)r�)r�rprcr`r�r�rdr�r�r�r)r�r�rBr{rr�)r*r+r,rr0r0r1�visit_AssignBlock�s zCodeGenerator.visit_AssignBlockcCs�|jdkr(|jr(|jr(|jd�|j�|j�|j�}|jdkr�|j�|�}|durj|dtkrj|� |�r�|� d|j||f�dS|� |�dS)Nr6r�r~rz-(undefined(name=%r) if %s is missing else %s))rrar�rzr9r`r�Z find_loadrr�r�)r*r+r,r�r~r0r0r1r��s& � �� ��zCodeGenerator.visit_NamecCsR|j�|j�}|�d|�|��|�dd�|��|�d||jf�dS)Nz!if not isinstance(%s, Namespace):rz/cannot assign attribute on non-namespace objectz%s[%r])r`r�r9r�r�r��attr)r*r+r,r�r0r0r1�visit_NSRef�s��zCodeGenerator.visit_NSRefcCs8|�|j�}t|t�r&|�t|��n|�t|��dSr$)rYr&r4rCr��strr�)r*r+r,rcr0r0r1�visit_Const�s zCodeGenerator.visit_ConstcCsDz|�t|�|j���Wn$tjy>|�d|j�Yn0dS)Nz9(Markup if context.eval_ctx.autoescape else identity)(%r))r�r�rYr&r r`�datarr0r0r1�visit_TemplateData�s�z CodeGenerator.visit_TemplateDatacCsV|�d�d}t|j�D]"\}}|r.|�d�|�||�q|�|dkrLdpNd�dS)N�(r�r�rz,)r��r�r�r#r)�r*r+r,r�rLr0r0r1�visit_Tuples zCodeGenerator.visit_TuplecCsF|�d�t|j�D]"\}}|r*|�d�|�||�q|�d�dS)N�[r��]rorpr0r0r1� visit_Lists zCodeGenerator.visit_ListcCs`|�d�t|j�D]<\}}|r*|�d�|�|j|�|�d�|�|j|�q|�d�dS)N�{r�z: r�)r�r�r#r)rMrKrpr0r0r1� visit_Dicts zCodeGenerator.visit_Dictcst�fdd��}|S)Ncs�|jjrJ�|jjvrJ|�d��|�|j|�|�d�|�|j|�n4|�d�|�|j|�|�d��|�|j|�|�d�dS)Nz$environment.call_binop(context, %r, r�rn� %s r�)r8� sandboxedZintercepted_binopsr�r)�left�rightr��operatorr0r1rRs� � z$CodeGenerator.binop.<locals>.visitor�r3�r|� interceptablerRr0r{r1�binopszCodeGenerator.binopcst�fdd��}|S)Ncs\|jjr2�|jjvr2|�d��|�|j|�n|�d��|�|j|�|�d�dS)Nz#environment.call_unop(context, %r, rnr�)r8rxZintercepted_unopsr�r)r+rr{r0r1rR2s� �z#CodeGenerator.uaop.<locals>.visitorr}r~r0r{r1�uaop1szCodeGenerator.uaop�+�-�*�/z//z**�%�and)r�orznot cCs^|jjrd}n|jjrd}nd}|�d|�|jD]}|�||�|�d�q4|�d�dS)Nz;(context.eval_ctx.volatile and markup_join or unicode_join)Zmarkup_joinZunicode_joinz%s((r�r_)r&r'r�r�r r))r*r+r,r#r�r0r0r1�visit_ConcatOs zCodeGenerator.visit_ConcatcCs>|�d�|�|j|�|jD]}|�||�q|�d�dS)Nrnr�)r�r)rG�ops)r*r+r,�opr0r0r1� visit_Compare]s zCodeGenerator.visit_ComparecCs&|�dt|j�|�|j|�dS)Nrw)r�� operatorsr�r)rGrr0r0r1� visit_OperandeszCodeGenerator.visit_OperandcCsP|jjr|�d�|�d�|�|j|�|�d|j�|jjrL|�d�dS)N�(await auto_await(zenvironment.getattr(rr_)r8r�r�r)r+rhrr0r0r1� visit_Getattris zCodeGenerator.visit_GetattrcCs�t|jtj�r@|�|j|�|�d�|�|j|�|�d�n^|jjrR|�d�|�d�|�|j|�|�d�|�|j|�|�d�|jjr�|�d�dS)Nrrrsr�zenvironment.getitem(r�r�r_) r4r�r ZSlicer)r+r�r8r�rr0r0r1� visit_Getitemus zCodeGenerator.visit_GetitemcCs`|jdur|�|j|�|�d�|jdur:|�|j|�|jdur\|�d�|�|j|�dS)Nr3)�startr)r��stopr�rr0r0r1�visit_Slice�s zCodeGenerator.visit_SlicecCs8|jjr|�d�|�|j|jd�|jj�|j�}|durT|�d|j|j�t|dd�durp|�d�n6t|dd�dur�|�d �nt|d d�dur�|�d�|j dur�|� |j |�nJ|jjr�|�d|j |j f�n*|jjr�|�d |j �n|�d|j �|�||�|�d�|jj�r4|�d�dS)N�await auto_await(rnzno filter named %rZ contextfilterFTrPZevalcontextfilterrQZenvironmentfilterrRzB(context.eval_ctx.autoescape and Markup(concat(%s)) or concat(%s))zMarkup(concat(%s))rfr�)r8r�r�rvr9�getr�r�r�r+r)r&r'rdr�r�)r*r+r,r�r0r0r1r{�s6 �� zCodeGenerator.visit_FiltercCs`|�|j|jd�|j|jjvr8|�d|j|j�|�|j|�|�||�|�d�dS)Nrnzno test named %rr�) r�rwr9r8r�r�r)r+r�rr0r0r1r|�szCodeGenerator.visit_Testcs^���fdd�}��d����j����d����j����d�|���d�dS)Ncs4�jdur���j��S��dd�����dS)Nzcond_expr_undefined(%r)zRthe inline if-expression on %s evaluated to false and no else section was defined.)Zexpr2r)r�r�r0�r,r+r*r0r1�write_expr2�s ���z1CodeGenerator.visit_CondExpr.<locals>.write_expr2rnz if z else r�)r�r)Zexpr1r2)r*r+r,r�r0r�r1�visit_CondExpr�s zCodeGenerator.visit_CondExprcCs||jjr|�d�|jjr&|�d�n |�d�|�|j|�|rJddipLd}|�|||�|�d�|jjrx|�d�dS)Nr�zenvironment.call(context, z context.call(r�r�)r8r�r�rxr)r+r�)r*r+r,r>r�r0r0r1r?�s zCodeGenerator.visit_CallcCs"|�|jd�|�|j|�dS)N�=)r�rMr)rKrr0r0r1� visit_Keyword�szCodeGenerator.visit_KeywordcCs&|�d�|�|j|�|�d�dS)NzMarkup(r��r�r)rGrr0r0r1�visit_MarkSafe�s zCodeGenerator.visit_MarkSafecCs&|�d�|�|j|�|�d�dS)Nz5(context.eval_ctx.autoescape and Markup or identity)(r�r�rr0r0r1�visit_MarkSafeIfAutoescape�s z(CodeGenerator.visit_MarkSafeIfAutoescapecCs|�d|j�dS)Nzenvironment.�r�r9rr0r0r1�visit_EnvironmentAttribute�sz(CodeGenerator.visit_EnvironmentAttributecCs|�d|j|jf�dS)Nzenvironment.extensions[%r].%s)r�Z identifierr9rr0r0r1�visit_ExtensionAttribute�sz&CodeGenerator.visit_ExtensionAttributecCs|�|j|j�dSr$)r�r�rrr0r0r1�visit_ImportedName�sz CodeGenerator.visit_ImportedNamecCs|�|j�dSr$r�rr0r0r1�visit_InternalName�sz CodeGenerator.visit_InternalNamecCs|�d�dS)Nr�)r�rr0r0r1�visit_ContextReference�sz$CodeGenerator.visit_ContextReferencecCs|�|�|��dSr$)r�r�rr0r0r1�visit_DerivedContextReferencesz+CodeGenerator.visit_DerivedContextReferencecCs|�d|�dS)N�continuer�rr0r0r1�visit_ContinueszCodeGenerator.visit_ContinuecCs|�d|�dS)N�breakr�rr0r0r1�visit_BreakszCodeGenerator.visit_BreakcCs:|��}|j�|�|�|�|�|j|�|�|�dSr$)rpr`r�r�r�r�r�)r*r+r,�scope_framer0r0r1�visit_Scopes zCodeGenerator.visit_ScopecCs�|��}|�d||�|�f�|�d|�|�|j|�|�|�|jdd�}|j�|�|� |�|� |j|�|�|�|� �dS)Nr�z %s.vars = T)ro)r�r�r�r)r�r�rpr`r�r�r�r�r�r�)r*r+r,rr�r0r0r1�visit_OverlayScopes z CodeGenerator.visit_OverlayScopec Csn|jD]b}|�d|j�|�|j|�z|j�|j�}WntjyVd|j_ Yq0t |j|j|�qdS)Nzcontext.eval_ctx.%s = T)�optionsr�rMr)rKrYr&r r`r'�setattr)r*r+r,�keywordrcr0r0r1�visit_EvalContextModifier s z'CodeGenerator.visit_EvalContextModifiercCsb|��}|j��}|�d|�|�||�|jD]}|�||�q2|j�|�|�d|�dS)Nz%s = context.eval_ctx.save()zcontext.eval_ctx.revert(%s))r�r&Zsaver�r�r�r)Zrevert)r*r+r,Zold_ctx_nameZ saved_ctxrbr0r0r1�visit_ScopedEvalContextModifier+s z-CodeGenerator.visit_ScopedEvalContextModifier)NFT)F)r )N)N)Nr)Nr)N)F)N)T)T)F)orZr[r\rYr�r�rdr�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�rrr}rr$r.r0r:r<r=rArCrHrIrrJrrUrTrVrXr[r]r^rdrergr�rirkrmrqrtrvr�r�Z visit_AddZ visit_SubZ visit_MulZ visit_DivZvisit_FloorDivZ visit_PowZ visit_ModZ visit_AndZvisit_OrZ visit_PosZ visit_NegZ visit_Notr3r�r�r�r�r�r�r{r|r�r?r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r0r0r0r1r��s�� D 5 P |&-:K ) O r�)NFT)=rr�collectionsr� functoolsr� itertoolsrr�rr�Z markupsaferrrr Z_compatrrr rrrr� exceptionsrZ idtrackingrrrrrrr(rZutilsrrRrr��hasattrrJrr�execr��SyntaxErrorr r3r=rIrSrgrTr]�RuntimeErrorrOrurNrar�r�r0r0r0r1�<module>sv� � =
Linux 65-254-81-4.cprapid.com 5.14.0-284.11.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 9 05:49:00 EDT 2023 x86_64
Apache
65.254.81.4