2024-09-09 08:52:07 +00:00
|
|
|
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:
|
2024-09-09 08:57:42 +00:00
|
|
|
flags = dict((flag, d.expand(value))
|
2024-09-09 08:52:07 +00:00
|
|
|
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)))
|