2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-27 19:37:44 +00:00

Fix ordering if list config

List config items can have xml order superseded by an 'order'
attribute.  Honor that attribute.

Change-Id: Ie5e2ee95ee40e5f7993bd426fc92aefb2a85b262
This commit is contained in:
Jarrod Johnson 2018-03-08 15:21:51 -05:00
parent 02e783c1d5
commit 7b50574186

View File

@ -284,10 +284,13 @@ class LenovoFirmwareConfig(object):
reset = False
name = setting.find("mriName").text
help = setting.find("desc").text
if setting.find("list_data") is not None:
ldata = setting.find("list_data")
extraorder = False
currentdict = {}
if ldata is not None:
is_list = True
current = []
extraorder = ldata.get('ordered') == 'true'
lenovo_value = None
for choice in setting.iter("choice"):
label = choice.find("label").text
@ -295,7 +298,11 @@ class LenovoFirmwareConfig(object):
instance = choice.find("instance")
if instance is not None:
if is_list:
current.append(label)
if not extraorder:
current.append(label)
else:
currentdict[
int(instance.get("order"))] = label
else:
current = label
try:
@ -307,6 +314,9 @@ class LenovoFirmwareConfig(object):
default = label
if choice.get("reset-required") == "true":
reset = True
if len(currentdict) > 0:
for order in sorted(currentdict):
current.append(currentdict[order])
optionname = "%s.%s" % (lenovo_id, name)
options[optionname] = dict(current=current,
default=default,