[oe] [PATCH] base.bbclass: add 'any' and 'all' functions.

Chris Larson clarson at mvista.com
Tue Jan 19 20:01:07 UTC 2010


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 4d25258..dc56282 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():
-- 
1.6.6





More information about the Openembedded-devel mailing list