[OE-core] [RFC PATCH 1/3] bitbake/utils: Add contains helper function
Richard Purdie
richard.purdie at linuxfoundation.org
Mon Jul 11 15:57:42 UTC 2011
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
bitbake/lib/bb/utils.py | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 82e5dc4..e19e1c8 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -856,3 +856,19 @@ def to_boolean(string, default=None):
return False
else:
raise ValueError("Invalid value for to_boolean: %s" % string)
+
+
+def contains(variable, checkvalues, truevalue, falsevalue, d):
+ val = d.getVar(variable, True)
+ if not val:
+ return falsevalue
+ matches = 0
+ if type(checkvalues).__name__ == "str":
+ checkvalues = [checkvalues]
+ for value in checkvalues:
+ if val.find(value) != -1:
+ matches = matches + 1
+ if matches == len(checkvalues):
+ return truevalue
+ return falsevalue
+
--
1.7.4.1
More information about the Openembedded-core
mailing list