Revonzy Mini Shell

Revonzy Mini Shell

Şuanki Dizin: /proc/self/root/usr/lib/python3.9/site-packages/jinja2/__pycache__/
Dosya Yükle :
Şuanki Dosya : //proc/self/root/usr/lib/python3.9/site-packages/jinja2/__pycache__/parser.cpython-39.pyc

a

�`L��@s�dZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
egd��Zegd	��Z
ejejejejejejd
�ZGdd�de�Zd
S)z8Parse tokens from the lexer into nodes for the compiler.�)�nodes)�imap)�TemplateAssertionError)�TemplateSyntaxError)�describe_token��describe_token_expr)�for�if�blockZextends�printZmacroZinclude�from�import�set�with�
autoescape)�eq�ne�ltZlteq�gtZgteq)�add�sub�mul�div�floordiv�modc@s�eZdZdZdidd�Zdefdd�Zdd�Zdjd	d
�Zdkdd�Z	dld
d�Z
dmdd�Zdd�Zdndd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zdod7d8�Zdpd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dqdMdN�Z)dOdP�Z*drdQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dsdadb�Z3dcdd�Z4dtdedf�Z5dgdh�Z6dS)u�Parserz�This is the central parsing class Jinja uses.  It's passed to
    extensions and can be used to parse expressions or statements.
    NcCsl||_|�||||�|_||_||_d|_i|_|��D]}|jD]}|j	|j|<qBq8d|_
g|_g|_dS)NF�)
�environment�	_tokenize�stream�name�filename�closed�
extensionsZiter_extensions�tags�parse�_last_identifier�
_tag_stack�_end_token_stack)�selfr�sourcer!r"�state�	extension�tag�r/�1/usr/lib/python3.9/site-packages/jinja2/parser.py�__init__+s
zParser.__init__cCs(|dur|jjj}||||j|j��dS)z�Convenience method that raises `exc` with the message, passed
        line number or last line number as well as the current name and
        filename.
        N)r �current�linenor!r")r*�msgr3�excr/r/r0�fail9s
zParser.failcCs�g}|D]}|�tt|��q|r<d�dd�|dD��}nd}|durPdg}n
d|g}|r�|dur~||vr~|�d|�n|�d|�|jr�|�d	|jd�|�d
�|�|�dS)Nz or css|]}dt|�VqdS)z'%s'Nr)�.0�exprr/r/r0�	<genexpr>Gsz&Parser._fail_ut_eof.<locals>.<genexpr>���zUnexpected end of template.zEncountered unknown tag '%s'.z_You probably made a nesting mistake. Jinja is expecting this tag, but currently looking for %s.z-Jinja was looking for the following tags: %s.z4The innermost block that needs to be closed is '%s'.� )�extendrr�join�appendr(r6)r*r!Zend_token_stackr3ZexpectedZexprsZcurrently_looking�messager/r/r0�_fail_ut_eofBs<
�

������zParser._fail_ut_eofcCs|�||j|�S)z�Called if the parser encounters an unknown tag.  Tries to fail
        with a human readable error message that could help to identify
        the problem.
        )r@r))r*r!r3r/r/r0�fail_unknown_taggszParser.fail_unknown_tagcCs*t|j�}|dur|�|�|�d||�S)z9Like fail_unknown_tag but for end of template situations.N)�listr)r>r@)r*�
end_tokensr3�stackr/r/r0�fail_eofns

zParser.fail_eofcCs,|jjjdvrdS|dur(|jj�|�SdS)zAre we at the end of a tuple?)�variable_end�	block_end�rparenTNF)r r2�type�test_any)r*�extra_end_rulesr/r/r0�is_tuple_endus
zParser.is_tuple_endcCs6|jd7_t�tj�}tjj|d|j|d�|S)zDReturn a new free identifier as :class:`~jinja2.nodes.InternalName`.rzfi%d�r3)r'�object�__new__rZInternalNameZNoder1)r*r3�rvr/r/r0�free_identifier}szParser.free_identifiercCs|jj}|jdkr |�d|j�|j�|j�d}z�|jtvrdt	|d|jjj��W|rb|j�
�S|jdkr�|��W|r�|j�
�S|jdkr�|��W|r�|j�
�S|j
�|j�}|dur�||�W|r�|j�
�S|j�
�d}|�|j|j�W|�r|j�
�n|�r|j�
�0dS)	zParse a single statement.r!ztag name expectedTZparse_�call�filterNF)r r2rIr6r3r(r>�value�_statement_keywords�getattr�pop�parse_call_block�parse_filter_blockr$�getrA)r*�tokenZpop_tag�extr/r/r0�parse_statement�sD


�

�

�	
�
�zParser.parse_statementFcCsL|j�d�|j�d�|�|�}|jjjdkr:|�|�|rHt|j�|S)aRParse multiple statements into a list until one of the end tokens
        is reached.  This is used to parse the body of statements as it also
        parses template data if appropriate.  The parser checks first if the
        current token is a colon and skips it if there is one.  Then it checks
        for the block end and parses until if one of the `end_tokens` is
        reached.  Per default the active token in the stream at the end of
        the call is the matched end token.  If this is not wanted `drop_needle`
        can be set to `True` and the end token is removed.
        �colonrG�eof)r �skip_if�expect�subparser2rIrE�next)r*rC�drop_needle�resultr/r/r0�parse_statements�s


zParser.parse_statementscCsft|j�j}|jdd�}|j�d�r<|��}tj|||d�S|�d�}|j	ddd�}tj
||||d�S)zParse an assign statement.T)�with_namespace�assignrMN)zname:endset�rd)rcr r3�parse_assign_targetr`�parse_tuplerZAssign�parse_filterrfZAssignBlock)r*r3�targetr8Zfilter_node�bodyr/r/r0�	parse_set�s
zParser.parse_setc	Cs�|j�d�j}|jdd�}|j�d�|jddd�}d}|j�d	�rL|��}|j�d
�}|�d�}t|j�j	dkrxg}n|jd
dd�}t
j|||||||d�S)zParse a for loop.zname:for)�name:in)rKrpF)�name:recursive)�
with_condexprrKN�name:ifrq)�name:endfor�	name:elseZendfor)rtTrirM)r rar3rjrkr`�parse_expressionrfrcrTrZFor)r*r3rm�iter�test�	recursivern�else_r/r/r0�	parse_for�s�
zParser.parse_forcCs�tj|j�d�jd�}}|jdd�|_|�d�|_g|_	g|_
t|j�}|�d�rvtj|jjjd�}|j	�
|�qq�|�d�r�|jdd	d
�|_
q�q|S)zParse an if construct.rsrMF�rr)�	name:elifru�
name:endifr}ru)r~Tri)rZIfr rar3rkrxrfrnZelif_rzrcr2r>)r*�noderer[r/r/r0�parse_if�s


zParser.parse_ifcCs�tjt|j�jd�}g}g}|jjjdkrr|r:|j�d�|��}|�	d�|�
|�|j�d�|�
|���q||_||_
|jddd�|_|S)	NrMrG�comma�paramrh)zname:endwithTri)rZWithrcr r3r2rIrarj�set_ctxr>rv�targets�valuesrfrn)r*rr�r�rmr/r/r0�
parse_with�s

zParser.parse_withcCsDtjt|j�jd�}t�d|���g|_|jddd�|_	t�
|g�S)NrMr)zname:endautoescapeTri)rZScopedEvalContextModifierrcr r3�Keywordrv�optionsrfrnZScope�r*rr/r/r0�parse_autoescape�szParser.parse_autoescapecCsptjt|j�jd�}|j�d�j|_|j�d�|_	|jj
jdkrJ|�d�|j
ddd�|_|j�d	|j�|S)
NrMr!zname:scopedrzpBlock names in Jinja have to be valid Python identifiers and may not contain hyphens, use an underscore instead.)z
name:endblockTrizname:)rZBlockrcr r3rarTr!r`Zscopedr2rIr6rfrnr�r/r/r0�parse_blocks�zParser.parse_blockcCs"tjt|j�jd�}|��|_|S)NrM)rZExtendsrcr r3rv�templater�r/r/r0�
parse_extendss
zParser.parse_extendscCsH|jj�dd�r>|j���d�r>t|j�jdk|_|j��n||_|S)Nz	name:withzname:without�name:contextr)	r r2rJ�lookrxrcrT�with_context�skip)r*r�defaultr/r/r0�parse_import_contexts��zParser.parse_import_contextcCsbtjt|j�jd�}|��|_|jj�d�rP|j�	��d�rPd|_
|j�d�nd|_
|�|d�S)NrMzname:ignorezname:missingT�F)
rZIncludercr r3rvr�r2rxr�Zignore_missingr�r�r�r/r/r0�
parse_include$s
�zParser.parse_includecCsFtjt|j�jd�}|��|_|j�d�|jdd�j	|_
|�|d�S)NrM�name:asT��	name_onlyF)rZImportrcr r3rvr�rarjr!rmr�r�r/r/r0�parse_import0s

