summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2016-04-05 15:46:41 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-18 16:28:23 +0100
commit004b939d1b5882db65d882633d3a3b8d22814779 (patch)
treec02c42f0d3e1bdbaade6cd4670cb0bcf541daf26
parent524d04cb0511d6dda4c6259e07a303f620555f78 (diff)
downloadpoky-004b939d1b5882db65d882633d3a3b8d22814779.tar.gz
bitbake: lib/bb/utils: add docstring for contains()
(Bitbake rev: e9174723ea6d0dff5f7f3042009761cf42284947) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/utils.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 8d7df13be7..3544bbe170 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -924,6 +924,24 @@ def to_boolean(string, default=None):
924 raise ValueError("Invalid value for to_boolean: %s" % string) 924 raise ValueError("Invalid value for to_boolean: %s" % string)
925 925
926def contains(variable, checkvalues, truevalue, falsevalue, d): 926def contains(variable, checkvalues, truevalue, falsevalue, d):
927 """Check if a variable contains all the values specified.
928
929 Arguments:
930
931 variable -- the variable name. This will be fetched and expanded (using
932 d.getVar(variable, True)) and then split into a set().
933
934 checkvalues -- if this is a string it is split on whitespace into a set(),
935 otherwise coerced directly into a set().
936
937 truevalue -- the value to return if checkvalues is a subset of variable.
938
939 falsevalue -- the value to return if variable is empty or if checkvalues is
940 not a subset of variable.
941
942 d -- the data store.
943 """
944
927 val = d.getVar(variable, True) 945 val = d.getVar(variable, True)
928 if not val: 946 if not val:
929 return falsevalue 947 return falsevalue
@@ -932,7 +950,7 @@ def contains(variable, checkvalues, truevalue, falsevalue, d):
932 checkvalues = set(checkvalues.split()) 950 checkvalues = set(checkvalues.split())
933 else: 951 else:
934 checkvalues = set(checkvalues) 952 checkvalues = set(checkvalues)
935 if checkvalues.issubset(val): 953 if checkvalues.issubset(val):
936 return truevalue 954 return truevalue
937 return falsevalue 955 return falsevalue
938 956