tests/bootloader-entries-crosscheck: Use Python 3-friendly sorting
This is a little clearer than a strcmp()-style negative/zero/positive return, and also works in Python 2. Signed-off-by: Simon McVittie <smcv@debian.org> Closes: #1457 Approved by: cgwalters
This commit is contained in:
parent
98b597b465
commit
6cabeaed3f
|
|
@ -38,8 +38,8 @@ def fatal(msg):
|
||||||
sys.stderr.write('\n')
|
sys.stderr.write('\n')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def compare_entries_descending(a, b):
|
def entry_get_version(entry):
|
||||||
return int(b['version']) - int(a['version'])
|
return int(entry['version'])
|
||||||
|
|
||||||
def get_ostree_option(optionstring):
|
def get_ostree_option(optionstring):
|
||||||
for o in optionstring.split():
|
for o in optionstring.split():
|
||||||
|
|
@ -65,7 +65,7 @@ for fname in os.listdir(loaderpath):
|
||||||
v = line[s+1:]
|
v = line[s+1:]
|
||||||
entry[k] = v
|
entry[k] = v
|
||||||
entries.append(entry)
|
entries.append(entry)
|
||||||
entries.sort(compare_entries_descending)
|
entries.sort(key=entry_get_version, reverse=True)
|
||||||
|
|
||||||
# Parse SYSLINUX config
|
# Parse SYSLINUX config
|
||||||
with open(syslinuxpath) as f:
|
with open(syslinuxpath) as f:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue