changeset: 560:1d09b119175d tag: tip user: Benjamin Trofatter date: Mon Apr 02 10:57:20 2012 -0500 files: mako/codegen.py mako/util.py description: Added py2.4 compatible alternative to all in util diff -r 18d9733eec5a -r 1d09b119175d mako/codegen.py --- a/mako/codegen.py Mon Apr 02 02:21:42 2012 -0500 +++ b/mako/codegen.py Mon Apr 02 10:57:20 2012 -0500 @@ -782,9 +782,11 @@ # 1) a ternary control line with no children and # 2) a primary control line with nothing but its own ternary # and end control lines - if (not node.get_children or all( - isinstance(c, parsetree.ControlLine) for c in children) and - all((node.is_ternary(c.keyword) or c.isend) for c in children)): + if (not node.get_children or + util.all(isinstance(c, parsetree.ControlLine) + for c in children) and + util.all((node.is_ternary(c.keyword) or c.isend) + for c in children)): self.printer.writeline("pass") def visitText(self, node): diff -r 18d9733eec5a -r 1d09b119175d mako/util.py --- a/mako/util.py Mon Apr 02 02:21:42 2012 -0500 +++ b/mako/util.py Mon Apr 02 10:57:20 2012 -0500 @@ -35,7 +35,7 @@ time_func = time.clock else: time_func = time.time - + def function_named(fn, name): """Return a function with a given __name__. @@ -57,15 +57,24 @@ return newfunc if py24: + def all(iterable): + for i in iterable: + if not i: + return False + return True + def exception_name(exc): try: return exc.__class__.__name__ except AttributeError: return exc.__name__ else: + all = all + def exception_name(exc): return exc.__class__.__name__ + class PluginLoader(object): def __init__(self, group): self.group = group