Mercurial > hg-stable
changeset 3634:6a46c9ccc2ed
templater: remove cStringIO from stringify
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 13 Nov 2006 13:26:57 -0600 |
parents | bf3dec184c78 |
children | 7af1f54c044c |
files | mercurial/templater.py |
diffstat | 1 files changed, 8 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templater.py Mon Nov 13 13:26:57 2006 -0600 +++ b/mercurial/templater.py Mon Nov 13 13:26:57 2006 -0600 @@ -172,15 +172,14 @@ def stringify(thing): '''turn nested template iterator into string.''' - cs = cStringIO.StringIO() - def walk(things): - for t in things: - if hasattr(t, '__iter__'): - walk(t) - else: - cs.write(t) - walk(thing) - return cs.getvalue() + def flatten(thing): + if hasattr(thing, '__iter__'): + for t in thing: + for i in flatten(t): + yield i + else: + yield str(thing) + return "".join(flatten(thing)) para_re = None space_re = None