Ñò -!Lc@sjdZddkZddkZddklZlZlZddklZhZ de fd„ƒYZ dS(sGprovides the Lexer class for parsing template strings into parse trees.iÿÿÿÿN(t parsetreet exceptionstutil(tadjust_whitespacetLexercBs¼eZdeddd„Zed„ƒZdd„Zd„Zd„Z d„Z e i dƒZ d„Zd„Zd „Zd „Zd „Zd „Zd „Zd„Zd„Zd„ZRS(cCsÚ||_||_ti|iƒ|_d|_d|_d|_d|_g|_ g|_ ||_ ||_ t io|otidƒ‚n|djo g|_n*t|dƒp|g|_n ||_dS(Niis4Mako for Python 3 does not support disabling Unicodet__iter__(ttexttfilenameRt TemplateNodettemplatetmatched_linenotmatched_charpostlinenotmatch_positionttagt control_linetdisable_unicodetencodingRtpy3kRtUnsupportedErrortNonet preprocessorthasattr(tselfRRRtinput_encodingR((s./usr/lib/python2.6/site-packages/mako/lexer.pyt__init__s&             cCs,h|id6|id6|id6|id6S(NtsourceR tposR(RR R R(R((s./usr/lib/python2.6/site-packages/mako/lexer.pytexception_kwargs+s   cCssyt||f}WnOtj oC|oti||ƒ}nti|ƒ}|t||fcompile the given regexp, cache the reg, and call match_reg().(t _regexp_cachetKeyErrortretcompilet match_reg(Rtregexptflagstreg((s./usr/lib/python2.6/site-packages/mako/lexer.pytmatch2scCs|i}|i|i|iƒ}|o×|iƒ\}}||jo|d|_n ||_|i|_tid|i||i!ƒ}|d}x@|djo2||ijo"|i|djo|d8}q™W|||_ |it |ƒ7_n|S(s¨match the given regular expression object to the current text position. if a match occurs, update the current text and line position. is\nis ( R R%RtspanR R Rtfindallt textlengthR tlen(RR$tmpR%tstarttendtlinestcp((s./usr/lib/python2.6/site-packages/mako/lexer.pyR!@s      1 cGsH|i}x8to0|idƒ}|oq n|idƒ}|oS|id|idƒtiƒ}|p&tid|idƒ|i‚q?q |iddi |ƒƒ}|o4|i ||it |idƒƒ!|idƒfS|iddi |ƒtiƒ}|p&tid d i |ƒ|i‚q q WdS( Ns#.*\ns(\"\"\"|\'\'\'|\"|\')s.*?%sisUnmatched '%s's(%s)t|s.*?(?=\"|\'|#|%s)s Expected: %st,( R tTrueR%tgroupRtSRtSyntaxExceptionRtjoinRR)(RRtstartposR%tm((s./usr/lib/python2.6/site-packages/mako/lexer.pytparse_until_text\s0 " #" cOs|id|iƒ|id|iƒ|id|iƒ|i|d<|||Ž}t|iƒo|idii|ƒn|i ii|ƒt |t i ƒo8t|iƒo|id|_ n|ii|ƒn¬t |t iƒo˜|io|iiƒq‰|io|ii|ƒq‰t|iƒoK|idi|iƒ o0tid|i|idif|i‚q‰ndS(NRR RRiÿÿÿÿs1Keyword '%s' not a legal ternary for keyword '%s'(t setdefaultRR R RR)RtnodestappendR t isinstanceRtTagtparentt ControlLinetisendRtpopt is_primaryt is_ternarytkeywordRR4R(Rtnodeclstargstkwargstnode((s./usr/lib/python2.6/site-packages/mako/lexer.pyt append_nodexs.   s #.*coding[:=]\s*([-\w.]+).*\r?\nc Csªt|tƒoA|ii|ƒ}|o|idƒp |pd}||fS|itiƒo–|ttiƒ}d}|ii|i ddƒƒ}|dj oN|idƒdjo8t i d|idƒ|i ddƒdd|ƒ‚q?nF|ii|i ddƒƒ}|o|idƒ}n|pd}|oZy|i |ƒ}Wq t j o4}t i d||i ddƒdd|ƒ‚q Xn||fS( s§given string/unicode or bytes/string, determine encoding from magic encoding comment, return body as unicode or raw if decode_raw=False itasciisutf-8tignoresHFound utf-8 BOM in file, with conflicting magic encoding comment of '%s'is0Unicode decode operation of encoding '%s' failedN(R<tunicodet _coding_reR%R2t startswithtcodecstBOM_UTF8R)tdecodeRRtCompileExceptiontUnicodeDecodeError( RRt decode_rawtknown_encodingRR7Rtparsed_encodingte((s./usr/lib/python2.6/site-packages/mako/lexer.pytdecode_raw_stream”s8$ #  cCsú|i|i|i |i|iƒ\|_|_x#|iD]}||iƒ|_q;W|i|iƒt|iƒ|_ xét oá|i |i joPn|i ƒoPn|i ƒoq|n|iƒoq|n|iƒoq|n|iƒoq|n|iƒoq|n|iƒoq|n|iƒoq|n|i |i joPntidƒ‚q|Wt|iƒo'tid|idi|i‚nt|iƒoGtid|idi|i|idi|idi|iƒ‚n|iS(Nsassertion failedsUnclosed tag: <%%%s>iÿÿÿÿs"Unterminated control keyword: '%s'(RXRRRRRR!RMR)R(R1R t match_endtmatch_expressiontmatch_control_linet match_commenttmatch_tag_startt match_tag_endtmatch_python_blockt match_textRRRRR4RDRRR RR (Rtpreproc((s./usr/lib/python2.6/site-packages/mako/lexer.pytparse¼sV             c Csz|idtitiBtiBƒ}|oH|idƒ|idƒ|idƒ}}}||_h}|oYxVtid|ƒD]>}|\}}} |p| } | iddƒ} | || # closing iiis)\s*(\w+)\s*=\s*(?:'([^']*)'|\"([^\"]*)\")s s Rs(.*?)(?=\)sUnclosed tag: <%%%s>iÿÿÿÿ(R%RtIR3tXR2RDR'treplaceRIRR=RRARR4RtTextR^R1tFalse( RR%RDtattrR@t attributestatttkeytval1tval2R((s./usr/lib/python2.6/site-packages/mako/lexer.pyR]ðs8 /    cCs¼|idƒ}|ožt|iƒp&tid|idƒ|i‚nW|idi|idƒjo6tid|idƒ|idif|i‚n|iiƒt St SdS(Ns\s(Closing tag without opening tag: iiÿÿÿÿs.Closing tag does not match tag: <%%%s>( R%R)RRR4R2RRDRAR1Rg(RR%((s./usr/lib/python2.6/site-packages/mako/lexer.pyR^s   cCsD|idtiƒ}|o |iƒ}|o|StSntSdS(Ns\Z(R%RR3R2R1Rg(RR%tstring((s./usr/lib/python2.6/site-packages/mako/lexer.pyRY-s cCsR|idtitiBƒ}|o'|idƒ}|iti|ƒtSt SdS(Nsá (.*?) # anything, followed by: ( (?<=\n)(?=[ \t]*(?=%|\#\#)) # an eval or line-based # comment preceded by a # consumed newline and whitespace | (?=\${) # an expression | (?=\#\*) # multiline comment | (?=s it!R R( R%R R R8RRIRtCodeR2R1Rg(RR%tlineRRR,((s./usr/lib/python2.6/site-packages/mako/lexer.pyR_Ss"cCs´|idƒ}|o–|i|i}}|iddƒ\}}|djo|idƒ\}}nd}|iddƒ}|iti||iƒd|d |ƒt St SdS( Ns\${s\|t}R/ts s R R( R%R R R8ReRIRt ExpressiontstripR1Rg(RR%RqRRR,tescapes((s./usr/lib/python2.6/site-packages/mako/lexer.pyRZcs  cCs`|idtiƒ}|o<|idƒ}|idƒ}|djoùtid|ƒ}|ptid||i‚n|iddƒ\}}|dj }|o{t|i ƒp#tid||f|i‚q#|i di |jo-tid ||i di f|i‚q#n|i t i |||ƒn|i t i|ƒtStSdS( NsB(?<=^)[\t ]*(%(?!%)|##)[\t ]*((?:(?:\\r?\n)|[^\r\n])*)(?:\r?\n|\Z)iit%s(end)?(\w+)\s*(.*)sInvalid control line: '%s's!No starting keyword '%s' for '%s'iÿÿÿÿs'Keyword '%s' doesn't match keyword '%s'(R%RtMR2RR4RRR)RRDRIRR?tCommentR1Rg(RR%toperatorRtm2R@RD((s./usr/lib/python2.6/site-packages/mako/lexer.pyR[us8   cCsE|idtiƒ}|o!|iti|idƒƒtStSdS(s*matches the multiline version of a comments<%doc>(.*?)iN( R%RR3RIRRyR2R1Rg(RR%((s./usr/lib/python2.6/site-packages/mako/lexer.pyR\–s N(t__name__t __module__RRgRtpropertyRR%R!R8RIRR RMRXRbR]R^RYR`R_RZR[R\(((s./usr/lib/python2.6/site-packages/mako/lexer.pyRs&     ( 4 +     !( t__doc__RROtmakoRRRt mako.pygenRRtobjectR(((s./usr/lib/python2.6/site-packages/mako/lexer.pyts