tests/bootloader-entries-crosscheck: Use Python 3-friendly sorting
authorSimon McVittie <smcv@debian.org>
Wed, 17 Jan 2018 15:19:12 +0000 (15:19 +0000)
committerSimon McVittie <smcv@debian.org>
Wed, 17 Jan 2018 15:34:46 +0000 (15:34 +0000)
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>
Gbp-Pq: Name tests-bootloader-entries-crosscheck-Use-Python-3-friendly.patch

tests/bootloader-entries-crosscheck.py

index 38e8e4516a5ac26dd722b25498bf7fcb611e528f..5faa5487c346cca3e8da6d27aeb9f1b7c55114fc 100755 (executable)
@@ -38,8 +38,8 @@ def fatal(msg):
     sys.stderr.write('\n')
     sys.exit(1)
 
-def compare_entries_descending(a, b):
-    return int(b['version']) - int(a['version'])
+def entry_get_version(entry):
+    return int(entry['version'])
 
 def get_ostree_option(optionstring):
     for o in optionstring.split():
@@ -65,7 +65,7 @@ for fname in os.listdir(loaderpath):
             v = line[s+1:]
             entry[k] = v
         entries.append(entry)
-    entries.sort(compare_entries_descending)
+    entries.sort(key=entry_get_version, reverse=True)
 
 # Parse SYSLINUX config
 with open(syslinuxpath) as f: