The bb and os modules are always imported so having these extra import calls are a waste of space/execution time. They also set a bad example for people copy and pasting code so clean them up. (From OE-Core rev: 7d674820958be3a7051ea619effe1a6061d9cbe2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
18 lines
604 B
Python
18 lines
604 B
Python
import oe.maketype
|
|
|
|
def typed_value(key, d):
|
|
"""Construct a value for the specified metadata variable, using its flags
|
|
to determine the type and parameters for construction."""
|
|
var_type = d.getVarFlag(key, 'type')
|
|
flags = d.getVarFlags(key)
|
|
if flags is not None:
|
|
flags = dict((flag, d.expand(value))
|
|
for flag, value in flags.iteritems())
|
|
else:
|
|
flags = {}
|
|
|
|
try:
|
|
return oe.maketype.create(d.getVar(key, True) or '', var_type, **flags)
|
|
except (TypeError, ValueError), exc:
|
|
bb.msg.fatal("Data", "%s: %s" % (key, str(exc)))
|