All of lore.kernel.org
 help / color / mirror / Atom feed
From: sireesha.nakkala@toshiba-tsip.com
To: tim.bird@sony.com
Cc: kazuhiro3.hayashi@toshiba.co.jp, fuego@lists.linuxfoundation.org,
	dinesh.kumar@toshiba-tsip.com,
	Shivanand Kunijadar <Shivanand.Kunijadar@toshiba-tsip.com>,
	sireesha <sireesha.nakkala@toshiba-tsip.com>
Subject: [Fuego] [PATCH 7/8] Fix TypeError: sort() takes no positional arguments in python3
Date: Wed, 20 Apr 2022 15:41:39 +0530	[thread overview]
Message-ID: <20220420101140.27182-8-sireesha.nakkala@toshiba-tsip.com> (raw)
In-Reply-To: <20220420101140.27182-1-sireesha.nakkala@toshiba-tsip.com>

From: sireesha <sireesha.nakkala@toshiba-tsip.com>

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 <sireesha.nakkala@toshiba-tsip.com>
Signed-off-by: Shivanand Kunijadar <Shivanand.Kunijadar@toshiba-tsip.com>
---
 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



  parent reply	other threads:[~2022-04-20 10:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 10:11 [Fuego] [PATCH 0/8] Python 2 & 3 compatible work sireesha.nakkala
2022-04-20 10:11 ` [Fuego] [PATCH 1/8] Create mylong function as a compatible replacement for long() sireesha.nakkala
2022-05-13 17:05   ` Bird, Tim
2022-04-20 10:11 ` [Fuego] [PATCH 2/8] ftc: Use text mode in file operation to make compatible with python3 sireesha.nakkala
2022-05-13 17:08   ` Bird, Tim
2022-04-20 10:11 ` [Fuego] [PATCH 3/8] Use file descriptor instead of file.write() sireesha.nakkala
2022-05-13 17:56   ` Bird, Tim
2022-04-20 10:11 ` [Fuego] [PATCH 4/8] Use decode() to convert bytes to string in python3 sireesha.nakkala
2022-05-13 19:06   ` Bird, Tim
2022-04-20 10:11 ` [Fuego] [PATCH 5/8] Use actual string name with replace() instead of string.replace() sireesha.nakkala
2022-05-13 19:15   ` Bird, Tim
2022-04-20 10:11 ` [Fuego] [PATCH 6/8] Replace cmp() function with equivalent expression sireesha.nakkala
2022-05-13 22:35   ` Bird, Tim
2022-04-20 10:11 ` sireesha.nakkala [this message]
2022-05-13 22:40   ` [Fuego] [PATCH 7/8] Fix TypeError: sort() takes no positional arguments in python3 Bird, Tim
2022-04-20 10:11 ` [Fuego] [PATCH 8/8] python2to3: use list() for dict.keys(), dict.values() and dict.items() sireesha.nakkala
2022-05-13 22:55   ` Bird, Tim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220420101140.27182-8-sireesha.nakkala@toshiba-tsip.com \
    --to=sireesha.nakkala@toshiba-tsip.com \
    --cc=Shivanand.Kunijadar@toshiba-tsip.com \
    --cc=dinesh.kumar@toshiba-tsip.com \
    --cc=fuego@lists.linuxfoundation.org \
    --cc=kazuhiro3.hayashi@toshiba.co.jp \
    --cc=tim.bird@sony.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.