From 3300065035cc9900340e15796fa0b33391c055c3 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 25 Jul 2011 19:03:08 +0100 Subject: 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 --- meta/lib/oe/utils.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'meta/lib/oe') diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index f6d4142c12..5a63ed3c3b 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): return falsevalue def contains(variable, checkvalues, truevalue, falsevalue, d): - val = bb.data.getVar(variable,d,1) + val = d.getVar(variable, True) if not val: return falsevalue - matches = 0 - if type(checkvalues).__name__ == "str": - checkvalues = [checkvalues] - for value in checkvalues: - if val.find(value) != -1: - matches = matches + 1 - if matches == len(checkvalues): + val = set(val.split()) + if isinstance(checkvalues, basestring): + checkvalues = set(checkvalues.split()) + else: + checkvalues = set(checkvalues) + if checkvalues.issubset(val): return truevalue return falsevalue -- cgit v1.2.3-54-g00ecf