blob: 35f67aa687f948b4e42e0dce23fc108f92cbd99b [file] [log] [blame]
Vishwanatha Subbannab21fda72016-10-17 17:46:37 +05301#!/usr/bin/env python
2import yaml
Vishwanatha Subbannabb8fe0b2016-11-12 18:29:38 +05303import os
Vishwanatha Subbannab21fda72016-10-17 17:46:37 +05304
5if __name__ == '__main__':
Vishwanatha Subbannabb8fe0b2016-11-12 18:29:38 +05306 script_dir = os.path.dirname(os.path.realpath(__file__))
7 with open(os.path.join(script_dir, 'led.yaml'), 'r') as f:
Vishwanatha Subbannab21fda72016-10-17 17:46:37 +05308 ifile = yaml.safe_load(f)
9
Vishwanatha Subbannabb8fe0b2016-11-12 18:29:38 +053010 with open(os.path.join(script_dir, 'led-gen.hpp'), 'w') as ofile:
Vishwanatha Subbannab21fda72016-10-17 17:46:37 +053011 ofile.write('/* !!! WARNING: This is a GENERATED Code..')
12 ofile.write('Please do NOT Edit !!! */\n\n')
13
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053014 ofile.write('static const std::map<std::string,')
15 ofile.write(' std::set<phosphor::led::Layout::LedAction>>')
16 ofile.write(' systemLedMap = {\n\n')
Vishwanatha Subbannab21fda72016-10-17 17:46:37 +053017 for group in ifile.iterkeys():
18 # Value of this group is a std::set<string, led structure>
19 ledset = ifile[group]
Vishwanatha Subbannabb8fe0b2016-11-12 18:29:38 +053020 ofile.write(' {\"' + "/xyz/openbmc_project/ledmanager/groups/" + group + '\",{\n')
Vishwanatha Subbannab21fda72016-10-17 17:46:37 +053021
22 for led_dict, list_dict in ledset.iteritems():
23 for name, value in list_dict.iteritems():
24 if group and led_dict and name and value:
25 ofile.write(' {\"' + led_dict + '\",')
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053026 ofile.write('phosphor::led::Layout::' + value + '},\n')
Vishwanatha Subbannab21fda72016-10-17 17:46:37 +053027 ofile.write(' }},\n')
28 ofile.write('};\n')
29