parse_led.py: python3 fixes
* iteritems / iterkeys does not exist in python3, use
items / keys directly.
* Order of dicts cannot be relied on.
Change-Id: Ieaf5f58115d4015070d812814d98ca1e58d92ae2
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/parse_led.py b/parse_led.py
index da23328..5afe4b0 100755
--- a/parse_led.py
+++ b/parse_led.py
@@ -44,7 +44,7 @@
ofile.write('static const std::map<std::string,')
ofile.write(' std::set<phosphor::led::Layout::LedAction>>')
ofile.write(' systemLedMap = {\n\n')
- for group in ifile.iterkeys():
+ for group in ifile.keys():
# This section generates an std::map of LedGroupNames to std::set
# of LEDs containing the name and properties
ledset = ifile[group]
@@ -59,18 +59,13 @@
ofile.write(' }},\n')
continue
- for led_dict, list_dict in ledset.iteritems():
- # Need this to make sure the LED name is printed once
- name_printed = False
- for name, value in list_dict.iteritems():
- if group and led_dict and name:
- if name_printed is False:
- ofile.write(' {\"' + underscore(led_dict) +
- '\",')
- name_printed = True
- if name == 'Action':
- ofile.write('phosphor::led::Layout::')
- ofile.write(str(value) + ',')
+ for led_dict, list_dict in ledset.items():
+ ofile.write(' {\"' + underscore(led_dict) + '\",')
+ ofile.write('phosphor::led::Layout::' +
+ str(list_dict.get('Action', 'Off')) + ',')
+ ofile.write(str(list_dict.get('DutyOn', 0)) + ',')
+ ofile.write(str(list_dict.get('Period', 0)) + ',')
+
ofile.write('},\n')
ofile.write(' }},\n')
ofile.write('};\n')