/usr/local/lib/python3.6/site-packages/jinja2/__pycache__
NameSizeModeActions
async_utils.cpython-36.pyc24350644editdlrm
bccache.cpython-36.pyc130970644editdlrm
compiler.cpython-36.pyc543690644editdlrm
constants.cpython-36.pyc14960644editdlrm
debug.cpython-36.pyc53440644editdlrm
defaults.cpython-36.pyc12410644editdlrm
environment.cpython-36.pyc523970644editdlrm
exceptions.cpython-36.pyc54980644editdlrm
ext.cpython-36.pyc262740644editdlrm
filters.cpython-36.pyc497540644editdlrm
idtracking.cpython-36.pyc111250644editdlrm
lexer.cpython-36.pyc199830644editdlrm
loaders.cpython-36.pyc202170644editdlrm
meta.cpython-36.pyc37460644editdlrm
nativetypes.cpython-36.pyc48050644editdlrm
nodes.cpython-36.pyc411930644editdlrm
optimizer.cpython-36.pyc18610644editdlrm
parser.cpython-36.pyc276350644editdlrm
runtime.cpython-36.pyc328630644editdlrm
sandbox.cpython-36.pyc116960644editdlrm
tests.cpython-36.pyc64820644editdlrm
utils.cpython-36.pyc272170644editdlrm
visitor.cpython-36.pyc38390644editdlrm
_identifier.cpython-36.pyc18500644editdlrm
__init__.cpython-36.pyc18650644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/jinja2/__pycache__/parser.cpython-36.pyc (27635B)
3 ^TBgW @s UdZddlZddlZddlmZddlmZddlmZddlm Z ddlm Z ej rlddl Z dd lmZejd ejejZejd ejejZed d ddddddddddg ZeddddddgZejejejejejejdZ ej!e"ej#ej$f Gdd 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)addsubmuldivfloordivmodc @s eZdZdZddeejeejeejeddddZdefeeje ej eddd d Z ejeej ej ed feje dd d dZdeeje ddddZdejej ed feje ddddZdejej ed fedddZdeje ejdddZejejej ejfdddZdej ed feej 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;Z2ej3ddd?Z6ej7dd@dAZ8ej9ddBdCZ:e;je;jdeeejej ed feejej?ej=ej fdIdKdGZ>deej@dLdMdNZAej@ddOdPZBej@ddQdRZCej@ddSdTZDej@ddUdVZEej@ddWdXZFej@ddYdZZGej@dd[d\ZHej@dd]d^ZIej@dd_d`ZJdeej@dadbdcZKej@ddddeZLdeeejej ed feejej ej@fdfdgdhZMej ddidjZNejOddkdlZPej@ej@d9dmdnZQej@ej@d9dodpZRej@ejejSejTfd9dqdrZUej@ddsdtZVej ddudvZWej@ejXd9dwdxZYdejej@eejej@dydzd{ZZej@ej@d9d|d}Z[dejej ed fej 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||_|j|||||_||_||_d|_i|_x,|jD] }x|jD]}|j |j|<qFWq:Wd|_ g|_ g|_ dS)NFr) r! _tokenizestreamr#r$closed extensionsZiter_extensionstagsparse_last_identifier _tag_stack_end_token_stack)selfr!r"r#r$r% extensiontagr3//tmp/pip-build-0s3hx122/Jinja2/jinja2/parser.py__init__3s zParser.__init__z te.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  z Parser.fail.)r#end_token_stackr7r&cCst}x|D]}|jtt|q W|rDdjtttt|d }nd}|dkrXdg}nd|dg}|r|dk r||kr|jd|dn|jd|d|jr|jd|jd d|jd j||dS) Nz or rzUnexpected 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  r>) rupdatemaprjoinreprappendr.r:)r0r#r;r7expectedexprsZcurrently_lookingmessager3r3r4 _fail_ut_eofXs( zParser._fail_ut_eof)r#r7r&cCs|j||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)rGr/)r0r#r7r3r3r4fail_unknown_tagszParser.fail_unknown_tag) end_tokensr7r&cCs.t|j}|dk r|j||jd||dS)z9Like fail_unknown_tag but for end of template situations.N)listr/rCrG)r0rIr7stackr3r3r4fail_eofs  zParser.fail_eof)extra_end_rulesr&cCs,|jjjdkrdS|dk r(|jjj|SdS)zAre we at the end of a tuple? variable_end block_endrparenTNF)rNrOrP)r(r9typetest_any)r0rMr3r3r4 is_tuple_ends zParser.is_tuple_end)r7r&cCs8|jd7_tjtj}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&c Cs|jj}|jdkr |jd|j|jj|jd}z|jtkrZt |d|jjj}|S|jdkrl|j S|jdkr~|j S|j j |j}|dk r||S|jjd}|j|j|jWd|r|jjXdS) zParse a single statement.r#ztag name expectedTZparse_callfilterNF)r(r9rQr:r7r.rCvalue_statement_keywordsgetattrparse_call_blockparse_filter_blockr*getpoprH)r0tokenZpop_tagfextr3r3r4parse_statements*     zParser.parse_statementF)rI drop_needler&cCsL|jjd|jjd|j|}|jjjdkr:|j||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. colonrOeof)r(skip_ifexpectsubparser9rQrLnext)r0rIrhresultr3r3r4parse_statementss     zParser.parse_statementscCsft|jj}|jdd}|jjdr<|j}tj|||dS|jd}|j ddd}tj ||||dS) zParse an assign statement.T)with_namespaceassign)r7N name:endset)rh)rs) rnr(r7parse_assign_targetrk parse_tuplerAssign parse_filterrp AssignBlock)r0r7targetexprZ filter_nodebodyr3r3r4 parse_sets    zParser.parse_setc Cs|jjdj}|jdd}|jjd|jddd}d}|jjdrL|j}|jjd}|jd}t|jj d krxg}n|jdd d }t j |||||||dS)zParse a for loop.zname:forname:in)rMFname:recursive) with_condexprrMNzname:if name:endfor name:elseZendforT)rh)r7)r})r~)rr)r) r(rlr7rtrurkparse_expressionrprnr]rFor)r0r7ryitertest recursiver{else_r3r3r4 parse_fors      zParser.parse_forcCstj|jjdjd}}x||jdd|_|jd |_g|_ g|_ t |j}|jdrxtj|jj jd}|j j |qn|jdr|jd dd |_ PqW|S) zParse an if construct.zname:if)r7F)r name:elif name:else name:endifT)rh)rrr)r)rIfr(rlr7rurrpr{Zelif_rrnr9rC)r0noderordr3r3r4parse_ifs     zParser.parse_ifcCstjt|jjd}g}g}xX|jjjdkrt|r<|jjd|j}|j d|j ||jjd|j |j qW||_ ||_ |jd dd|_|S) N)r7rOcommaparamrr name:endwithT)rh)r)rWithrnr(r7r9rQrlrtset_ctxrCrtargetsvaluesrpr{)r0rrrryr3r3r4 parse_withs    zParser.parse_withcCsDtjt|jjd}tjd|jg|_|jddd|_ tj |gS)N)r7rname:endautoescapeT)rh)r) rZScopedEvalContextModifierrnr(r7Keywordroptionsrpr{Scope)r0rr3r3r4parse_autoescape szParser.parse_autoescapecCstjt|jjd}|jjdj|_|jjd|_ |jjd|_ |jj j dkrX|j d|jddd |_|j rtd d |jD r|j d |jjd |j|S)N)r7r#z name:scopedz name:requiredrzpBlock names in Jinja have to be valid Python identifiers and may not contain hyphens, use an underscore instead. name:endblockT)rhcss0|](}|jD]}t|tjo$|jjVq qdS)N)r isinstance TemplateDatadataisspace).0r{childr3r3r4 ;sz%Parser.parse_block..z7Required blocks can only contain comments or whitespacezname:)r)rBlockrnr(r7rlr]r#rkscopedrequiredr9rQr:rpr{all)r0rr3r3r4 parse_block&s zParser.parse_blockcCs"tjt|jjd}|j|_|S)N)r7)rExtendsrnr(r7rtemplate)r0rr3r3r4 parse_extendsDs zParser.parse_extends)rdefaultr&cCsH|jjjddr>|jjjdr>t|jjdk|_|jjn||_|S)Nz name:withz name:withoutz name:contextr) r(r9rRlookrrnr] with_contextskip)r0rrr3r3r4parse_import_contextIs zParser.parse_import_contextcCsbtjt|jjd}|j|_|jjjdrP|jj jdrPd|_ |jj dnd|_ |j |dS)N)r7z name:ignorez name:missingTF) rIncludernr(r7rrr9rrZignore_missingrr)r0rr3r3r4 parse_includeUs zParser.parse_includecCsFtjt|jjd}|j|_|jjd|jddj |_ |j |dS)N)r7zname:asT) name_onlyF) rImportrnr(r7rrrlrtr#ryr)r0rr3r3r4 parse_importas   zParser.parse_importcstjtjjdj_jjdg_t dfdd }xjrXjjdjj j dkr|rnPj dd }|j jd rjd |jtd jjd rƈj dd }jj|j |j fnjj|j |sjj j dkrPqFjjdqFWtdsd_S)N)r7z name:import)r&csBjjjdkr>jjjdr>tjjdk_jjdSdS)Nrwithoutz name:contextTF>rr)r(r9r]rrrnrrr3)rr0r3r4 parse_contextns z(Parser.parse_from..parse_contextrr#T)r_z4names starting with an underline can not be imported)r8zname:asrF)r FromImportrnr(r7rrrlnamesboolr9rQrtr# startswithr:rrkrChasattrr)r0rryaliasr3)rr0r4 parse_fromhs6        zParser.parse_from)rr&cCsg}|_g}|_|jjdxl|jjjdkr|r@|jjd|jdd}|jd|jjdrr|j |j n|r|j d|j |q"W|jjddS) NlparenrPrT)rrrrz-non-default argument follows default argument) argsdefaultsr(rlr9rQrtrrkrCrr:)r0rrrargr3r3r4parse_signatures        zParser.parse_signaturecCsvtjt|jjd}|jjjdkr.|j|n g|_g|_ |j }t |tj s\|j d|j||_|jddd|_|S)N)r7rz expected call name:endcallT)rh)r)r CallBlockrnr(r7r9rQrrrrrCallr:r[rpr{)r0rZ call_noder3r3r4r`s  zParser.parse_call_blockcCs8tjt|jjd}|jddd|_|jddd|_|S)N)r7T) start_inlinename:endfilter)rh)r) r FilterBlockrnr(r7rwr\rpr{)r0rr3r3r4raszParser.parse_filter_blockcCsBtjt|jjd}|jddj|_|j||jddd|_ |S)N)r7T)r name:endmacro)rh)r) rMacrornr(r7rtr#rrpr{)r0rr3r3r4 parse_macros  zParser.parse_macrocCsTtjt|jjd}g|_x4|jjjdkrN|jr<|jjd|jj|j qW|S)N)r7rOr) rOutputrnr(r7r9rQrlrCr)r0rr3r3r4 parse_prints zParser.parse_printzte.Literal[True]) with_tuplerr&cCsdS)Nr3)r0rrr3r3r4rtszParser.parse_assign_targetT)rrrMrqr&cCsdS)Nr3)r0rrrMrqr3r3r4rtscCs|rN|jjjdkrN|jjd}t|j|jjd}tj|j|j|jd}nL|rt|jjd}tj |jd|jd}n&|r|j d|d}n|j }|j d|j s|jdt|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#)r7storeT) simplifiedrMzcan't assign to )r(rrQrlrnrNSRefr]r7Nameru parse_primaryrZ can_assignr:__name__lower)r0rrrMrqrdattrryr3r3r4rts"      )rr&cCs|r |jS|jS)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)r0rr3r3r4rszParser.parse_expressioncCsf|jjj}|j}xN|jjdr`|j}|jjdr>|j}nd}tj||||d}|jjj}qW|S)Nzname:ifz name:else)r7)r(r9r7rrkrrZCondExpr)r0r7Zexpr1Zexpr2Zexpr3r3r3r4rs   zParser.parse_condexprcCsJ|jjj}|j}x2|jjdrD|j}tj|||d}|jjj}qW|S)Nzname:or)r7)r(r9r7 parse_andrkrOr)r0r7leftrightr3r3r4rs zParser.parse_orcCsJ|jjj}|j}x2|jjdrD|j}tj|||d}|jjj}qW|S)Nzname:and)r7)r(r9r7 parse_notrkrAnd)r0r7rrr3r3r4r&s zParser.parse_andcCs4|jjjdr,t|jj}tj|j|dS|jS)Nzname:not)r7) r(r9rrnr7rNotr parse_compare)r0r7r3r3r4r/s zParser.parse_notcCs|jjj}|j}g}x|jjj}|tkrLt|j|jtj ||jnh|jj drp|jtj d|jnD|jjj dr|jj j dr|jj d|jtj d|jnP|jjj}qW|s|Stj|||dS)Nzname:ininzname:notrnotin)r7)r(r9r7 parse_math1rQ_compare_operatorsrnrCrZOperandrkrrrZCompare)r0r7rzops token_typer3r3r4r5s&     zParser.parse_comparecCsb|jjj}|j}xJ|jjjdkr\t|jjj}t|j|j}||||d}|jjj}qW|S)Nrr)r7)rr)r(r9r7 parse_concatrQ _math_nodesrn)r0r7rclsrr3r3r4rLs  zParser.parse_math1cCsb|jjj}|jg}x*|jjjdkr>t|j|j|jqWt|dkrT|dStj ||dS)Ntilderr)r7) r(r9r7 parse_math2rQrnrClenrZConcat)r0r7rr3r3r4rWs    zParser.parse_concatcCsb|jjj}|j}xJ|jjjdkr\t|jjj}t|j|j}||||d}|jjj}qW|S)Nrrrr)r7)rrrr)r(r9r7 parse_powrQrrn)r0r7rrrr3r3r4ras  zParser.parse_math2cCsV|jjj}|j}x>|jjjdkrPt|j|j}tj|||d}|jjj}qW|S)Npow)r7)r(r9r7 parse_unaryrQrnrZPow)r0r7rrr3r3r4rls  zParser.parse_pow) with_filterr&cCs|jjj}|jjj}|dkr.parseFrTrzExpected an expression, got r)r7)r(r9r7rrrExprrlrSrCrQr:rTuple) r0rrrMrr7r,rZis_tupler3)r0r4rus2    zParser.parse_tuplecCsn|jjd}g}x@|jjjdkrP|r0|jjd|jjjdkr@P|j|jqW|jjdtj||jdS)Nrrbracketr)r7) r(rlr9rQrCrrListr7)r0rditemsr3r3r4rs   zParser.parse_listcCs|jjd}g}xf|jjjdkrv|r0|jjd|jjjdkr@P|j}|jjd|j}|jtj|||jdqW|jjdtj ||jdS)NrZrbracerri)r7) r(rlr9rQrrCrZPairr7Dict)r0rdr keyr]r3r3r4rs    zParser.parse_dictcCsFx@|jjj}|dks|dkr(|j|}q|dkr<|j|}qPqW|S)Nrrr)r(r9rQparse_subscript parse_call)r0rrr3r3r4rs   zParser.parse_postfixcCs`xZ|jjj}|dkr |j|}q|dkrB|jjjdkrB|j|}q|dkrV|j|}qPqW|S)Npiper#isr)r(r9rQrwr] parse_testr)r0rrr3r3r4rs    zParser.parse_filter_exprcCs t|j}|jdkr|jj}t|j|jdkrFtj||jd|jdS|jdkr^|jd|jtj |j|jd}tj ||d|jdS|jdkrg}x0|jjjdkr|r|jj d |j |j qW|jj dt|d kr|d }ntj|d|jd}tj ||d|jdS|jd |jdS) Nrr#r)r7rzexpected name or numberrr rrrzexpected subscript expression)rnr(rQr9rGetattrr]r7r:rGetitemrlrCparse_subscribedrr )r0rrdZ attr_tokenrrr3r3r4r#s.          zParser.parse_subscriptcCs|jjj}|jjjdkr*t|jdg}n*|j}|jjjdkrD|St|j|g}|jjjdkrn|jdn(|jjjdkr|j|jn |jd|jjjdkrt|j|jjjdkr|j|jq|jdn |jdtj|d|iS)Nrir rr7)r r)r r) r(r9r7rQrnrrCrZSlice)r0r7rrr3r3r4rBs*        zParser.parse_subscribedc s~jjdg}g}d}d}d}tddfdd }x,jjjdkrd|rjjjdjjjdkrjPjjjdkr||dko|dktjj}njjjd kr||dktjj}njjjd kojjjd kr2||dkjjj}jj d j}|j t j |||j d n,||dkoL|dkoL| |j jd}q:Wjjd||||fS)NrF)rzr&cs|sjdjdS)Nz+invalid syntax for function call expression)r:r7)rz)r0rdr3r4ensurejsz&Parser.parse_call_args..ensurerPrrrr#rrr)r7T)r(rlrr9rQrnrrr]rrCrrr7) r0rkwargsdyn_args dyn_kwargsZ require_commarrr]r3)r0rdr4parse_call_argsbs@           zParser.parse_call_argscCs0|jj}|j\}}}}tj||||||jdS)N)r7)r(r9rrrr7)r0rrdrrrrr3r3r4rszParser.parse_call)rrr&c Csx|jjjdks|r|s"t|j|jjd}|j}x2|jjjdkrft|j|d|jjdj7}q6W|jjjdkr|j\}}}}ng}g}d}}tj|||||||j d}d}qW|S)Nrr#rr<r)r7F) r(r9rQrnrlr]rrFilterr7) r0rrrdr#rrrrr3r3r4rws"   zParser.parse_filterc Cs&t|j}|jjjdr(t|jd}nd}|jjdj}x2|jjjdkrlt|j|d|jjdj7}qrrrr#rrr)rnr(r9rrlr]rQrrRr:rrrZTestr7r) r0rrdZnegatedr#rrrrZarg_noder3r3r4rsB     zParser.parse_test)rIr&c sLggj}|dk r"|jj|ddfdd }zx|jr&|jj}|jdkr||jrp|tj|j|jdt |jq:|jdkrt |j||j dd|jj d q:|jd kr|t |j|dk r|jjj |rS|j }t|trj|n j||jj d q:td q:W|Wd|dk rF|jjXS) N)r&cs8r4dj}jtjdd|ddd=dS)Nr)r7)r7rCrr)r7)r{ data_bufferr3r4 flush_datas z#Parser.subparse..flush_datar)r7Zvariable_beginT)rrNZ block_beginrOzinternal parsing error)rCr/r(r9rQr]rrr7rnrurlrRrgrrJextendAssertionErrorrc)r0rIZadd_datarrdrYr3)r{rr4rmsB               zParser.subparsecCs"tj|jdd}|j|j|S)z0Parse the whole template into a `Template` node.r)r7)rTemplatermZset_environmentr!)r0ror3r3r4r, s z Parser.parse)NNN)N)NN)N)N)F)..)TFNF)TFNF)T)T)FTNF)F)N)_r __module__ __qualname____doc__strtOptionalr5rintTyper:r r rGrHrLrrSrrWrZUnionrXrgrprvrxr|rrrrrrrrrrrrr rrrrrrrr rrr`rrarrrrtypingZoverloadrrtrr rrrrrrrrrrrrrurrrrrrrrrrrrrwrrmr"r,r3r3r3r4r .s $  "   . " $       $<   1+/r )&r%r,r'rr exceptionsrrlexerrrZ TYPE_CHECKINGZtyping_extensionster!rZTypeVarrrr rrr frozensetr^rZAddZSubZMulZDivZFloorDivZModrrr&r*r r r3r3r3r4sB