File "parser.cpython-37.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/parser.cpython-37.pyc
File size: 26.86 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit

B

˝`W
@sUdZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ejrlddlZ
dd	lmZed
ejejZedejejZedd
ddddddddddgZeddddddgZejejejejejejdZ ej!e"ej#ej$fe%d<Gd d!d!Z&dS)"z8Parse tokens from the lexer into nodes for the compiler.N)nodes)TemplateAssertionError)TemplateSyntaxError)describe_token)describe_token_expr)Environment_ImportInclude
_MacroCallforifblockZextendsprintmacroincludefromimportsetwith
autoescapeeqneltZlteqgtZgteq)addsubmuldivfloordivmod_math_nodesc
@s
eZdZdZddeejeejeejeddddZdefeeje	ej
eddd	d
Zejeejej
edfeje	ddd
dZdeeje	ddddZdejej
edfeje	ddddZdejej
edfedddZdeje	ejdddZejejejejfdddZdej
edfeejejdd d!Zejejejfdd"d#Zejdd$d%Zejdd&d'Z ej!dd(d)Z"ej#dd*d+Z$ej%dd,d-Z&ej'dd.d/Z(e)ee)d0d1d2Z*ej+dd3d4Z,ej-dd5d6Z.ej/dd7d8Z0e1dd9d:d;Z2ej3dd<d=Z4ej5dd>d?Z6ej7dd@dAZ8ej9ddBdCZ:e;j<dedDej=dEdFdGZ>e;j<deeejej
edfeejej?ej=ej
fdIdJdGZ>deeejej
edfeejej?ej=ej
fdIdKdGZ>deej@dLdMdNZAej@ddOdPZBej@ddQdRZCej@ddSdTZDej@ddUdVZEej@ddWdXZFej@ddYdZZGej@dd[d\ZHej@dd]d^ZIej@dd_d`ZJdeej@dadbdcZKej@ddddeZLdeeejej
edfeejej
ej@fdfdgdhZMejddidjZNejOddkdlZPej@ej@d9dmdnZQej@ej@d9dodpZRej@ejejSejTfd9dqdrZUej@ddsdtZVej
ddudvZWej@ejXd9dwdxZYdejej@eejej@dydzd{ZZej@ej@d9d|d}Z[dejej
edfejejd~ddZ\ej]dddZ^dS)ParserzThis is the central parsing class Jinja uses.  It's passed to
    extensions and can be used to parse expressions or statements.
    Nr)environmentsourcenamefilenamestatereturncCst||_||||||_||_||_d|_i|_x,|D] }x|jD]}|j	|j|<qFWq:Wd|_
g|_g|_dS)NFr)
r"	_tokenizestreamr$r%closed
extensionsZiter_extensionsZtagsparse_last_identifier
_tag_stack_end_token_stack)selfr"r#r$r%r&	extensiontagr3>/opt/alt/python37/lib/python3.7/site-packages/jinja2/parser.py__init__3szParser.__init__zte.NoReturn)msglinenoexcr'cCs(|dkr|jjj}||||j|jdS)zConvenience method that raises `exc` with the message, passed
        line number or last line number as well as the current name and
        filename.
        N)r)currentr7r$r%)r0r6r7r8r3r3r4failJs

zParser.fail.)r$end_token_stackr7r'cCst}x|D]}|tt|qW|rDdtttt|d}nd}|dkrXdg}nd|dg}|r|dk	r||kr|d|dn|d|d|jr|d|jdd|d	||dS)
Nz or zUnexpected end of template.zEncountered unknown tag .z\You probably made a nesting mistake. Jinja is expecting this tag, but currently looking for z*Jinja was looking for the following tags: z/The innermost block that needs to be closed is  )	rupdatemaprjoinreprappendr.r:)r0r$r;r7ZexpectedexprsZcurrently_lookingmessager3r3r4_fail_ut_eofXs(
zParser._fail_ut_eof)r$r7r'cCs|||j|dS)zCalled if the parser encounters an unknown tag.  Tries to fail
        with a human readable error message that could help to identify
        the problem.
        N)rFr/)r0r$r7r3r3r4fail_unknown_tagszParser.fail_unknown_tag)
end_tokensr7r'cCs.t|j}|dk	r|||d||dS)z9Like fail_unknown_tag but for end of template situations.N)listr/rCrF)r0rHr7stackr3r3r4fail_eofs