zParser.parse_importcstjt�j�jd������_�j�d�g�_��fdd�}�jrP�j�d��jj	j
dkr�|�rfq�jdd�}|j�
d	�r��jd
|jtd��j�d�r��jdd�}�j�|j|jf�n�j�|j�|�s�jj	j
dkr�q�q>�j�d�q>t�d
��sd�_�S)NrMzname:importcsB�jjjdvr>�j���d�r>t�j�jdk�_�j��dSdS)N)rZwithoutr�rTF)r r2rTr�rxrcr�r�r/�rr*r/r0�
parse_context=s�
z(Parser.parse_from.<locals>.parse_contextr�r!Tr��_z4names starting with an underline can not be imported)r5r�r�F)rZ
FromImportrcr r3rvr�ra�namesr2rIrjr!�
startswithr6rr`r>�hasattrr�)r*r�rm�aliasr/r�r0�
parse_from7s6
�zParser.parse_fromcCs�g|_}g|_}|j�d�|jjjdkr�|r>|j�d�|jdd�}|�d�|j�d�rp|�	|�
��n|r~|�d�|�	|�q |j�d�dS)	N�lparenrHr�Tr�r�rhz-non-default argument follows default argument)�args�defaultsr rar2rIrjr�r`r>rvr6)r*rr�r��argr/r/r0�parse_signatureas



