blob: 96bcd5e72794d0c555df215899f2f806cedb5c86 [file] [log] [blame]
Vishwanatha Subbannab21fda72016-10-17 17:46:37 +05301#!/usr/bin/env python
2import yaml
3
4if __name__ == '__main__':
5 with open('led.yaml', 'r') as f:
6 ifile = yaml.safe_load(f)
7
8 with open('led-gen.hpp', 'w') as ofile:
9 ofile.write('/* !!! WARNING: This is a GENERATED Code..')
10 ofile.write('Please do NOT Edit !!! */\n\n')
11
12 ofile.write('const std::map<std::string,')
13 ofile.write(' std::set<phosphor::led::Manager::LedAction>>')
14 ofile.write(' phosphor::led::Manager::cv_LedMap = {\n\n')
15 for group in ifile.iterkeys():
16 # Value of this group is a std::set<string, led structure>
17 ledset = ifile[group]
18 ofile.write(' {\"' + group + '\",{\n')
19
20 for led_dict, list_dict in ledset.iteritems():
21 for name, value in list_dict.iteritems():
22 if group and led_dict and name and value:
23 ofile.write(' {\"' + led_dict + '\",')
24 ofile.write(value.upper() + '},\n')
25 ofile.write(' }},\n')
26 ofile.write('};\n')
27