bitbake: data_smart: directly check for methodpool functions in context lookup

We previously checked for the existence of the 'func' flag to determine
if we should avoid looking up in the metadata. This was done to ensure
the user gets the function for 'def' python functions rather than their
string contents. We can sidestep the metadata lookup and check our
function context directly, instead.

(Bitbake rev: 6cac1eac51efa9a54e8457f60ea1ea0e604c50b7)

Signed-off-by: Christopher Larson <kergoth@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Christopher Larson
2022-03-17 15:29:52 -07:00
committed by Richard Purdie
parent 042b70da3b
commit 7be82bf665

View File

@@ -154,19 +154,20 @@ class VariableParse:
return str(value)
class DataContext(dict):
excluded = set([i for i in dir(builtins) if not i.startswith('_')] + ['bb', 'os', 'oe'])
excluded = set([i for i in dir(builtins) if not i.startswith('_')] + ['oe'])
def __init__(self, metadata, **kwargs):
self.metadata = metadata
dict.__init__(self, **kwargs)
self['d'] = metadata
self.context = set(bb.utils.get_context())
def __missing__(self, key):
if key in self.excluded:
if key in self.excluded or key in self.context:
raise KeyError(key)
value = self.metadata.getVar(key)
if value is None or self.metadata.getVarFlag(key, 'func', False):
if value is None:
raise KeyError(key)
else:
return value