]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
lib/bb/utils: add docstring for contains()
authorRoss Burton <ross.burton@intel.com>
Tue, 5 Apr 2016 14:46:41 +0000 (15:46 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 18 Apr 2016 15:23:09 +0000 (16:23 +0100)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/utils.py

index 8d7df13be788ed901f9c2f7fa36db80327391813..3544bbe1707dedca6009795d013102dad42e89ad 100644 (file)
@@ -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