[Fuego] [PATCH 7/8] Fix TypeError: sort() takes no positional arguments in python3
[email protected] Wed, 20 Apr 2022 15:41:39 +0530
| Newsgroups | dev.linux.lists.fuego |
|---|---|
| Message-ID | <[email protected]> |
From: sireesha <[email protected]> Transform an old-style comparison function to a key function. use functools.cmp_to_key(func) with sort() function to fix the issue. This change is compatible with python2 and python3. Signed-off-by: sireesha <[email protected]> Signed-off-by: Shivanand Kunijadar <[email protected]> --- scripts/parser/common.py | 5 +++-- scripts/parser/prepare_chart_data.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/parser/common.py b/scripts/parser/common.py index a04047a..8c307f1 100644 --- a/scripts/parser/common.py +++ b/scripts/parser/common.py @@ -26,7 +26,8 @@ common.py - This library contains parsing functions By Daniel Sangorrin (July 2017) """ -import sys, os, re, json, time, collections +import sys, os, re, json, time, collections, functools + from fuego_parser_utils import hls, split_test_id, get_test_case loglevel = "info" @@ -562,7 +563,7 @@ def dump_ordered_data(data, indent=""): if type(data)==type([]): print("%s[" % indent) item_list = data[:] - item_list.sort(name_compare) + item_list.sort(key=functools.cmp_to_key(name_compare)) for item in item_list: dump_ordered_data(item,indent+" ") print("%s]" % indent) diff --git a/scripts/parser/prepare_chart_data.py b/scripts/parser/prepare_chart_data.py index 9aea666..d85315e 100644 --- a/scripts/parser/prepare_chart_data.py +++ b/scripts/parser/prepare_chart_data.py @@ -32,7 +32,7 @@ the results of tests in the Jenkins interface. By Tim Bird (September 2017) """ -import sys, os, re, json, collections +import sys, os, re, json, collections, functools from filelock import FileLock from operator import itemgetter from fuego_parser_utils import split_test_id, get_test_case @@ -507,7 +507,7 @@ def make_measure_tables(test_name, chart_config, entries): # one row per test case tg_list = result_map.keys() - tg_list.sort(cmp_alpha_num) + tg_list.sort(key=functools.cmp_to_key(cmp_alpha_num)) for tg in tg_list: # break apart tguid(tc) and divide into test set and test case @@ -730,7 +730,7 @@ def make_testcase_table(test_name, chart_config, entries): # one row per test case tc_list = result_map.keys() - tc_list.sort(cmp_alpha_num) + tc_list.sort(key=functools.cmp_to_key(cmp_alpha_num)) for tc in tc_list: row = '<tr><td>' + tc + '</td>' -- 2.20.1