summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-25 18:03:08 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-26 11:05:39 (GMT)
commit3300065035cc9900340e15796fa0b33391c055c3 (patch)
tree6bea24158c142c0909579915bffa491ab906015a /meta/lib
parentb163a0bca6115ec5983ab5ba9277f3214d64287d (diff)
downloadpoky-3300065035cc9900340e15796fa0b33391c055c3.tar.gz
lib/oe/utils: 'Fix' oe.utils.contains() behaviour
Currently oe.utils.contains(X, "A", true, false) will return true for substring matches, e.g. if X = "ABC". This is not what most users expect from the function. In the common OE use of this function there is the case of "touchscreen" and "screen" being used as independent variables. Whilst it could be argued there isn't a problem in that specific case (touchscreens are usually on screens), there is no substring usage of this function is OE-Core so this patch changes the behaviour to match only full strings. It also fixes a bug where duplicate entries would confuse multiple matches, e.g. contains(X, ["A", "B"], ...) would match X = "A A" which is clearly wrong. (From OE-Core rev: 5c09cbe3bf456e968fc853827698eb18b62e8348) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/utils.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index f6d4142..5a63ed3 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -35,16 +35,15 @@ def version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
35 return falsevalue 35 return falsevalue
36 36
37def contains(variable, checkvalues, truevalue, falsevalue, d): 37def contains(variable, checkvalues, truevalue, falsevalue, d):
38 val = bb.data.getVar(variable,d,1) 38 val = d.getVar(variable, True)
39 if not val: 39 if not val:
40 return falsevalue 40 return falsevalue
41 matches = 0 41 val = set(val.split())
42 if type(checkvalues).__name__ == "str": 42 if isinstance(checkvalues, basestring):
43 checkvalues = [checkvalues] 43 checkvalues = set(checkvalues.split())
44 for value in checkvalues: 44 else:
45 if val.find(value) != -1: 45 checkvalues = set(checkvalues)
46 matches = matches + 1 46 if checkvalues.issubset(val):
47 if matches == len(checkvalues):
48 return truevalue 47 return truevalue
49 return falsevalue 48 return falsevalue
50 49