blob: e49572177b19c19c438d95b8fbf2c2be6576020e [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001import oe.maketype
2
3def typed_value(key, d):
4 """Construct a value for the specified metadata variable, using its flags
5 to determine the type and parameters for construction."""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05006 var_type = d.getVarFlag(key, 'type', True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007 flags = d.getVarFlags(key)
8 if flags is not None:
9 flags = dict((flag, d.expand(value))
10 for flag, value in flags.iteritems())
11 else:
12 flags = {}
13
14 try:
15 return oe.maketype.create(d.getVar(key, True) or '', var_type, **flags)
16 except (TypeError, ValueError), exc:
17 bb.msg.fatal("Data", "%s: %s" % (key, str(exc)))