[oe-commits] Christopher Larson : base.bbclass: add 'any' and 'all' functions.

git version control git at git.openembedded.org
Sun Jan 24 10:39:20 UTC 2010


Module: openembedded.git
Branch: holger/staging-branch
Commit: ce6fa24f05cfc12fd66aaa6a125e6dd0d8a3ec59
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=ce6fa24f05cfc12fd66aaa6a125e6dd0d8a3ec59

Author: Christopher Larson <clarson at mvista.com>
Date:   Tue Jan 19 10:01:07 2010 +0000

base.bbclass: add 'any' and 'all' functions.

Python 2.5+ has these functions built-in, but we don't yet require 2.5+.

Signed-off-by: Chris Larson <clarson at mvista.com>

---

 classes/base.bbclass |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/classes/base.bbclass b/classes/base.bbclass
index a9badc9..2d49aee 100644
--- a/classes/base.bbclass
+++ b/classes/base.bbclass
@@ -1,5 +1,20 @@
 BB_DEFAULT_TASK ?= "build"
 
+# Useful Python 2.5+ built-in functions
+def any(iterable):
+    """ Return True if any element of the iterable is true.  If the iterable is empty, return False. """
+    for element in iterable:
+        if element:
+            return True
+    return False
+
+def all(iterable):
+    """ Return True if all elements of the iterable are true (or if the iterable is empty). """
+    for element in iterable:
+        if not element:
+            return False
+    return True
+
 python () {
     env = {}
     for v in d.keys():





More information about the Openembedded-commits mailing list