Skip to contentSkip to conversation

bb.codeparser.py: Remove reference for oe.utils.contains

PATCH New Otavio Salvador 1 participant 2 messages Apr 25, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 bb.codeparser.py: Remove reference for oe.utils.contains

The oe.utils.contains function has been removed from OE-Core metadata as the references for it has been replaced to use the bb.utils.contains.

---
 lib/bb/codeparser.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/codeparser.py +1 -1
index a50b9f2..b4b1013 100644
@@ -103,7 +103,7 @@ class BufferedLogger(Logger):
 
 class PythonParser():
     getvars = ("d.getVar", "bb.data.getVar", "data.getVar", "d.appendVar", "d.prependVar")
-    containsfuncs = ("bb.utils.contains", "base_contains", "oe.utils.contains")
+    containsfuncs = ("bb.utils.contains", "base_contains")
     execfuncs = ("bb.build.exec_func", "bb.build.exec_task")
 
     def warn(self, func, arg):
Signature · 1 line
2.0.0.rc0
#1 lore raw

PATCH 2/2 bb.utils, bb.codeparser: Add bb.utils.contains_any

This includes contains_any in the special handling code for sstate. It does not take into account the equivalence of the values. In current code, considering 'bb.utils.contains_any("A", "foo bar", ...)':

A = "foo"
A = "bar"
A = "foo bar"

All those will get different signatures.

---
 lib/bb/codeparser.py |  3 ++-
 lib/bb/utils.py      | 13 +++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
lib/bb/codeparser.py +2 -1
index b4b1013..58e0016 100644
@@ -103,7 +103,8 @@ class BufferedLogger(Logger):
 
 class PythonParser():
     getvars = ("d.getVar", "bb.data.getVar", "data.getVar", "d.appendVar", "d.prependVar")
-    containsfuncs = ("bb.utils.contains", "base_contains")
+    containsfuncs = ("bb.utils.contains", "base_contains",
+                     "bb.utils.contains_any", "base_contains_any")
     execfuncs = ("bb.build.exec_func", "bb.build.exec_task")
 
     def warn(self, func, arg):
lib/bb/utils.py +13 -0
index 0be45e1..1be1874 100644
@@ -845,6 +845,19 @@ def contains(variable, checkvalues, truevalue, falsevalue, d):
         return truevalue
     return falsevalue
 
+def contains_any(variable, checkvalues, truevalue, falsevalue, d):
+    val = d.getVar(variable, True)
+    if not val:
+        return falsevalue
+    val = set(val.split())
+    if isinstance(checkvalues, basestring):
+        checkvalues = set(checkvalues.split())
+    else:
+        checkvalues = set(checkvalues)
+    if checkvalues in val:
+        return truevalue
+    return falsevalue
+
 def cpu_count():
     return multiprocessing.cpu_count()
 
Signature · 1 line
2.0.0.rc0