Ñò ûãtHc @sÔdZddklZddkZddkZddklZddklZddk l Z l Z ddk l Z dgZd Zd Zed Zd Zeid defƒZddddd„Zd„ZdS(s”String interpolation routines, i.e. the splitting up a given text into some parts that are literal strings, and others that are Python expressions. iÿÿÿÿ(tchainN(t PseudoToken(tTEXT(tTemplateSyntaxErrortEXPR(t Expressiont interpolatesrestructuredtext ent5abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_s .0123456789t$s %s|%s(?s)s)[uU]?[rR]?("""|\'\'\')((?t| iƒ|d|dd|ƒ} t| t |ƒfVWq t j o4} t | ||d|d| i pdƒ‚q Xq9n+|i | ƒ|d jot |ƒ}nd| joD| iƒ} |dct| ƒd7<|dct| dƒ7>> for kind, data, pos in interpolate("hey ${foo}bar"): ... print kind, `data` TEXT u'hey ' EXPR Expression('foo') TEXT u'bar' :param text: the text to parse :param filepath: absolute path to the file in which the text was found (optional) :param lineno: the line number at which the text was found (optional) :param offset: the column number at which the text starts in the source (optional) :param lookup: the variable lookup mechanism; either "lenient" (the default), "strict", or a custom lookup class :return: a list of `TEXT` and `EXPR` events :raise TemplateSyntaxError: when a syntax error in an expression is encountered tuiitlookupis iÿÿÿÿN(tNoneRtlextTrueRtjoinRtstripRttuplet SyntaxErrorRtoffsettappendt splitlinestlen( ttexttfilepathtlinenoRR tposttextbufttextpostis_exprtchunktexprterrtlines((sC/usr/lib64/python2.6/site-packages/genshi/template/interpolation.pyR's4%   (    ccs¿d}}t|ƒ}t}x||o |it|dƒ}t}n|it|ƒ}|djp||djoPn||d}|djoû||jot|||!fVn|d}d}x§|oŸti||ƒ} | djotd||dŒ‚n| iƒ}| i d\} } || | !} | djo|d7}qÌ| djo|d8}qÌqÌWt ||d|d!fVq|t joŽ||jot|||!fV|}n|d7}x8||jo*||} | t joPn|d7}qÔWt ||d|!i ƒfVq| oD|tjo7||jot|||!fVnt }|d}qt|||d!fV|d}q||jot||fVndS(Niiit{sinvalid syntaxit}(RtFalsetfindtPREFIXttoken_retmatchR RtendtregsRt NAMESTARTt NAMECHARSR(RRRRRR)tescapedtnexttlevelR(ttstartttendttokentchar((sC/usr/lib64/python2.6/site-packages/genshi/template/interpolation.pyR ^sf                       (t__doc__t itertoolsRtostrettokenizeRt genshi.coreRtgenshi.template.baseRRtgenshi.template.evalRt__all__t __docformat__R+R,R&tcompileR'R RR (((sC/usr/lib64/python2.6/site-packages/genshi/template/interpolation.pyts"      7