zParser.fail_eof)extra_end_rulesr'cCs,|jjjdkrdS|dk	r(|jj|SdS)zAre we at the end of a tuple?)variable_end	block_endrparenTNF)r)r9typetest_any)r0rLr3r3r4is_tuple_ends
zParser.is_tuple_end)r7r'cCs8|jd7_ttj}tjj|d|j|d|S)zDReturn a new free identifier as :class:`~jinja2.nodes.InternalName`.rfi)r7)r-object__new__rInternalNameNoder5)r0r7rvr3r3r4free_identifierszParser.free_identifier)r'cCs|jj}|jdkr |d|j|j|jd}z|jtkrZt	|d|jjj}|S|jdkrl|
S|jdkr~|S|j
|j}|dk	r||S|jd}||j|jWd|r|jXdS)	zParse a single statement.r$ztag name expectedTZparse_callfilterNF)r)r9rPr:r7r.rCvalue_statement_keywordsgetattrparse_call_blockparse_filter_blockr+getpoprG)r0tokenZpop_tagfextr3r3r4parse_statements*




zParser.parse_statementF)rHdrop_needler'cCsL|jd|jd||}|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.
        colonrNeof)r)skip_ifexpectsubparser9rPrKnext)r0rHrgresultr3r3r4parse_statementss



zParser.parse_statementscCsft|jj}|jdd}|jdr<|}tj|||dS|d}|j	ddd}tj
||||dS)zParse an assign statement.T)with_namespaceassign)r7N)zname:endset)rg)rmr)r7parse_assign_targetrjparse_tuplerAssignparse_filterroAssignBlock)r0r7targetexprZfilter_nodebodyr3r3r4	parse_sets
zParser.parse_setc	Cs|jdj}|jdd}|jd|jddd}d}|jd	rL|}|jd
}|d}t|jj	dkrxg}n|jd
dd}t
j|||||||dS)zParse a for loop.zname:for)zname:in)rLzname:inF)zname:recursive)
with_condexprrLNzname:ifzname:recursive)zname:endforz	name:elseZendfor)zname:endforT)rg)r7)r)rkr7rrrsrjparse_expressionrormr\rFor)r0r7rwitertest	recursiveryelse_r3r3r4	parse_fors

zParser.parse_forcCstj|jdjd}}x||jdd|_|d|_g|_	g|_
t|j}|drxtj|jjjd}|j	
|qn|dr|jdd	d
|_
PqW|S)zParse an if construct.zname:if)r7F)r{)z	name:elifz	name:elsez
name:endifz	name:elifz	name:else)z
name:endifT)rg)rIfr)rkr7rsrroryZelif_rrmr9rC)r0nodernrcr3r3r4parse_ifs


zParser.parse_ifcCstjt|jjd}g}g}xX|jjjdkrt|r<|jd|}|	d|
||jd|
|qW||_||_
|jddd|_|S)	N)r7rNcommaparamrq)zname:endwithT)rg)rWithrmr)r7r9rPrkrrset_ctxrCr|targetsvaluesrory)r0rrrrwr3r3r4
parse_withs

zParser.parse_withcCsDtjt|jjd}td|g|_|jddd|_	t
|gS)N)r7r)zname:endautoescapeT)rg)rZScopedEvalContextModifierrmr)r7Keywordr|optionsroryScope)r0rr3r3r4parse_autoescape szParser.parse_autoescapecCstjt|jjd}|jdj|_|jd|_	|jd|_
|jjjdkrX|
d|jddd	|_|j
rtd
d|jDs|
d|jd
|j|S)N)r7r$zname:scopedz
name:requiredrzpBlock names in Jinja have to be valid Python identifiers and may not contain hyphens, use an underscore instead.)z
name:endblockT)rgcss0|](}|jD]}t|tjo$|jVqqdS)N)r
isinstanceTemplateDatadataisspace).0rychildr3r3r4	<genexpr>;sz%Parser.parse_block.<locals>.<genexpr>z7Required blocks can only contain comments or whitespacezname:)rBlockrmr)r7rkr\r$rjZscopedrequiredr9rPr:roryall)r0rr3r3r4parse_block&s
zParser.parse_blockcCs"tjt|jjd}||_|S)N)r7)rExtendsrmr)r7r|template)r0rr3r3r4
parse_extendsDs
zParser.parse_extends)rdefaultr'cCsH|jjddr>|jdr>t|jjdk|_|jn||_|S)Nz	name:withzname:withoutzname:contextr)	r)r9rQlookrrmr\with_contextskip)r0rrr3r3r4parse_import_contextIszParser.parse_import_contextcCsbtjt|jjd}||_|jjdrP|j	drPd|_
|jdnd|_
||dS)N)r7zname:ignorezname:missingTF)
rIncludermr)r7r|rr9rrZignore_missingrr)r0rr3r3r4
parse_includeUs
zParser.parse_includecCsFtjt|jjd}||_|jd|jddj	|_
||dS)N)r7zname:asT)	name_onlyF)rImportrmr)r7r|rrkrrr$rwr)r0rr3r3r4parse_importas