zParser.parse_signaturecCsttjt|j�jd�}|jjjdkr.|�|�ng|_g|_	|�
�|_t|jtj
�s`|�d|j�|jddd�|_|S)NrMr�z
expected call)zname:endcallTri)rZ	CallBlockrcr r3r2rIr�r�r�rvrR�
isinstance�Callr6rfrnr�r/r/r0rXqs
zParser.parse_call_blockcCs8tjt|j�jd�}|jddd�|_|jddd�|_|S)NrMT)�start_inline)zname:endfilterri)	rZFilterBlockrcr r3rlrSrfrnr�r/r/r0rYszParser.parse_filter_blockcCsBtjt|j�jd�}|jdd�j|_|�|�|jddd�|_	|S)NrMTr�)z
name:endmacrori)
rZMacrorcr r3rjr!r�rfrnr�r/r/r0�parse_macro�s

zParser.parse_macrocCsPtjt|j�jd�}g|_|jjjdkrL|jr:|j�d�|j�|�	��q|S)NrMrGr�)
r�Outputrcr r3r2rIrar>rvr�r/r/r0�parse_print�szParser.parse_printTcCs�|rN|j��jdkrN|j�d�}t|j�|j�d�}tj|j|j|jd�}nL|rt|j�d�}tj	|jd|jd�}n&|r�|j
d|d�}n|��}|�d�|�
�s�|�d|jj��|j�|S)aParse an assignment target.  As Jinja allows assignments to
        tuples, this function can parse all allowed assignment targets.  Per
        default assignments to tuples are parsed, that can be disable however
        by setting `with_tuple` to `False`.  If only assignments to names are
        wanted `name_only` can be set to `True`.  The `extra_end_rules`
        parameter is forwarded to the tuple parsing function.  If
        `with_namespace` is enabled, a namespace assignment may be parsed.
        �dotr!rM�storeT)�
simplifiedrKzcan't assign to %r)r r�rIrarcrZNSRefrTr3�Namerk�
parse_primaryr�Z
can_assignr6�	__class__�__name__�lower)r*Z
with_tupler�rKrgr[�attrrmr/r/r0rj�s&
�
�zParser.parse_assign_targetcCs|r|��S|��S)z�Parse an expression.  Per default all expressions are parsed, if
        the optional `with_condexpr` parameter is set to `False` conditional
        expressions are not parsed.
        )�parse_condexpr�parse_or)r*rrr/r/r0rv�szParser.parse_expressioncCsb|jjj}|��}|j�d�r^|��}|j�d�r<|��}nd}tj||||d�}|jjj}q|S)NrsrurM)r r2r3r�r`r�rZCondExpr)r*r3Zexpr1Zexpr2Zexpr3r/r/r0r��s

