PL iMJdZddlZddlmZddlmZddlmZddlmZGddZGd d eZGd d eZ Gd deZ GddeZ GddeZ GddeZ GddeZGddeeZGddeZGddeZGddeZGd d!eZGd"d#eZGd$d%eZGd&d'eZGd(d)eZGd*d+eZy),z5defines the parse tree components for Mako templates.N)ast) exceptions)filters)utilc2eZdZdZdZedZdZdZy)Nodez(base class for a Node in the parse tree.c<||_||_||_||_yNsourcelinenoposfilename)selfr r rrs T/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mako/parsetree.py__init__z Node.__init__s    c`|j|j|j|jdS)Nr r rs rexception_kwargszNode.exception_kwargss*kkkk88   rcgSr rs r get_childrenzNode.get_children$ rchfd}td|jjz|}||y)NcR|jD]}|jyr )raccept_visitor)nodenvisitors rtraversez%Node.accept_visitor..traverse(s)&&( *  ) *rvisit)getattr __class____name__)rr r!methods ` rrzNode.accept_visitor's. *'DNN,C,C"CXNt rN) r% __module__ __qualname____doc__rpropertyrrrrrrrrs(2!   rrc.eZdZdZfdZdZdZxZS) TemplateNodez?a 'container' node that stores the overall collection of nodes.cFt|ddd|g|_i|_y)Nr)superrnodespage_attributes)rrr$s rrzTemplateNode.__init__4s% Q8, !rc|jSr r0rs rrzTemplateNode.get_children9 zzrcbdtj|jd|jdS)Nz TemplateNode(, ))rsorted_dict_reprr1r0rs r__repr__zTemplateNode.__repr__<s'  ! !$"6"6 7 JJ  r)r%r'r(r)rrr9 __classcell__r$s@rr,r,0sI"  rr,cDeZdZdZdZfdZdZdZdZdZ dZ xZ S) ControlLinezdefines a control line, a line-oriented python line or end tag. e.g.:: % if foo: (markup) % endif Fc (t|di|||_||_||_|dv|_g|_|jrg|_g|_ytj|fi|j}|j|_|j|_y)N)forifwhiletrywithr)r/rtextkeywordisend is_primaryr0_declared_identifiers_undeclared_identifiersrPythonFragmentrdeclared_identifiersundeclared_identifiers)rrErFrDkwargscoder$s rrzControlLine.__init__Qs "6"   !%JJ ::)+D &+-D (%%dDd.C.CDD)-)B)BD &+/+F+FD (rc|jSr r3rs rrzControlLine.get_children`r4rc|jSr )rHrs rrKz ControlLine.declared_identifierscs)))rc|jSr )rIrs rrLz"ControlLine.undeclared_identifiersfs+++rcdddhddhdhd}||j|jtvS)zRreturn true if the given keyword is a ternary keyword for this ControlLineelseelifexceptfinally)r@rBr?)getrEset)rrEcasess r is_ternaryzControlLine.is_ternaryis> 6"i(8  %))DLL#%888rc d|jd|jd|jd|j|jfd S)Nz ControlLine(r6r7)rErDrFr rrs rr9zControlLine.__repr__us1 LL II JJ [[$(( #   r) r%r'r(r)has_loop_contextrrrKrLrZr9r:r;s@rr=r=Cs/ G*, 9 rr=c(eZdZdZfdZdZxZS)Textz#defines plain text in the template.c 2t|di|||_yNr)r/rcontent)rrarMr$s rrz Text.__init__s "6" rcTd|jd|j|jfdS)NzText(r6r7)rar rrs rr9z Text.__repr__s!% TXX/FGGrr%r'r(r)rr9r:r;s@rr^r^~s-Hrr^c4eZdZdZfdZdZdZdZxZS)Codezdefines a Python code block, either inline or module level. e.g.:: inline: <% x = 12 %> module level: <%! import logger %> c t|di|||_||_t j |fi|j |_yr`)r/rrDismoduler PythonCoderrN)rrDrgrMr$s rrz Code.__init__s< "6"   NN4A4+@+@A rc.|jjSr )rNrKrs rrKzCode.declared_identifierssyy---rc.|jjSr )rNrLrs rrLzCode.undeclared_identifierssyy///rcnd|jd|jd|j|jfdS)NzCode(r6r7)rDrgr rrs rr9z Code.__repr__s* II MM [[$(( #  r r%r'r(r)rrKrLr9r:r;s@rreres B .0 rrec(eZdZdZfdZdZxZS)Commentz6defines a comment line. # this is a comment c 2t|di|||_yr`)r/rrD)rrDrMr$s rrzComment.__init__s "6" rcTd|jd|j|jfdS)NzComment(r6r7)rDr rrs rr9zComment.__repr__s$(II TXX/FGGrrcr;s@rrnrns Hrrnc4eZdZdZfdZdZdZdZxZS) Expressionz/defines an inline expression. ${x+y} c t|di|||_||_t j |fi|j |_t j|fi|j |_ yr`) r/rrDescapesr ArgumentListr escapes_coderhrN)rrDrtrMr$s rrzExpression.__init__sZ "6"  ,,WN8M8MNNN4A4+@+@A rcgSr rrs rrKzExpression.declared_identifiersrrc|jjj|jjj t j j |jjSr )rNrLunionrv differencerDEFAULT_ESCAPESrKrs rrLz!Expression.undeclared_identifierssXyy//55    4 4 ? ?''   *TYY33 4  5rcd|jd|jjd|j|jfdS)Nz Expression(r6r7)rDrvargsr rrs rr9zExpression.__repr__s2 II    " " [[$(( #  rrlr;s@rrrrrs B5 rrrc,eZdZdZiZfdZdZxZS)_TagMetazImetaclass to allow Tag to produce a subclass according to its keywordctt|dd||j|j<t||||y)N __keyword__)r# _classmaprr/r)clsclsnamebasesdict_r$s rrz_TagMeta.__init__s5 3 t , 8-0CMM#// * %/rc 0d|vr1|jd\}}tjt|||fi|S tj |}tj|||fi|S#t $r*tjd|z|d|d|d|dwxYw)N:zNo such tag: '%s'r r rrr ) splittype__call__CallNamespaceTagrrKeyErrorrCompileException)rrE attributesrMnsdefnames rrz_TagMeta.__call__s '>!--,KB== "gz=C  $$W-C}}S':@@@ --#g-h'h'5M +   s A""3B)r%r'r(r)rrrr:r;s@rrrsI0 ArrcJeZdZdZdZfdZdZdZdZdZ dZ d Z xZ S) Tagzabstract base class for tags. e.g.:: <%sometag/> <%someothertag> stuff Nc Nt |di|||_||_|j |||Dcgc]}||j vs|}}t |r9tjddjd|Dzfi|jd|_ g|_ ycc}w)aVconstruct a new Tag instance. this constructor not called directly, and is only called by subclasses. :param keyword: the tag keyword :param attributes: raw dictionary of attribute key/value pairs :param expressions: a set of identifiers that are legal attributes, which can also contain embedded expressions :param nonexpressions: a set of identifiers that are legal attributes, which cannot contain embedded expressions :param \**kwargs: other arguments passed to the Node superclass (lineno, pos) zMissing attribute(s): %s,c32K|]}t|ywr )repr).0ms r zTag.__init__..1s81tAw8sNr) r/rrEr_parse_attributesparsed_attributeslenrrjoinrparentr0) rrEr expressionsnonexpressionsrequiredrMrmissingr$s rrz Tag.__init__ s8 "6" $ {N;&J!43I3I*I1JJ w<--.hh8889 ''    Ks B" B"c|jduSr )rrs ris_rootz Tag.is_root9s{{d""rc|jSr r3rs rrzTag.get_children<r4rcDt}i|_|jD]}||vrBg}tjdtj j |j|D]}tjdtj j|}|r|tj|jdjfi|j}|j|j}|jd|jdz|s|jt!|dj#|xs t!d|j|<K||vr{tj$d|j|r1t'j(d|d |j*d fi|jt!|j||j|<t'j(d |j*d |d fi|j||_y)Nz(\${(?:[^$]*?{.+|.+?)})z ^\${(.+?)}$z(%s)z + r.z\${.+?}z Attribute 'z ' in tag 'z%' does not allow embedded expressionszInvalid attribute for tag 'z': '')rXrrrecompileSrmatchrrhgrouprstriprryrLappendrrsearchrrrE!expression_undeclared_identifiers) rrrrLkeyexprxrrNs rrzTag._parse_attributes?s!$!#??# Ck!$>EKKOOC(-A >2448>>qAA"~~GGAJ--/ 373H3H 2H1M1M 772. FQWWQZ$78 DG,#-$/4jj.>.J$r(&&s+&99Z)=>$55),dll<// /34??33G.H&&s+ 11||S*++?# H2H.rcgSr rrs rrKzTag.declared_identifiershrrc|jSr )rrs rrLzTag.undeclared_identifiersks555rc |jjd|jdtj|j d|j |jfd|jd S)N(r6r7) r$r%rErr8rr rr0rs rr9z Tag.__repr__nsI NN # # LL  ! !$// 2 [[$(( # JJ   r) r%r'r(r)rrrrrrKrLr9r:r;s@rrrs5 K+Z#'HR6 rr) metaclassc2eZdZdZfdZdZfdZxZS) IncludeTagincludec t|||dddfi|tjd|j ddzfi|j |_y)N)fileimportr}rrz __DUMMY(%s)r}r.)r/rrrhrWr page_argsrrErrMr$s rrzIncludeTag.__init__{s\    &       JNN626 6 :>:O:O rcgSr rrs rrKzIncludeTag.declared_identifiersrrc|jjjdhj|jj}|j t |S)N__DUMMY)rrLrzrKryr/)r identifiersr$s rrLz!IncludeTag.undeclared_identifierssTnn;;FF K *T^^88 9   !?!ABBrr%r'r(rrrKrLr:r;s@rrrxsK  CCrrc(eZdZdZfdZdZxZS) NamespaceTag namespacec :t|||dddfi||jddtt t |z|_d|vr$d|vr tj d i|jd|vr%d|vr tj d i|jyy) Nr)name inheritablermodulerrz __anon_%srrr)z?'name' and/or 'import' attributes are required for <%namespace>)z4<%namespace> may only have one of 'file' or 'module') r/rrWhexabsidrrrrrs rrzNamespaceTag.__init__s     7     NN6;SD]9K+KL  # (B--#''  Z H $:--F'' %; rcgSr rrs rrKz!NamespaceTag.declared_identifiersrrr%r'r(rrrKr:r;s@rrrsK.rrc(eZdZdZfdZdZxZS)TextTagrDc t|||dddfi|tj|j ddfi|j |_y)Nrfilterr.)r/rrrurWr filter_argsrs rrzTextTag.__init__sL *b8bKFK++ NN8R ( ,0,A,A rc|jjjtjj j |jSr rrLrzrr{keysryrrs rrLzTextTag.undeclared_identifierssC66AA  # # ( ( * %66 7 8r)r%r'r(rrrLr:r;s@rrrsK 8rrcLeZdZdZfdZdZdZedZdZ dZ dZ xZ S)DefTagdefc ddg|Dcgc]}|jds|c}z}t||||ddfi||d}tjd|r t j d i|jtjd|zd zfi|j|_ |jj|_ |jd d |_tj|jd d fi|j|_ycc}w)Nbufferedcachedcache_rr decoratorrr^[\w_]+$zdef z:passrr.r)zMissing parenthesis in %def) startswithr/rrrrrrr FunctionDecl function_declfuncnamerrWrrurrrErrMcrrr$s rrzDefTag.__init__s !8,!0 Q\\(%;A0       +     &! 88K &---151F1F !-- TMG # '+'<'< &&// # R8++ NN8R ( ,0,A,A -0 s D D Fc.|jjSr )rrrs rrzDefTag.funcnames!!***rc :|jjdi|Sr`)rget_argument_expressionsrkws rrzDefTag.get_argument_expressionss:t!!::@R@@rc.|jjSr )r allargnamesrs rrKzDefTag.declared_identifierss!!---rc g}|jjD]8}|ttj|fi|j j z }:t|j|jj jtjjj|jj|jjSr )rdefaultslistrrhrrLrXryrrzrr{rrr)rresrs rrLzDefTag.undeclared_identifierss##,, A 4..(( C  H U  77BB++002 U499 : Z**66 7 r) r%r'r(rr is_anonymousis_blockr*rrrKrLr:r;s@rrrs;K 6LH ++A. rrcXeZdZdZfdZdZedZedZdZ dZ dZ xZ S) BlockTagblockc gd|Dcgc]}|jds|c}z}t||||ddfi||jd}|r6t j d|s t j d i|j|s2|jddr t j d i|jtj|jddfi|j|_ ||_ |jd d|_ tj|jd dfi|j|_ycc}w) N)rrr}rrrrrr}r.rr)z,%block may not specify an argument signature)z#Only named %blocks may specify args)rr/rrWrrrrrr FunctionArgs body_declrrrurrs rrzBlockTag.__init__sL4!8 Q\\(%;A8       +     ~~f% d3-->''  vt4--59=9N9N )) NN62 & *.*?*?  # R8++ NN8R ( ,0,A,A 98 s EETc|jduSr rrs rrzBlockTag.is_anonymous$syyD  rc>|jxsd|jfzS)Nz __M_anon_%d)rr rs rrzBlockTag.funcname(syy:MT[[N::rc :|jjdi|Sr`)rrrs rrz!BlockTag.get_argument_expressions,s6t~~66<< >'',,.  %66 7  8r) r%r'r(rrrr*rrrrKrLr:r;s@rrrsJK BH !!;;=*8rrc.eZdZdZfdZdZdZxZS)CallTagcallc t|||dddfi||d|_tj|jfi|j |_tj|jddfi|j |_ y)Nr})rrr.) r/r expressionrrhrrNrrWrrs rrzCallTag.__init__=s~  Z&9i CI %V,NN4??Ld6K6KL )) NN62 & *.*?*? rct|jjj|jjSr rNrKryrrrs rrKzCallTag.declared_identifiersG'yy--33DNN4N4NOOrct|jjj|jjSr rNrLrzrKrs rrLzCallTag.undeclared_identifiersJ,yy//:: II * *  rrr;s@rr r :sK P rr c*eZdZfdZdZdZxZS)rc t||dz|z|t|jdzddfi||d|ddj d|j j Dd|_tj|jfi|j|_ tj|jd d fi|j|_y) Nr)r}r.rrc3:K|]\}}|dk7r |d|yw)r}=Nr)rkvs rrz,CallNamespaceTag.__init__..^s(Aq;a sr7r}r.)r/rtuplerrritemsr rrhrrNrrWr)rrrrrMr$s rrzCallNamespaceTag.__init__Qs  Og %  *//# $y 0         HH 2288:  NN4??Ld6K6KL )) NN62 & *.*?*? rct|jjj|jjSr rrs rrKz%CallNamespaceTag.declared_identifiersjrrct|jjj|jjSr rrs rrLz'CallNamespaceTag.undeclared_identifiersmrr)r%r'r(rrKrLr:r;s@rrrPs 2P rrc"eZdZdZfdZxZS) InheritTaginheritc .t|||dddfi|y)Nrr)r/rrs rrzInheritTag.__init__vs#  ZB  =C r)r%r'r(rrr:r;s@rr r ssK  rr c(eZdZdZfdZdZxZS)PageTagpagec Zgd|Dcgc]}|jds|c}z}t||||ddfi|tj|j ddfi|j |_tj|j ddfi|j |_ ycc}w)N)rr}expression_filter enable_looprrr}r.r') rr/rrrrWrrrur)rrErrMrrr$s rrzPageTag.__init__s # =1all8&  *k2rLVL)) NN62 & *.*?*? ++ NN. 3 7;7L7L  >s B(B(c.|jjSr rrs rrKzPageTag.declared_identifiersrrrr;s@rr$r$|sK *rr$)r)rmakorrrrrr,r=r^rernrrrrrrrrrrr rr r$rrrr+s< > 4 &8 $8 vH4H" 4" J Hd H  BAtA>x $(x vCC43< 8c 8< S< ~98s98x c ,  s  F  *c*r