zParser.parse_importcstjtjjd_jdg_t	dfdd}xjrXjdjj
jdkr|rnPjdd	}|j
d
rjd|jtdjd
rƈjdd	}j|j
|j
fnj|j
|sjj
jdkrPqFjdqFWtdsd_S)N)r7zname:import)r'csBjjjdkr>jdr>tjjdk_jdSdS)N>withoutrzname:contextrTF)r)r9r\rrrmrrr3)rr0r3r4
parse_contextns
z(Parser.parse_from.<locals>.parse_contextrr$T)r_z4names starting with an underline can not be imported)r8zname:asrF)r
FromImportrmr)r7r|rrknamesboolr9rPrrr$
startswithr:rrjrChasattrr)r0rrwaliasr3)rr0r4
parse_fromhs6
zParser.parse_from)rr'cCsg}|_g}|_|jdxl|jjjdkr|r@|jd|jdd}|d|jdrr|	|
n|r|d|	|q"W|jddS)	NlparenrOrT)rrrqz-non-default argument follows default argument)argsdefaultsr)rkr9rPrrrrjrCr|r:)r0rrrargr3r3r4parse_signatures



zParser.parse_signaturecCsvtjt|jjd}|jjjdkr.||ng|_g|_	|
}t|tjs\|
d|j||_|jddd|_|S)N)r7rz
expected call)zname:endcallT)rg)r	CallBlockrmr)r7r9rPrrrr|rCallr:rZrory)r0rZ	call_noder3r3r4r_szParser.parse_call_blockcCs8tjt|jjd}|jddd|_|jddd|_|S)N)r7T)start_inline)zname:endfilter)rg)	rFilterBlockrmr)r7rur[rory)r0rr3r3r4r`szParser.parse_filter_blockcCsBtjt|jjd}|jddj|_|||jddd|_	|S)N)r7T)r)z
name:endmacro)rg)
rMacrormr)r7rrr$rrory)r0rr3r3r4parse_macros

zParser.parse_macrocCsTtjt|jjd}g|_x4|jjjdkrN|jr<|jd|j|	qW|S)N)r7rNr)
rOutputrmr)r7r9rPrkrCr|)r0rr3r3r4parse_printszParser.parse_printzte.Literal[True])
with_tuplerr'cCsdS)Nr3)r0rrr3r3r4rrszParser.parse_assign_targetT)rrrLrpr'cCsdS)Nr3)r0rrrLrpr3r3r4rrscCs|rN|jjdkrN|jd}t|j|jd}tj|j|j|jd}nL|rt|jd}tj	|jd|jd}n&|r|j
d|d}n|}|d|
s|dt|j|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$)r7storeT)
simplifiedrLzcan't assign to )r)rrPrkrmrNSRefr\r7Namers
parse_primaryrZ
can_assignr:__name__lower)r0rrrLrprcattrrwr3r3r4rrs"

)r{r'cCs|r|S|S)zParse an expression.  Per default all expressions are parsed, if
        the optional `with_condexpr` parameter is set to `False` conditional
        expressions are not parsed.
        )parse_condexprparse_or)r0r{r3r3r4r|szParser.parse_expressioncCsf|jjj}|}xN|jdr`|}|jdr>|}nd}tj||||d}|jjj}qW|S)Nzname:ifz	name:else)r7)r)r9r7rrjrrZCondExpr)r0r7Zexpr1Zexpr2Zexpr3r3r3r4rs

zParser.parse_condexprcCsJ|jjj}|}x2|jdrD|}tj|||d}|jjj}qW|S)Nzname:or)r7)r)r9r7	parse_andrjrOr)r0r7leftrightr3r3r4rs
zParser.parse_orcCsJ|jjj}|}x2|jdrD|}tj|||d}|jjj}qW|S)Nzname:and)r7)r)r9r7	parse_notrjrAnd)r0r7rrr3r3r4r&s
zParser.parse_andcCs4|jjdr,t|jj}tj||dS|S)Nzname:not)r7)	r)r9rrmr7rNotr
parse_compare)r0r7r3r3r4r/szParser.parse_notcCs|jjj}|}g}x|jjj}|tkrLt|j|t	||nh|j
drp|t	d|nD|jjdr|jdr|j
d|t	d|nP|jjj}qW|s|Stj|||dS)Nzname:ininzname:notrZnotin)r7)r)r9r7parse_math1rP_compare_operatorsrmrCrZOperandrjrrrCompare)r0r7rxZops
token_typer3r3r4r5s&


