@@ -1336,21 +1336,18 @@ def contains_any(variable, checkvalues, truevalue, falsevalue, d):
return truevalue
return falsevalue
-def filter(variable, checkvalues, d):
- """Return all words in the variable that are present in the ``checkvalues``.
+def filter_string(val, checkvalues):
+ """Return all words in the string that are present in the ``checkvalues``.
Arguments:
- - ``variable``: the variable name. This will be fetched and expanded (using
- d.getVar(variable)) and then split into a set().
+ - ``val``: the string data to filter after being split into a set().
- ``checkvalues``: if this is a string it is split on whitespace into a set(),
otherwise coerced directly into a set().
- ``d``: the data store.
Returns a list of string.
"""
-
- val = d.getVar(variable)
if not val:
return ''
val = set(val.split())
@@ -1360,6 +1357,22 @@ def filter(variable, checkvalues, d):
checkvalues = set(checkvalues)
return ' '.join(sorted(checkvalues & val))
+def filter(variable, checkvalues, d):
+ """Return all words in the variable that are present in the ``checkvalues``.
+
+ Arguments:
+
+ - ``variable``: the variable name. This will be fetched and expanded (using
+ d.getVar(variable)) 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().
+ - ``d``: the data store.
+
+ Returns a list of string.
+ """
+
+ val = d.getVar(variable)
+ return filter_string(val, checkvalues)
def get_referenced_vars(start_expr, d):
"""
There are cases where we would like the filter functionality but don't want to read the data from a variable. Add a new function, filter_string to allow this, basically separating filter() into two functions. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- lib/bb/utils.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)