Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | import yaml |
Vishwanatha Subbanna | bb8fe0b | 2016-11-12 18:29:38 +0530 | [diff] [blame] | 3 | import os |
Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 4 | |
| 5 | if __name__ == '__main__': |
Vishwanatha Subbanna | bb8fe0b | 2016-11-12 18:29:38 +0530 | [diff] [blame] | 6 | script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 7 | with open(os.path.join(script_dir, 'led.yaml'), 'r') as f: |
Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 8 | ifile = yaml.safe_load(f) |
| 9 | |
Vishwanatha Subbanna | bb8fe0b | 2016-11-12 18:29:38 +0530 | [diff] [blame] | 10 | with open(os.path.join(script_dir, 'led-gen.hpp'), 'w') as ofile: |
Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 11 | ofile.write('/* !!! WARNING: This is a GENERATED Code..') |
| 12 | ofile.write('Please do NOT Edit !!! */\n\n') |
| 13 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame^] | 14 | ofile.write('static const std::map<std::string,') |
| 15 | ofile.write(' std::set<phosphor::led::Layout::LedAction>>') |
| 16 | ofile.write(' systemLedMap = {\n\n') |
Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 17 | for group in ifile.iterkeys(): |
| 18 | # Value of this group is a std::set<string, led structure> |
| 19 | ledset = ifile[group] |
Vishwanatha Subbanna | bb8fe0b | 2016-11-12 18:29:38 +0530 | [diff] [blame] | 20 | ofile.write(' {\"' + "/xyz/openbmc_project/ledmanager/groups/" + group + '\",{\n') |
Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 21 | |
| 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 Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame^] | 26 | ofile.write('phosphor::led::Layout::' + value + '},\n') |
Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 27 | ofile.write(' }},\n') |
| 28 | ofile.write('};\n') |
| 29 | |