chiark / gitweb /
Add the any() and all() utility functions from Python 2.5
authorKarl Hasselström <kha@treskal.com>
Tue, 11 Sep 2007 01:34:08 +0000 (03:34 +0200)
committerKarl Hasselström <kha@treskal.com>
Tue, 11 Sep 2007 03:57:14 +0000 (05:57 +0200)
Signed-off-by: Karl Hasselström <kha@treskal.com>
stgit/utils.py

index 02e98e99645217a7572dcecbfb2c28eccd093907..34c0f96a57babbc825e41781ad698b551c7eea8e 100644 (file)
@@ -214,3 +214,18 @@ def make_patch_name(msg, unacceptable, default_name = 'patch'):
             suffix += 1
         patchname = '%s-%d' % (patchname, suffix)
     return patchname
+
+# any and all functions are builtin in Python 2.5 and higher, but not
+# in 2.4.
+if not 'any' in dir(__builtins__):
+    def any(bools):
+        for b in bools:
+            if b:
+                return True
+        return False
+if not 'all' in dir(__builtins__):
+    def all(bools):
+        for b in bools:
+            if not b:
+                return False
+        return True