oe.types: add floating point type
authorChris Larson <chris_larson@mentor.com>
Thu, 13 Jan 2011 15:42:13 +0000 (08:42 -0700)
committerChris Larson <chris_larson@mentor.com>
Thu, 13 Jan 2011 15:58:46 +0000 (08:58 -0700)
Optional flags:
'fromhex': if set to a true value (obeying the same rules as for the boolean
           type), your string value is in base 16, not base 10

Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/oe/_types.py

index b9eb2d2..ea31cf4 100644 (file)
@@ -89,3 +89,16 @@ def integer(value, numberbase=10):
     'numberbase' flag."""
 
     return int(value, int(numberbase))
+
+_float = float
+def float(value, fromhex='false'):
+    """OpenEmbedded floating point type
+
+    To use this type, set the type flag to 'float', and optionally set the
+    'fromhex' flag to a true value (obeying the same rules as for the
+    'boolean' type) if the value is in base 16 rather than base 10."""
+
+    if boolean(fromhex):
+        return _float.fromhex(value)
+    else:
+        return _float(value)