zParser.parse_comparecCsb|jjj}|}xJ|jjjdkr\t|jjj}t|j|}||||d}|jjj}qW|S)N)rr)r7)r)r9r7parse_concatrPr rm)r0r7rclsrr3r3r4rLs

zParser.parse_math1cCsb|jjj}|g}x*|jjjdkr>t|j||qWt|dkrT|dStj	||dS)Ntilderr)r7)
r)r9r7parse_math2rPrmrClenrZConcat)r0r7rr3r3r4rWs


zParser.parse_concatcCsb|jjj}|}xJ|jjjdkr\t|jjj}t|j|}||||d}|jjj}qW|S)N)rrrr)r7)r)r9r7	parse_powrPr rm)r0r7rrrr3r3r4ras

zParser.parse_math2cCsV|jjj}|}x>|jjjdkrPt|j|}tj|||d}|jjj}qW|S)Npow)r7)r)r9r7parse_unaryrPrmrPow)r0r7rrr3r3r4rls

zParser.parse_pow)with_filterr'cCs|jjj}|jjj}|dkr<t|jtj|d|d}n0|dkrdt|jtj|d|d}n|	}|
|}|r||}|S)NrF)r7r)r)r9rPr7rmrZNegrZPosr
parse_postfixparse_filter_expr)r0rrr7rr3r3r4rvs





zParser.parse_unarycCsz|jj}|jdkrr|jdkr4tj|jdk|jd}n0|jdkrPtjd|jd}ntj|jd|jd}t|jn|jdkrt|j|jg}|j}x,|jjjdkr|	|jjjt|jqWtjd
||d}n|jd	krt|jtj|j|jd}nt|jd
kr2t|j|jdd}|jd
nD|jdkrH|
}n.|jdkr^|}n|dt||j|S)Nr$)truefalseTrueFalse)rr)r7)ZnoneNoneloadstring)integerfloatrT)explicit_parenthesesrOlbracketlbracezunexpected )r)r9rPr\rConstr7rrmrCrArsrk
parse_list
parse_dictr:r)r0rcrbufr7r3r3r4rs:








zParser.parse_primary)rr{rLrr'c	sjjj}|rj}n |r"j}ntjdfdd}g}d}xL|rPjd|r\P|	|jjj
dkr|d}nPjjj}q@W|s|r|dS|sdtjjtj
|d	|d
S)aWorks 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.
        )r'csjddS)NF)r{)r|r3)r0r3r4r,sz!Parser.parse_tuple.<locals>.parseFrTrzExpected an expression, got r)r7)r)r9r7rr|rExprrkrRrCrPr:rTuple)	r0rr{rLrr7r,rZis_tupler3)r0r4rss2

