diff options
author | Ross Burton <ross.burton@intel.com> | 2016-04-05 15:46:41 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-04-18 16:23:09 +0100 |
commit | e9174723ea6d0dff5f7f3042009761cf42284947 (patch) | |
tree | 9e63c25894ebdfabbd23990700c550379cb2fce3 /lib | |
parent | 4ca651d32d9e5fbf7f932b4167804905969f4c3a (diff) | |
download | bitbake-e9174723ea6d0dff5f7f3042009761cf42284947.tar.gz |
lib/bb/utils: add docstring for contains()
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bb/utils.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py index 8d7df13be..3544bbe17 100644 --- a/lib/bb/utils.py +++ b/lib/bb/utils.py @@ -924,6 +924,24 @@ def to_boolean(string, default=None): raise ValueError("Invalid value for to_boolean: %s" % string) def contains(variable, checkvalues, truevalue, falsevalue, d): + """Check if a variable contains all the values specified. + + Arguments: + + variable -- the variable name. This will be fetched and expanded (using + d.getVar(variable, True)) and then split into a set(). + + checkvalues -- if this is a string it is split on whitespace into a set(), + otherwise coerced directly into a set(). + + truevalue -- the value to return if checkvalues is a subset of variable. + + falsevalue -- the value to return if variable is empty or if checkvalues is + not a subset of variable. + + d -- the data store. + """ + val = d.getVar(variable, True) if not val: return falsevalue @@ -932,7 +950,7 @@ def contains(variable, checkvalues, truevalue, falsevalue, d): checkvalues = set(checkvalues.split()) else: checkvalues = set(checkvalues) - if checkvalues.issubset(val): + if checkvalues.issubset(val): return truevalue return falsevalue |