equal
deleted
inserted
replaced
170 if n >= 2 or s == 1: |
170 if n >= 2 or s == 1: |
171 return fmt(t, n) |
171 return fmt(t, n) |
172 |
172 |
173 def stringify(thing): |
173 def stringify(thing): |
174 '''turn nested template iterator into string.''' |
174 '''turn nested template iterator into string.''' |
175 cs = cStringIO.StringIO() |
175 def flatten(thing): |
176 def walk(things): |
176 if hasattr(thing, '__iter__'): |
177 for t in things: |
177 for t in thing: |
178 if hasattr(t, '__iter__'): |
178 for i in flatten(t): |
179 walk(t) |
179 yield i |
180 else: |
180 else: |
181 cs.write(t) |
181 yield str(thing) |
182 walk(thing) |
182 return "".join(flatten(thing)) |
183 return cs.getvalue() |
|
184 |
183 |
185 para_re = None |
184 para_re = None |
186 space_re = None |
185 space_re = None |
187 |
186 |
188 def fill(text, width): |
187 def fill(text, width): |