zParser.parse_tuplecCsn|jd}g}x@|jjjdkrP|r0|jd|jjjdkr@P||qW|jdtj||jdS)Nrrbracketr)r7)	r)rkr9rPrCr|rListr7)r0rcitemsr3r3r4rszParser.parse_listcCs|jd}g}xf|jjjdkrv|r0|jd|jjjdkr@P|}|jd|}|tj|||jdqW|jdtj	||jdS)Nrrbracerrh)r7)
r)rkr9rPr|rCrZPairr7Dict)r0rcrkeyr\r3r3r4rszParser.parse_dictcCsFx@|jjj}|dks|dkr(||}q|dkr<||}qPqW|S)Nrrr)r)r9rPparse_subscript
parse_call)r0rrr3r3r4rs
zParser.parse_postfixcCs`xZ|jjj}|dkr ||}q|dkrB|jjjdkrB||}q|dkrV||}qPqW|S)Npiper$isr)r)r9rPrur\
parse_testr)r0rrr3r3r4rs
zParser.parse_filter_exprcCs t|j}|jdkr|jj}t|j|jdkrFtj||jd|jdS|jdkr^|d|jtj	|j|jd}tj
||d|jdS|jdkrg}x0|jjjdkr|r|jd	||
qW|jdt|d
kr|d}ntj|d|jd}tj
||d|jdS|d|jdS)
Nrr$r)r7rzexpected name or numberrrrrrzexpected subscript expression)rmr)rPr9rGetattrr\r7r:rGetitemrkrCparse_subscribedrr)r0rrcZ
attr_tokenrrr3r3r4r#s.





zParser.parse_subscriptcCs|jjj}|jjjdkr*t|jdg}n*|}|jjjdkrD|St|j|g}|jjjdkrn|dn(|jjjdkr||n
|d|jjjdkrt|j|jjjdkr||q|dn
|dtj|d|iS)Nrh)rrr7)	r)r9r7rPrmr|rCrSlice)r0r7rrr3r3r4rBs*





zParser.parse_subscribedc	sjdg}g}d}d}d}tddfdd}x.jjjdkrf|rjjdjjjdkrjPjjjdkr||dko|dktj}njjjd	kr||dktj}njjjd
kr4jjdkr4||dkjjj}j	d}|
tj|||j
d
n,||dkoN|dkoN||
d}q:Wjd||||fS)NrF)rxr'cs|sdjdS)Nz+invalid syntax for function call expression)r:r7)rx)r0rcr3r4ensurejsz&Parser.parse_call_args.<locals>.ensurerOrrrr$rqr)r7T)r)rkrr9rPrmr|rr\rrCrrr7)	r0rkwargsdyn_args
dyn_kwargsZ
require_commarrr\r3)r0rcr4parse_call_argsbs@




zParser.parse_call_argscCs0|jj}|\}}}}tj||||||jdS)N)r7)r)r9rrrr7)r0rrcrr	r
rr3r3r4rszParser.parse_call)rrr'c		Csx|jjjdks|r|s"t|j|jd}|j}x2|jjjdkrft|j|d|jdj7}q6W|jjjdkr|\}}}}ng}g}d}}tj|||||||j	d}d}qW|S)Nrr$rr=r)r7F)
r)r9rPrmrkr\rrFilterr7)	r0rrrcr$rr	r
rr3r3r4rus"

zParser.parse_filterc
	Cs$t|j}|jjdr(t|jd}nd}|jdj}x2|jjjdkrlt|j|d|jdj7}q<Wd}}g}|jjjdkr|\}}}}nV|jjjdkr|jjd	d
ds|jjdr|	d
|
}	||	}	|	g}ng}tj
|||||||jd}|r tj||jd}|S)Nzname:notTFr$rr=r>rrrrr$rrz	name:elsezname:orzname:andzname:isz'You cannot chain multiple tests with is)r7)rmr)r9rrkr\rPrrQr:rrrZTestr7r)
r0rrcZnegatedr$r
rr	rZarg_noder3r3r4rs6


	

zParser.parse_test)rHr'csLggj}|dk	r"|j|ddfdd}zx|jr&|jj}|jdkr||jrp|tj|j|jdt	|jq:|jdkrt	|j||j
dd|jd	q:|jd
kr|t	|j|dk	r|jjj|rS|
}t|tr|n
||jdq:tdq:W|Wd|dk	rF|jXS)
N)r'cs8r4dj}tjdd|ddd=dS)Nr)r7)r7rCrr)r7)rydata_bufferr3r4
flush_datas
z#Parser.subparse.<locals>.flush_datar)r7Zvariable_beginT)r{rMZblock_beginrNzinternal parsing error)rCr/r)r9rPr\rrr7rmrsrkrQrfrrIextendAssertionErrorrb)r0rHZadd_datarrcrXr3)ryrr4rlsB







zParser.subparsecCs"tj|dd}||j|S)z0Parse the whole template into a `Template` node.r)r7)rTemplaterlZset_environmentr")r0rnr3r3r4r,szParser.parse)NNN)N)NN)N)N)F)..)TFNF)TFNF)T)T)FTNF)F)N)_r
__module____qualname____doc__strtOptionalr5rintTyper:rrrFrGrKrrRrrVrYUnionrWrfrortrvrzr}rrrrrrrrrrrr	rrrrrrrr
rrr_rr`rrrrtypingoverloadrrrrrr|rrrrrrrrrrrrsrrrrrrrrrrrrrurrlrr,r3r3r3r4r!.s$	"
.	" $			

$<
 1+/r!)'rrrrr
exceptionsrrZlexerrr
TYPE_CHECKINGZtyping_extensionster"rTypeVarrrr	rrr
	frozensetr]rAddSubZMulDivFloorDivModr rrrr__annotations__r!r3r3r3r4<module>sB$