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>
This commit is contained in:
parent
f3406dd288
commit
283b0a20c2
|
@ -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 = {}
|
||||
|
|
Loading…
Reference in New Issue