diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-12-23 19:22:21 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-12-23 19:23:00 -0700 |
commit | b0a3cc0eacbf537a8c5f020c456fa08f6ca7c1e4 (patch) | |
tree | 0cb048969c1727f8a53b0d06ab20c21c45de2605 /lib/bb/data_smart.py | |
parent | 29f6bceac00d4699fcf5e9664626175ef56fd376 (diff) | |
download | openembedded-core-contrib-b0a3cc0eacbf537a8c5f020c456fa08f6ca7c1e4.tar.gz |
data_smart: don't include functions in name lookups
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>
Diffstat (limited to 'lib/bb/data_smart.py')
-rw-r--r-- | lib/bb/data_smart.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py index 92ef51709a..9b89c5f5a4 100644 --- a/lib/bb/data_smart.py +++ b/lib/bb/data_smart.py @@ -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 |