bitbake/utils: Add contains helper function from lib.oe.utils

This function is needed by some of the early .conf setup we need
to improve the machine/tune files in Openembedded. We need to add
it here since the location in oe.utils can't be accessed until after
base.bbclass parses which is too late for our needs.

(Bitbake rev: abc67ed6921c98ed581f101ec1acc589fd9ce7e9)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2011-07-11 14:38:50 +01:00
parent 14f3bab4d1
commit ac704918e4
1 changed files with 14 additions and 0 deletions

View File

@ -856,3 +856,17 @@ 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