util: add any() and all() functions for Python 2.4 compatibility
authorSteve Losh <steve@stevelosh.com>
Fri, 12 Feb 2010 19:59:09 -0500
changeset 10438 e6dc44147234
parent 10437 8a99388f87cc
child 10439 509f4ed56509
util: add any() and all() functions for Python 2.4 compatibility This patch adds these two very useful functions to the mercurial.util module, because they are not present in Python 2.4.
mercurial/util.py
--- a/mercurial/util.py	Sat Feb 13 10:56:43 2010 +0100
+++ b/mercurial/util.py	Fri Feb 12 19:59:09 2010 -0500
@@ -1342,3 +1342,15 @@
     finally:
         if prevhandler is not None:
             signal.signal(signal.SIGCHLD, prevhandler)
+
+def any(iterable):
+    for i in iterable:
+        if i:
+            return True
+    return False
+
+def all(iterable):
+    for i in iterable:
+        if not i:
+            return False
+    return True