inventory: write YAML parser
Write python-based parser for writefru.yaml. The parser generates
writefru.hpp, which would have code to write to the inventory-manager
the FRU VPD information, as described in writefru.yaml.
Change-Id: I91776f808ef720e96c1b6fbd17e5f1edb93ea8f8
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/writefru.py b/writefru.py
new file mode 100755
index 0000000..97418ca
--- /dev/null
+++ b/writefru.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+import os
+import yaml
+from mako.template import Template
+
+if __name__ == '__main__':
+ script_dir = os.path.dirname(os.path.realpath(__file__))
+ with open(os.path.join(script_dir, 'writefru.yaml'), 'r') as fd:
+ yamlDict = yaml.safe_load(fd)
+
+ # Render the mako template
+ template = os.path.join(script_dir, 'writefru.mako.hpp')
+ t = Template(filename=template)
+ with open('writefru.hpp', 'w') as fd:
+ fd.write(
+ t.render(
+ fruDict=yamlDict))