]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
data_smart: don't include functions in name lookups
authorChris Larson <chris_larson@mentor.com>
Fri, 24 Dec 2010 02:22:21 +0000 (19:22 -0700)
committerChris Larson <chris_larson@mentor.com>
Fri, 24 Dec 2010 02:23:00 +0000 (19:23 -0700)
For raw name lookups in python snippets, don't return the values for functions
in the metadata.  This was necessary to fix issues once the methodpool
functions get added to the metadata.

Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/bb/data_smart.py

index 92ef51709a0a8a27b9901fbd8a14ae5ddfaceb0d..9b89c5f5a4c9d3bbdd9cfd038711f6dd947413b8 100644 (file)
@@ -28,7 +28,7 @@ BitBake build tools.
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 # Based on functions from the base bb module, Copyright 2003 Holger Schurig
 
-import copy, re, sys
+import copy, re
 from collections import MutableMapping
 import logging
 import bb
@@ -43,14 +43,15 @@ __expand_var_regexp__ = re.compile(r"\${[^{}]+}")
 __expand_python_regexp__ = re.compile(r"\${@.+?}")
 
 
-class DataDict(dict):
+class DataContext(dict):
     def __init__(self, metadata, **kwargs):
         self.metadata = metadata
         dict.__init__(self, **kwargs)
+        self['d'] = metadata
 
     def __missing__(self, key):
         value = self.metadata.getVar(key, True)
-        if value is None:
+        if value is None or self.metadata.getVarFlag(key, 'func'):
             raise KeyError(key)
         else:
             return value
@@ -80,7 +81,7 @@ class DataSmart(MutableMapping):
         def python_sub(match):
             code = match.group()[3:-1]
             codeobj = compile(code.strip(), varname or "<expansion>", "eval")
-            value = utils.better_eval(codeobj, DataDict(self, d=self))
+            value = utils.better_eval(codeobj, DataContext(self))
             return str(value)
 
         if not isinstance(s, basestring): # sanity check