summaryrefslogtreecommitdiffstats
path: root/scripts/extra-properties.py
blob: 0baa3e069e2f660857277e0a487fac2d49235082 (plain)
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
33
34
#!/usr/bin/env python

import os
import yaml
from mako.template import Template
import argparse


def main():
    parser = argparse.ArgumentParser(
        description="IPMI FRU VPD parser and code generator")

    parser.add_argument(
        '-e', '--extra_props_yaml',
        dest='extra_props_yaml',
        default='extra-properties-example.yaml',
        help='input extra properties yaml file to parse')
    args = parser.parse_args()

    with open(os.path.join(script_dir, args.extra_props_yaml), 'r') as fd:
        yamlDict = yaml.safe_load(fd)

        # Render the mako template
        template = os.path.join(script_dir, 'extra-properties.mako.cpp')
        t = Template(filename=template)
        with open('extra-properties-gen.cpp', 'w') as fd:
            fd.write(
                t.render(
                    dict=yamlDict))


if __name__ == '__main__':
    script_dir = os.path.dirname(os.path.realpath(__file__))
    main()
OpenPOWER on IntegriCloud