aboutsummaryrefslogtreecommitdiffstats
path: root/lib/oe/data.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-02-09 10:28:42 -0700
committerChris Larson <chris_larson@mentor.com>2011-02-09 12:10:45 -0700
commit2fbd56c0ef7df1b45746dbf9390805f2e67c590b (patch)
treea549ae6d6eb2783e5d2390f4bb7e007af551464f /lib/oe/data.py
parentf41d2fdfa6fc443353aec43eec0bfdf5c4dbb5f8 (diff)
downloadopenembedded-2fbd56c0ef7df1b45746dbf9390805f2e67c590b.tar.gz
More sane naming for the variable typing code
oe.types.value -> oe.data.typed_value This name has been bugging me. This function is the primary interface to the module for OE metadata, as it takes a variable name and datastore and returns an object of the correct type. While this function is part of the variable typing implementation, in reality it's more about giving you a useful object from the metadata, so I think oe.data is a more appropriate place for it. oe.types -> oe.maketype These are the functions which construct types, not the types themselves, so it was somewhat misleading. oe._types -> oe.types These are the actual types, any callable in this module becomes an OE type, using its arguments to determine the variable flags (optional and required) to obey. Will use __init__'s args in the case of an actual python class. Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/oe/data.py')
-rw-r--r--lib/oe/data.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/oe/data.py b/lib/oe/data.py
new file mode 100644
index 0000000000..8b7c3cd789
--- /dev/null
+++ b/lib/oe/data.py
@@ -0,0 +1,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)))