zParser.parse_condexprcCsF|jjj}|��}|j�d�rB|��}tj|||d�}|jjj}q|S)N�name:orrM)r r2r3�	parse_andr`rZOr�r*r3�left�rightr/r/r0r��s
zParser.parse_orcCsF|jjj}|��}|j�d�rB|��}tj|||d�}|jjj}q|S)N�name:andrM)r r2r3�	parse_notr`rZAndr�r/r/r0r��s
zParser.parse_andcCs4|jj�d�r,t|j�j}tj|��|d�S|��S)N�name:notrM)	r r2rxrcr3r�Notr��
parse_compare)r*r3r/r/r0r��szParser.parse_notcCs�|jjj}|��}g}|jjj}|tvrJt|j�|�t�	||����nh|j�
d�rn|�t�	d|����nD|jj�d�r�|j���d�r�|j�
d�|�t�	d|����nq�|jjj}q|s�|Stj|||d�S)Nrp�inr�r�ZnotinrM)r r2r3�parse_math1rI�_compare_operatorsrcr>rZOperandr`rxr�r�ZCompare)r*r3r8�ops�
token_typer/r/r0r��s&


�zParser.parse_comparecCs^|jjj}|��}|jjjdvrZt|jjj}t|j�|��}||||d�}|jjj}q|S)N)rrrM)r r2r3�parse_concatrI�_math_nodesrc�r*r3r��clsr�r/r/r0r��s

zParser.parse_math1cCs^|jjj}|��g}|jjjdkr<t|j�|�|���qt|�dkrP|dStj	||d�S)N�tilderrrM)
r r2r3�parse_math2rIrcr>�lenrZConcat)r*r3r�r/r/r0r�
s


zParser.parse_concatcCs^|jjj}|��}|jjjdvrZt|jjj}t|j�|��}||||d�}|jjj}q|S)N)rrrrrM)r r2r3�	parse_powrIr�rcr�r/r/r0r�s

zParser.parse_math2cCsR|jjj}|��}|jjjdkrNt|j�|��}tj|||d�}|jjj}q|S)N�powrM)r r2r3�parse_unaryrIrcrZPowr�r/r/r0r�s

zParser.parse_powcCs�|jjj}|jjj}|dkr<t|j�tj|�d�|d�}n0|dkrdt|j�tj|�d�|d�}n|�	�}|�
|�}|r�|�|�}|S)NrFrMr)r r2rIr3rcrZNegr�ZPosr��
parse_postfix�parse_filter_expr)r*Zwith_filterr�r3rr/r/r0r�)s





zParser.parse_unarycCsp|jj}|jdkrp|jdvr4tj|jdv|jd�}n0|jdvrPtjd|jd�}ntj|jd|jd�}t|j�n�|jdkr�t|j�|jg}|j}|jjjdkr�|�	|jjj�t|j�q�tjd�
|�|d�}n�|jd	vr�t|j�tj|j|jd�}nr|jd
k�r*t|j�|jdd�}|j�d
�nB|jdk�r@|�
�}n,|jdk�rV|��}n|�dt|�|j�|S)Nr!)�trueZfalse�True�False)r�r�rM)Znone�None�load�string�)�integer�floatr�T)�explicit_parenthesesrH�lbracket�lbracezunexpected '%s')r r2rIrTr�Constr3r�rcr>r=rkra�
parse_list�
parse_dictr6r)r*r[r�bufr3r/r/r0r�9s:









zParser.parse_primaryc	s��jjj}|r�j}n|r"�j}n�fdd�}g}d}|rF�j�d���|�rRq�|�|���jjjdkr�d}nq��jjj}q6|s�|r�|dS|s���	dt
�jj��tj|d|d	�S)
a�Works like `parse_expression` but if multiple expressions are
        delimited by a comma a :class:`~jinja2.nodes.Tuple` node is created.
        This method could also return a regular expression instead of a tuple
        if no commas where found.

        The default parsing mode is a full tuple.  If `simplified` is `True`
        only names and literals are parsed.  The `no_condexpr` parameter is
        forwarded to :meth:`parse_expression`.

        Because tuples do not require delimiters and may end in a bogus comma
        an extra hint is needed that marks the end of a tuple.  For example
        for loops support tuples between `for` and `in`.  In that case the
        `extra_end_rules` is set to ``['name:in']``.

        `explicit_parentheses` is true if the parsing was triggered by an
        expression in parentheses.  This is used to figure out if an empty
        tuple is a valid expression or not.
        cs�jdd�S)NFr|)rvr/�r*r/r0r&zsz!Parser.parse_tuple.<locals>.parseFr�Trz Expected an expression, got '%s'r�rM)
r r2r3r�rvrarLr>rIr6rr�Tuple)	r*r�rrrKr�r3r&r�Zis_tupler/r�r0rkZs6


��zParser.parse_tuplecCsj|j�d�}g}|jjjdkrN|r.|j�d�|jjjdkr>qN|�|���q|j�d�tj||jd�S)Nr��rbracketr�rM)	r rar2rIr>rvr�Listr3)r*r[�itemsr/r/r0r��szParser.parse_listcCs�|j�d�}g}|jjjdkrt|r.|j�d�|jjjdkr>qt|��}|j�d�|��}|�tj|||jd��q|j�d�tj	||jd�S)Nr��rbracer�r^rM)
r rar2rIrvr>rZPairr3�Dict)r*r[r��keyrTr/r/r0r��szParser.parse_dictcCsB|jjj}|dks|dkr&|�|�}q|dkr>|�|�}qq>q|S)Nr�r�r�)r r2rI�parse_subscript�
parse_call�r*rr�r/r/r0r��s
zParser.parse_postfixcCs\|jjj}|dkr|�|�}q|dkr@|jjjdkr@|�|�}q|dkrX|�|�}qqXq|S)N�piper!�isr�)r r2rIrlrT�
parse_testr�r�r/r/r0r��s
zParser.parse_filter_exprcCst|j�}|jdkr�|jj}t|j�|jdkrFtj||jd|jd�S|jdkr^|�d|j�tj	|j|jd�}tj
||d|jd�S|jdk�r
g}|jjjdkr�|r�|j�d	�|�|�
��q�|j�d�t|�d
kr�|d}ntj|d|jd�}tj
||d|jd�S|�d|j�dS)
Nr�r!r�rMr�zexpected name or numberr�r�r�rrzexpected subscript expression)rcr rIr2rZGetattrrTr3r6r�ZGetitemrar>�parse_subscribedr�r�)r*rr[Z
attr_tokenr�r�r/r/r0r��s0



�

zParser.parse_subscriptcCs�|jjj}|jjjdkr*t|j�dg}n*|��}|jjjdkrD|St|j�|g}|jjjdkrn|�d�n(|jjjdvr�|�|���n
|�d�|jjjdkr�t|j�|jjjdvr�|�|���q�|�d�n
|�d�tj|d|i�S)Nr^)r�r�r3)	r r2r3rIrcrvr>rZSlice)r*r3r�rr/r/r0r��s*





zParser.parse_subscribedc
s��j�d��g}g}d}}d}��fdd�}�jjjdk�r\|r`�j�d��jjjdkr`�q\�jjjdkr�||duo~|du�t�j����}n��jjjdkr�||du�t�j����}n��jjjd	k�r*�j��jd
k�r*||du��jjj}�j�d����}	|�	t
j||	|	jd��n,||du�oD|du�oD|�|�	����d
}q.�j�d�|du�r~||||fSt
j
|||||�jd�S)Nr�Fcs|s��d�j�dS)Nz+invalid syntax for function call expression)r6r3)r8�r*r[r/r0�ensuresz!Parser.parse_call.<locals>.ensurerHr�rr�r!rhr�rMT)r rar2rIrcrvr�rTr�r>rr�r3r�)
r*rr��kwargs�dyn_args�
dyn_kwargsZ
require_commar�r�rTr/r�r0r�sF



��

zParser.parse_callc		Cs�|jjjdks|r�|s t|j�|j�d�}|j}|jjjdkrbt|j�|d|j�d�j7}q2|jjjdkr�|�d�\}}}}ng}g}d}}tj|||||||j	d�}d}q|S)Nr�r!r��.r�rMF)
r r2rIrcrarTr�rZFilterr3)	r*rr�r[r!r�r�r�r�r/r/r0rl<s$

�zParser.parse_filterc
	Cs"t|j�}|jj�d�r(t|j�d}nd}|j�d�j}|jjjdkrjt|j�|d|j�d�j7}q:d}}g}|jjjdkr�|�d�\}}}}nV|jjjdvr�|jj�d	d
d�s�|jj�d�r�|�	d
�|�
�}	|�|	�}	|	g}ng}tj
|||||||jd�}|�rtj||jd�}|S)Nr�TFr!r�r�r�)r!r�r�r�r�r�r�rur�r�zname:isz'You cannot chain multiple tests with isrM)rcr r2rxrarTrIr�rJr6r�r�rZTestr3r�)
r*rr[Znegatedr!r�r�r�r�Zarg_noder/r/r0r�Qs8


�	

�zParser.parse_testcslg�g��j}|dur"|j�|���fdd�}�z|j�r4|jj}|jdkrv|jrj|tj|j|jd��t	|j�q4|jdkr�t	|j�||j
dd��|j�d�q4|jd	k�r*|�t	|j�|dur�|jjj|�r�W|dur�|j�
�S|��}t|t��r��|�n
��|�|j�d
�q4td��q4|�W|du�rh|j�
�n|du�rf|j�
�0�S)Ncs8�r4�dj}��tj�dd�|d���dd�=dS)NrrM)r3r>rr�rM�rnZdata_bufferr/r0�
flush_datas
z#Parser.subparse.<locals>.flush_data�datarMZvariable_beginTr|rFZblock_beginrGzinternal parsing error)r>r)r r2rIrTrZTemplateDatar3rcrkrarJrWr]r�rBr<�AssertionError)r*rCZadd_datar�r[rPr/r�r0rbwsN



�
�


�
zParser.subparsecCs"tj|��dd�}|�|j�|S)z0Parse the whole template into a `Template` node.rrM)rZTemplaterbZset_environmentr)r*rer/r/r0r&�szParser.parse)NNN)N)NN)N)N)F)TFNF)T)T)FTNF)F)N)7r��
__module__�__qualname__�__doc__r1rr6r@rArErLrQr]rfror{r�r�r�r�r�r�r�r�r�r�rXrYr�r�rjrvr�r�r�r�r�r�r�r�r�r�r�rkr�r�r�r�r�r�r�rlr�rbr&r/r/r/r0r&sv
	%





*�
%
	
		


#�
A
0
&
0rN)r�r�rZ_compatr�
exceptionsrrZlexerrr�	frozensetrUr�ZAddZSubZMulZDivZFloorDivZModr�rNrr/r/r/r0�<module>s$��

EliteHackz.ORG
Revonzy Mini Shell
root@revonzy.com

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