summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/data.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/data.py')
-rw-r--r--meta/lib/oe/data.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/meta/lib/oe/data.py b/meta/lib/oe/data.py
index 4a67c457b3..39567333f1 100644
--- a/meta/lib/oe/data.py
+++ b/meta/lib/oe/data.py
@@ -1,3 +1,4 @@
1import json
1import oe.maketype 2import oe.maketype
2 3
3def typed_value(key, d): 4def typed_value(key, d):
@@ -15,3 +16,30 @@ def typed_value(key, d):
15 return oe.maketype.create(d.getVar(key) or '', var_type, **flags) 16 return oe.maketype.create(d.getVar(key) or '', var_type, **flags)
16 except (TypeError, ValueError) as exc: 17 except (TypeError, ValueError) as exc:
17 bb.msg.fatal("Data", "%s: %s" % (key, str(exc))) 18 bb.msg.fatal("Data", "%s: %s" % (key, str(exc)))
19
20def export2json(d, json_file, expand=True):
21 data2export = {}
22 keys2export = []
23
24 for key in d.keys():
25 if key.startswith("_"):
26 continue
27 elif key.startswith("BB"):
28 continue
29 elif key.startswith("B_pn"):
30 continue
31 elif key.startswith("do_"):
32 continue
33 elif d.getVarFlag(key, "func", True):
34 continue
35
36 keys2export.append(key)
37
38 for key in keys2export:
39 try:
40 data2export[key] = d.getVar(key, expand)
41 except bb.data_smart.ExpansionError:
42 data2export[key] = ''
43
44 with open(json_file, "w") as f:
45 json.dump(data2export, f, skipkeys=True, indent=4, sort_keys=True)