diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/utils.py | 20 |
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 | ||
926 | def contains(variable, checkvalues, truevalue, falsevalue, d): | 926 | def 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 | ||