diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-10-05 19:35:23 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2011-01-04 14:46:38 +0000 |
commit | 283b0a20c2a9bfa27966e10f40669cbe904b7080 (patch) | |
tree | bf0946ca363c9f9a9d5b7217df0782e904b37c90 /bitbake/lib/bb | |
parent | f3406dd28846f4782bec36cb0bd1f834e068147b (diff) | |
download | openembedded-core-283b0a20c2a9bfa27966e10f40669cbe904b7080.tar.gz openembedded-core-283b0a20c2a9bfa27966e10f40669cbe904b7080.tar.bz2 openembedded-core-283b0a20c2a9bfa27966e10f40669cbe904b7080.tar.xz openembedded-core-283b0a20c2a9bfa27966e10f40669cbe904b7080.zip |
Access metadata vars as locals in python snippets
Example:
FOO = "bar"
BAR = "${@FOO + '/baz'}"
${BAR} == "bar/baz"
(Bitbake rev: 606fa1fd97cbd47a6a7ebdc7a2e6aa93a8f65cf5)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 17a642ee2..3f2d42c1b 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py @@ -72,10 +72,23 @@ class VariableParse: self.references |= parser.references self.execs |= parser.execs - value = utils.better_eval(codeobj, {"d": self.d}) + value = utils.better_eval(codeobj, DataDict(self.d)) return str(value) +class DataDict(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 or self.metadata.getVarFlag(key, 'func'): + raise KeyError(key) + else: + return value + class DataSmart(MutableMapping): def __init__(self, special = COWDictBase.copy(), seen = COWDictBase.copy() ): self.dict = {} |