Mercurial > genshi > genshi-test
diff genshi/template/interpolation.py @ 859:fbe34d12acde
More bits of 2to3 related cleanup.
author | cmlenz |
---|---|
date | Thu, 12 Nov 2009 17:01:52 +0000 |
parents | 0d9e87c6cf6e |
children |
line wrap: on
line diff
--- a/genshi/template/interpolation.py +++ b/genshi/template/interpolation.py @@ -36,6 +36,7 @@ PseudoToken )) + def interpolate(text, filepath=None, lineno=-1, offset=0, lookup='strict'): """Parse the given string and extract expressions. @@ -45,9 +46,9 @@ >>> for kind, data, pos in interpolate("hey ${foo}bar"): ... print('%s %r' % (kind, data)) - TEXT u'hey ' + TEXT 'hey ' EXPR Expression('foo') - TEXT u'bar' + TEXT 'bar' :param text: the text to parse :param filepath: absolute path to the file in which the text was found @@ -68,7 +69,7 @@ for is_expr, chunk in chain(lex(text, pos, filepath), [(True, '')]): if is_expr: if textbuf: - yield TEXT, u''.join(textbuf), textpos + yield TEXT, ''.join(textbuf), textpos del textbuf[:] textpos = None if chunk: @@ -91,6 +92,7 @@ else: pos[2] += len(chunk) + def lex(text, textpos, filepath): offset = pos = 0 end = len(text)