commit:     962f937e460a3204d43b6772665494e1d9250d6a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  5 19:08:05 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jan  5 19:09:46 2021 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=962f937e

scripts/auto-bootstraps/analyse_result: sort triplets more complicatedly

- sort by os, vendor, cpu
- sort os by name, and its version

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 scripts/auto-bootstraps/analyse_result.py | 32 ++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/scripts/auto-bootstraps/analyse_result.py 
b/scripts/auto-bootstraps/analyse_result.py
index b2cc9bfec8..880fd64343 100755
--- a/scripts/auto-bootstraps/analyse_result.py
+++ b/scripts/auto-bootstraps/analyse_result.py
@@ -5,6 +5,7 @@ import glob
 import re
 import time
 import html
+from functools import cmp_to_key
 
 resultsdir='./results'
 
@@ -171,7 +172,36 @@ with os.scandir(resultsdir) as it:
         endc = '\033[0m'
         print("%s%30s: suc %8s  fail %8s%s" % (color, arch, suc, fail, endc))
 
-sarchs = sorted(archs, key=lambda a: '-'.join(a.split('-')[::-1]))
+def archSort(l, r):
+    """
+    Sort by os, vendor, cpu
+    """
+    lcpu, lvendor, los = l.split('-', 2)
+    losname = re.split('\d', los, 1)[0]
+    losver = los.split(losname, 1)[1]
+    rcpu, rvendor, ros = r.split('-', 2)
+    rosname = re.split('\d', ros, 1)[0]
+    rosver = ros.split(rosname, 1)[1]
+
+    if losname > rosname:
+        return 1
+    if losname < rosname:
+        return -1
+    if float(losver) > float(rosver):
+        return 1
+    if float(losver) < float(rosver):
+        return -1
+    if lvendor > rvendor:
+        return 1
+    if lvendor < rvendor:
+        return -1
+    if lcpu > rcpu:
+        return 1
+    if lcpu < rcpu:
+        return -1
+    return 0
+
+sarchs = sorted(archs, key=cmp_to_key(archSort))
 
 def gentags(infos):
     tags = ''

Reply via email to