forked from ibm-openbmc/phosphor-settingsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
executable file
·32 lines (24 loc) · 907 Bytes
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
import os
import yaml
from mako.template import Template
import argparse
def main():
parser = argparse.ArgumentParser(
description="Settings YAML parser and code generator")
parser.add_argument(
'-i', '--settings_yaml', dest='settings_yaml',
default='settings_example.yaml', help='settings yaml file to parse')
args = parser.parse_args()
with open(os.path.join(script_dir, args.settings_yaml), 'r') as fd:
yamlDict = yaml.safe_load(fd)
# Render the mako template
template = os.path.join(script_dir, 'settings_manager.mako.hpp')
t = Template(filename=template)
with open('settings_manager.hpp', 'w') as fd:
fd.write(
t.render(
settingsDict=yamlDict))
if __name__ == '__main__':
script_dir = os.path.dirname(os.path.realpath(__file__))
main()