[PATCH i-g-t 4/6] scripts/xls_to_doc.py: fix issues with python < 3.7

Mauro Carvalho Chehab mauro.chehab at linux.intel.com
Wed Mar 13 07:56:07 UTC 2024


From: Mauro Carvalho Chehab <mchehab at kernel.org>

The current logic relies on dict = sorted(dict) to preserve the
sorted order. Ordered dicts were introduced only on python 3.7.

This is a silly requirement, as all we want is to sort the
dict.item() tuple. Change the logic to avoid the need of
checking for an specific python version.

Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
---
 scripts/xls_to_doc.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/xls_to_doc.py b/scripts/xls_to_doc.py
index 7ea92a344aff..cf2cfe2fe233 100755
--- a/scripts/xls_to_doc.py
+++ b/scripts/xls_to_doc.py
@@ -17,6 +17,7 @@ from openpyxl import load_workbook
 
 from test_list import TestList
 
+
 #
 # FillTests class definition
 #
@@ -127,7 +128,7 @@ class FillTests(TestList):
 
             self.process_spreadsheet_sheet(sheet)
 
-        return dict(sorted(self.spreadsheet_data.items()))
+        return self.spreadsheet_data
 
     def change_value(self, content, subtest, line, field, value):
 
@@ -190,7 +191,7 @@ class FillTests(TestList):
 
         data = self.read_spreadsheet_file(fname, sheets)
 
-        for test, row in data.items():
+        for test, row in sorted(data.items()):
             match = self.testname_regex.match(test)
             if not match:
                 sys.exit(f"Error: can't parse {test}")
-- 
2.43.2



More information about the igt-dev mailing list