aboutsummaryrefslogtreecommitdiff
path: root/lib/oe/data.py
blob: 8b7c3cd7898fcb6a5f05964073fb88a402f2acc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import oe.maketype
import bb.msg

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)

    try:
        return oe.maketype.create(d.getVar(key, True) or '', var_type, **flags)
    except (TypeError, ValueError), exc:
        bb.msg.fatal(bb.msg.domain.Data, "%s: %s" % (key, str(exc)))