Skip to contentSkip to conversation

More improvements to scripts/xls_to_doc.py

PATCH In review Mauro Carvalho Chehab 3 participants 27 messages Mar 14, 2024 – Mar 15, 2024

lore
Share & tools
lore
#0 lore raw

cover More improvements to scripts/xls_to_doc.py

From: Mauro Carvalho Chehab <[email protected]>

Fix a series of bugs on it, and add an option to simplify the common tags at the processed files.

Mauro Carvalho Chehab (10):
scripts/xls_to_doc.py: make the message about wildcards clearer scripts/xls_to_doc.py: don't ignore the last column scripts/xls_to_doc.py: be clearer when ignoring a value in verbose
mode
scripts/xls_to_doc.py: detect field removal scripts/xls_to_doc.py: improve the addition logic scripts/xls_to_doc.py: preserve line for found fields scripts/xls_to_doc.py: don't duplicate a common field scripts/xls_to_doc.py: reduce verbosity for writing message scripts/xls_to_doc.py: better handle common attributes scripts/xls_to_doc.py: add a logic to simplify tags

 scripts/xls_to_doc.py | 201 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 172 insertions(+), 29 deletions(-)
Signature · 1 line
2.43.2
#1 lore raw

PATCH 1/10 scripts/xls_to_doc.py: make the message about wildcards clearer

From: Mauro Carvalho Chehab <[email protected]>

Automatically creating/updating wildcards is not an easy task. This script can't do it, so make it clearer that it will be skipped.

---
 scripts/xls_to_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/xls_to_doc.py +1 -1
index a7eaeead1a49..f47d56719bfe 100755
@@ -294,7 +294,7 @@ class FillTests(TestList):
                     doc_value = doc_content.get(field)
                     if doc_value:
                         if self.key_has_wildcard.search(doc_value):
-                            print(f"Warning: {subtest} field {field} has wildcards.")
+                            print(f"Warning: {subtest} field {field} has wildcards. Skipping it.")
                             continue
                         if doc_value == value:
                             if self.verbose > 1:
Signature · 1 line
2.43.2
Reviewed-by on v1 1/10
#2 lore raw

Re: [PATCH i-g-t 01/10] scripts/xls_to_doc.py: make the message about wildcards clearer

Hi Mauro,

Quoted 7 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Automatically creating/updating wildcards is not an easy task. This script can't do it, so make it clearer that it will be skipped.

Quoted 20 lines
---
 scripts/xls_to_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/xls_to_doc.py +1 -1
index a7eaeead1a49..f47d56719bfe 100755
@@ -294,7 +294,7 @@ class FillTests(TestList):
                     doc_value = doc_content.get(field)
                     if doc_value:
                         if self.key_has_wildcard.search(doc_value):
-                            print(f"Warning: {subtest} field {field} has wildcards.")
+                            print(f"Warning: {subtest} field {field} has wildcards. Skipping it.")
                             continue
                         if doc_value == value:
                             if self.verbose > 1:
Signature · 1 line
2.43.2
#3 lore raw

PATCH 2/10 scripts/xls_to_doc.py: don't ignore the last column

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Currently the last line of the spreadsheet is not processed.

---
 scripts/xls_to_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/xls_to_doc.py +1 -1
index f47d56719bfe..bd14320a3bce 100755
@@ -103,7 +103,7 @@ class FillTests(TestList):
         for cell in sheet[1]:
             column_list.append(cell.value)
 
-        for row in range(2, sheet.max_row):
+        for row in range(2, sheet.max_row + 1):
             if sheet[row][0].value is None:
                 print(f"Ignoring sheet after A{row} row, as test name is empty")
                 return
Signature · 1 line
2.43.2
Reviewed-by on v1 2/10
#4 lore raw

Re: [PATCH i-g-t 02/10] scripts/xls_to_doc.py: don't ignore the last column

Hi Mauro,

Quoted 5 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Currently the last line of the spreadsheet is not processed.

Quoted 20 lines
---
 scripts/xls_to_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/xls_to_doc.py +1 -1
index f47d56719bfe..bd14320a3bce 100755
@@ -103,7 +103,7 @@ class FillTests(TestList):
         for cell in sheet[1]:
             column_list.append(cell.value)
 
-        for row in range(2, sheet.max_row):
+        for row in range(2, sheet.max_row + 1):
             if sheet[row][0].value is None:
                 print(f"Ignoring sheet after A{row} row, as test name is empty")
                 return
Signature · 1 line
2.43.2
#5 lore raw

PATCH 3/10 scripts/xls_to_doc.py: be clearer when ignoring a value in verbose mode

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Print what value was not changed because it is duplicated.

---
 scripts/xls_to_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/xls_to_doc.py +1 -1
index bd14320a3bce..5e79a725c1d3 100755
@@ -298,7 +298,7 @@ class FillTests(TestList):
                             continue
                         if doc_value == value:
                             if self.verbose > 1:
-                                print(f"{testname}@{subtest} field {field}: Value unchanged. Ignoring it")
+                                print(f"{testname}@{subtest} field {field}: Value unchanged: {value}. Ignoring it")
                             continue
 
                     if self.verbose > 0:
Signature · 1 line
2.43.2
Reviewed-by on v1 3/10
#6 lore raw

Re: [PATCH i-g-t 03/10] scripts/xls_to_doc.py: be clearer when ignoring a value in verbose mode

Hi Mauro,

Quoted 5 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Print what value was not changed because it is duplicated.

Quoted 20 lines
---
 scripts/xls_to_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/xls_to_doc.py +1 -1
index bd14320a3bce..5e79a725c1d3 100755
@@ -298,7 +298,7 @@ class FillTests(TestList):
                             continue
                         if doc_value == value:
                             if self.verbose > 1:
-                                print(f"{testname}@{subtest} field {field}: Value unchanged. Ignoring it")
+                                print(f"{testname}@{subtest} field {field}: Value unchanged: {value}. Ignoring it")
                             continue
 
                     if self.verbose > 0:
Signature · 1 line
2.43.2
#7 lore raw

PATCH 4/10 scripts/xls_to_doc.py: detect field removal

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Eventually, a field may have been removed. Add support for detecting it at the write logic.

---
 scripts/xls_to_doc.py | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)
scripts/xls_to_doc.py +22 -14
index 5e79a725c1d3..a090dcffe98e 100755
@@ -37,6 +37,8 @@ class FillTests(TestList):
         # Read current documentation
         TestList.__init__(self, config_path)
 
+        self.orig_doc = self.doc.copy()
+
         self.testname_regex = re.compile(r'^\s*(igt@[^\n\@]+)\@?(\S*)\s*')
         self.key_has_wildcard = re.compile(r'\%?arg\[(\d+)\]')
         self.field_re = re.compile(r"(" + '|'.join(self.field_list.keys()) + r'):\s*(.*)', re.I)
@@ -202,7 +204,8 @@ class FillTests(TestList):
 
                     content[i] = ""
 
-        content.insert(i, f' * {field}: {value}\n')
+        if value != "":
+            content.insert(i, f' * {field}: {value}\n')
 
     def parse_spreadsheet(self, fname, sheets=None):
         """
@@ -265,6 +268,8 @@ class FillTests(TestList):
 
             test_nr = self.tests[testname]["Test"]
 
+            doc_content = self.orig_doc[test_nr]
+
             for subtest, subtest_content in sorted(self.tests[testname]["subtests"].items()):
                 if "line" not in subtest_content:
                     print(f"Warning: didn't find where {subtest} is documented.")
@@ -280,26 +285,29 @@ class FillTests(TestList):
                         print(f"Warning: test {testname}, subtest {subtest} is not documented.")
                     continue
 
-                doc_content = self.doc[test_nr]["subtest"][subtest_nr]
+                doc_content = self.orig_doc[test_nr]["subtest"][subtest_nr]
 
-                # Handling wildcards is not easy. Let's just skip those
-                for field, value in sorted(subtest_content.items()):
-                    if field in ['line', 'subtest_nr']:
+                fields = set(subtest_content.keys()) | set(doc_content.keys())
+
+                for field in sorted(fields):
+                    if field not in self.props:
                         continue
 
                     if args.ignore_lists:
                         if field in self.ignore_fields:
                             continue
 
-                    doc_value = doc_content.get(field)
-                    if doc_value:
-                        if self.key_has_wildcard.search(doc_value):
-                            print(f"Warning: {subtest} field {field} has wildcards. Skipping it.")
-                            continue
-                        if doc_value == value:
-                            if self.verbose > 1:
-                                print(f"{testname}@{subtest} field {field}: Value unchanged: {value}. Ignoring it")
-                            continue
+                    value = subtest_content.get(field, "")
+                    doc_value = doc_content.get(field, "")
+
+                    # Handling wildcards is not easy. Let's just skip those
+                    if self.key_has_wildcard.search(doc_value):
+                        print(f"Warning: {subtest} field {field} has wildcards. Skipping it.")
+                        continue
+                    if doc_value == value:
+                        if self.verbose > 1:
+                            print(f"{testname}@{subtest} field {field}: Value unchanged: {value}. Ignoring it")
+                        continue
 
                     if self.verbose > 0:
                         print(f"Update {testname}@{subtest} field {field} on line {line}:")
Signature · 1 line
2.43.2
Acked-by on v1 4/10
#8 lore raw

Re: [PATCH i-g-t 04/10] scripts/xls_to_doc.py: detect field removal

Hi Mauro,

Quoted 6 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Eventually, a field may have been removed. Add support for detecting it at the write logic.

Quoted 82 lines
---
 scripts/xls_to_doc.py | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)
scripts/xls_to_doc.py +22 -14
index 5e79a725c1d3..a090dcffe98e 100755
@@ -37,6 +37,8 @@ class FillTests(TestList):
         # Read current documentation
         TestList.__init__(self, config_path)
 
+        self.orig_doc = self.doc.copy()
+
         self.testname_regex = re.compile(r'^\s*(igt@[^\n\@]+)\@?(\S*)\s*')
         self.key_has_wildcard = re.compile(r'\%?arg\[(\d+)\]')
         self.field_re = re.compile(r"(" + '|'.join(self.field_list.keys()) + r'):\s*(.*)', re.I)
@@ -202,7 +204,8 @@ class FillTests(TestList):
 
                     content[i] = ""
 
-        content.insert(i, f' * {field}: {value}\n')
+        if value != "":
+            content.insert(i, f' * {field}: {value}\n')
 
     def parse_spreadsheet(self, fname, sheets=None):
         """
@@ -265,6 +268,8 @@ class FillTests(TestList):
 
             test_nr = self.tests[testname]["Test"]
 
+            doc_content = self.orig_doc[test_nr]
+
             for subtest, subtest_content in sorted(self.tests[testname]["subtests"].items()):
                 if "line" not in subtest_content:
                     print(f"Warning: didn't find where {subtest} is documented.")
@@ -280,26 +285,29 @@ class FillTests(TestList):
                         print(f"Warning: test {testname}, subtest {subtest} is not documented.")
                     continue
 
-                doc_content = self.doc[test_nr]["subtest"][subtest_nr]
+                doc_content = self.orig_doc[test_nr]["subtest"][subtest_nr]
 
-                # Handling wildcards is not easy. Let's just skip those
-                for field, value in sorted(subtest_content.items()):
-                    if field in ['line', 'subtest_nr']:
+                fields = set(subtest_content.keys()) | set(doc_content.keys())
+
+                for field in sorted(fields):
+                    if field not in self.props:
                         continue
 
                     if args.ignore_lists:
                         if field in self.ignore_fields:
                             continue
 
-                    doc_value = doc_content.get(field)
-                    if doc_value:
-                        if self.key_has_wildcard.search(doc_value):
-                            print(f"Warning: {subtest} field {field} has wildcards. Skipping it.")
-                            continue
-                        if doc_value == value:
-                            if self.verbose > 1:
-                                print(f"{testname}@{subtest} field {field}: Value unchanged: {value}. Ignoring it")
-                            continue
+                    value = subtest_content.get(field, "")
+                    doc_value = doc_content.get(field, "")
+
+                    # Handling wildcards is not easy. Let's just skip those
+                    if self.key_has_wildcard.search(doc_value):
+                        print(f"Warning: {subtest} field {field} has wildcards. Skipping it.")
+                        continue
+                    if doc_value == value:
+                        if self.verbose > 1:
+                            print(f"{testname}@{subtest} field {field}: Value unchanged: {value}. Ignoring it")
+                        continue
 
                     if self.verbose > 0:
                         print(f"Update {testname}@{subtest} field {field} on line {line}:")
Signature · 1 line
2.43.2
#9 lore raw

PATCH 5/10 scripts/xls_to_doc.py: improve the addition logic

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

If the last line before inserting a new value is a blank comment, add the new fiels before that.

---
 scripts/xls_to_doc.py | 3 +++
 1 file changed, 3 insertions(+)
scripts/xls_to_doc.py +3 -0
index a090dcffe98e..0aa774e811a3 100755
@@ -205,6 +205,9 @@ class FillTests(TestList):
                     content[i] = ""
 
         if value != "":
+            if i > 2 and re.match(r'\s*\*\s*$', content[i - 1]):
+                i -= 1
+
             content.insert(i, f' * {field}: {value}\n')
 
     def parse_spreadsheet(self, fname, sheets=None):
Signature · 1 line
2.43.2
Reviewed-by on v1 5/10
#10 lore raw

Re: [PATCH i-g-t 05/10] scripts/xls_to_doc.py: improve the addition logic

Hi Mauro,

Quoted 6 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

If the last line before inserting a new value is a blank comment, add the new fiels before that.

Quoted 21 lines
---
 scripts/xls_to_doc.py | 3 +++
 1 file changed, 3 insertions(+)
scripts/xls_to_doc.py +3 -0
index a090dcffe98e..0aa774e811a3 100755
@@ -205,6 +205,9 @@ class FillTests(TestList):
                     content[i] = ""
 
         if value != "":
+            if i > 2 and re.match(r'\s*\*\s*$', content[i - 1]):
+                i -= 1
+
             content.insert(i, f' * {field}: {value}\n')
 
     def parse_spreadsheet(self, fname, sheets=None):
Signature · 1 line
2.43.2
#11 lore raw

PATCH 6/10 scripts/xls_to_doc.py: preserve line for found fields

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

By default, the update logic will place new values at the end of subtests.

Yet, if the field is already at the source file, just update the value at the line.

Please notice that the logic needs to parse the entire subtest description, as continuation lines may be present.

---
 scripts/xls_to_doc.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/xls_to_doc.py +6 -1
index 0aa774e811a3..749666faf41f 100755
@@ -155,6 +155,7 @@ class FillTests(TestList):
         """
 
         current_field = None
+        found_line = None
         i = line
         while True:
             i += 1
@@ -193,7 +194,7 @@ class FillTests(TestList):
                 current_field = self.field_list[match.group(1).lower()]
                 if current_field != field:
                     continue
-                content[i] = ""
+                found_line = i
 
             # Handle continuation lines
             if current_field:
@@ -205,6 +206,10 @@ class FillTests(TestList):
                     content[i] = ""
 
         if value != "":
+            if found_line:
+                content[found_line] = f' * {field}: {value}\n'
+                return
+
             if i > 2 and re.match(r'\s*\*\s*$', content[i - 1]):
                 i -= 1
 
Signature · 1 line
2.43.2
Acked-by on v1 6/10
#12 lore raw

Re: [PATCH i-g-t 06/10] scripts/xls_to_doc.py: preserve line for found fields

Hi Mauro,

Quoted 5 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

By default, the update logic will place new values at the end of subtests.

Quoted 7 lines

Yet, if the field is already at the source file, just update the value at the line.

Please notice that the logic needs to parse the entire subtest description, as continuation lines may be present.

Quoted 39 lines
---
 scripts/xls_to_doc.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/xls_to_doc.py +6 -1
index 0aa774e811a3..749666faf41f 100755
@@ -155,6 +155,7 @@ class FillTests(TestList):
         """
 
         current_field = None
+        found_line = None
         i = line
         while True:
             i += 1
@@ -193,7 +194,7 @@ class FillTests(TestList):
                 current_field = self.field_list[match.group(1).lower()]
                 if current_field != field:
                     continue
-                content[i] = ""
+                found_line = i
 
             # Handle continuation lines
             if current_field:
@@ -205,6 +206,10 @@ class FillTests(TestList):
                     content[i] = ""
 
         if value != "":
+            if found_line:
+                content[found_line] = f' * {field}: {value}\n'
+                return
+
             if i > 2 and re.match(r'\s*\*\s*$', content[i - 1]):
                 i -= 1
 
Signature · 1 line
2.43.2
#13 lore raw

PATCH 7/10 scripts/xls_to_doc.py: don't duplicate a common field

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

If the TEST field has the same value of the subtest one, ignore it when updating it, as the subtest on is inherited.

---
 scripts/xls_to_doc.py | 5 +++++
 1 file changed, 5 insertions(+)
scripts/xls_to_doc.py +5 -0
index 749666faf41f..0d6ad0e0b1cd 100755
@@ -317,6 +317,11 @@ class FillTests(TestList):
                             print(f"{testname}@{subtest} field {field}: Value unchanged: {value}. Ignoring it")
                         continue
 
+                    if value == self.doc[test_nr].get(field, ""):
+                        if self.verbose:
+                            print(f"{testname}@{subtest} field {field}: Value matches common field. Ignoring it")
+                            continue
+
                     if self.verbose > 0:
                         print(f"Update {testname}@{subtest} field {field} on line {line}:")
                         print(f"  Change from {doc_value} to {value}")
Signature · 1 line
2.43.2
Reviewed-by on v1 7/10
#14 lore raw

Re: [PATCH i-g-t 07/10] scripts/xls_to_doc.py: don't duplicate a common field

Hi Mauro,

Quoted 6 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

If the TEST field has the same value of the subtest one, ignore it when updating it, as the subtest on is inherited.

Quoted 23 lines
---
 scripts/xls_to_doc.py | 5 +++++
 1 file changed, 5 insertions(+)
scripts/xls_to_doc.py +5 -0
index 749666faf41f..0d6ad0e0b1cd 100755
@@ -317,6 +317,11 @@ class FillTests(TestList):
                             print(f"{testname}@{subtest} field {field}: Value unchanged: {value}. Ignoring it")
                         continue
 
+                    if value == self.doc[test_nr].get(field, ""):
+                        if self.verbose:
+                            print(f"{testname}@{subtest} field {field}: Value matches common field. Ignoring it")
+                            continue
+
                     if self.verbose > 0:
                         print(f"Update {testname}@{subtest} field {field} on line {line}:")
                         print(f"  Change from {doc_value} to {value}")
Signature · 1 line
2.43.2
#15 lore raw

PATCH 8/10 scripts/xls_to_doc.py: reduce verbosity for writing message

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Such log is usually uneeded. Drop it.

---
 scripts/xls_to_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/xls_to_doc.py +1 -1
index 0d6ad0e0b1cd..03feae5834d7 100755
@@ -348,7 +348,7 @@ class FillTests(TestList):
 
         # Write changes
         try:
-            if self.verbose:
+            if self.verbose > 1:
                 print(f"Writing to {sourcename}")
 
             with open(sourcename, 'w', encoding='utf8') as out_fp:
Signature · 1 line
2.43.2
Reviewed-by on v1 8/10
#16 lore raw

Re: [PATCH i-g-t 08/10] scripts/xls_to_doc.py: reduce verbosity for writing message

Hi Mauro,

Quoted 3 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Such log is usually uneeded. Drop it.

s/uneeded/unneeded/

With that,

Quoted 21 lines
---
 scripts/xls_to_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/xls_to_doc.py +1 -1
index 0d6ad0e0b1cd..03feae5834d7 100755
@@ -348,7 +348,7 @@ class FillTests(TestList):
 
         # Write changes
         try:
-            if self.verbose:
+            if self.verbose > 1:
                 print(f"Writing to {sourcename}")
 
             with open(sourcename, 'w', encoding='utf8') as out_fp:
Signature · 1 line
2.43.2
#17 lore raw

PATCH 9/10 scripts/xls_to_doc.py: better handle common attributes

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

---
 scripts/xls_to_doc.py | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
scripts/xls_to_doc.py +20 -7
index 03feae5834d7..60f7536c8839 100755
@@ -31,9 +31,10 @@ class FillTests(TestList):
     def __init__(self, config_path, verbose):
         self.tests = {}
         self.spreadsheet_data = {}
-        self.ignore_fields = []
         self.verbose = verbose
 
+        self.update_fields = []
+
         # Read current documentation
         TestList.__init__(self, config_path)
 
@@ -78,7 +79,9 @@ class FillTests(TestList):
             if "sublevel" in item["_properties_"]:
                 update = item["_properties_"].get("update-from-file")
                 if update:
-                    self.ignore_fields.append(field)
+                    continue
+
+            self.update_fields.append(field)
 
     def add_field(self, dic, field, value):
         """
@@ -276,8 +279,22 @@ class FillTests(TestList):
 
             test_nr = self.tests[testname]["Test"]
 
+            # Update common fields
             doc_content = self.orig_doc[test_nr]
+            fields = set(self.doc[test_nr].keys()) | set(doc_content.keys())
 
+            for field in sorted(fields):
+                if field not in self.update_fields:
+                    continue
+
+                value = self.doc[test_nr].get(field, "")
+                doc_value = doc_content.get(field, "")
+
+                if doc_value == value:
+                    continue
+
+
+            # Update subtest fields
             for subtest, subtest_content in sorted(self.tests[testname]["subtests"].items()):
                 if "line" not in subtest_content:
                     print(f"Warning: didn't find where {subtest} is documented.")
@@ -298,11 +315,7 @@ class FillTests(TestList):
                 fields = set(subtest_content.keys()) | set(doc_content.keys())
 
                 for field in sorted(fields):
-                    if field not in self.props:
-                        continue
-
-                    if args.ignore_lists:
-                        if field in self.ignore_fields:
+                    if field not in self.update_fields:
                             continue
 
                     value = subtest_content.get(field, "")
Signature · 1 line
2.43.2
#18 lore raw

Re: [PATCH i-g-t 09/10] scripts/xls_to_doc.py: better handle common attributes

Hi Mauro,

Quoted 2 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Please describe your changes here, use also pylint, after your patchset applied it is:

pylint scripts/xls_to_doc.py
************* Module xls_to_doc
scripts/xls_to_doc.py:422:0: W0311: Bad indentation. Found 28 spaces, expected 24 (bad-indentation) scripts/xls_to_doc.py:27:0: R0902: Too many instance attributes (8/7) (too-many-instance-attributes) scripts/xls_to_doc.py:145:8: C0103: Variable name "wb" doesn't conform to snake_case naming style (invalid-name) scripts/xls_to_doc.py:302:8: C0206: Consider iterating with .items() (consider-using-dict-items) scripts/xls_to_doc.py:366:41: W0613: Unused argument 'args' (unused-argument)

------------------------------------------------------------------
Your code has been rated at 9.84/10 (previous run: 9.82/10, +0.03)

Regards,
Kamil

Quoted 71 lines
---
 scripts/xls_to_doc.py | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
scripts/xls_to_doc.py +20 -7
index 03feae5834d7..60f7536c8839 100755
@@ -31,9 +31,10 @@ class FillTests(TestList):
     def __init__(self, config_path, verbose):
         self.tests = {}
         self.spreadsheet_data = {}
-        self.ignore_fields = []
         self.verbose = verbose
 
+        self.update_fields = []
+
         # Read current documentation
         TestList.__init__(self, config_path)
 
@@ -78,7 +79,9 @@ class FillTests(TestList):
             if "sublevel" in item["_properties_"]:
                 update = item["_properties_"].get("update-from-file")
                 if update:
-                    self.ignore_fields.append(field)
+                    continue
+
+            self.update_fields.append(field)
 
     def add_field(self, dic, field, value):
         """
@@ -276,8 +279,22 @@ class FillTests(TestList):
 
             test_nr = self.tests[testname]["Test"]
 
+            # Update common fields
             doc_content = self.orig_doc[test_nr]
+            fields = set(self.doc[test_nr].keys()) | set(doc_content.keys())
 
+            for field in sorted(fields):
+                if field not in self.update_fields:
+                    continue
+
+                value = self.doc[test_nr].get(field, "")
+                doc_value = doc_content.get(field, "")
+
+                if doc_value == value:
+                    continue
+
+
+            # Update subtest fields
             for subtest, subtest_content in sorted(self.tests[testname]["subtests"].items()):
                 if "line" not in subtest_content:
                     print(f"Warning: didn't find where {subtest} is documented.")
@@ -298,11 +315,7 @@ class FillTests(TestList):
                 fields = set(subtest_content.keys()) | set(doc_content.keys())
 
                 for field in sorted(fields):
-                    if field not in self.props:
-                        continue
-
-                    if args.ignore_lists:
-                        if field in self.ignore_fields:
+                    if field not in self.update_fields:
                             continue
 
                     value = subtest_content.get(field, "")
Signature · 1 line
2.43.2
Acked-by on v1 9/10
#19 lore raw

Re: [PATCH i-g-t 09/10] scripts/xls_to_doc.py: better handle common attributes

In reply to Mauro Carvalho Chehab

Hi Mauro,

Quoted 2 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Please add description here, with that:

Quoted 71 lines
---
 scripts/xls_to_doc.py | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
scripts/xls_to_doc.py +20 -7
index 03feae5834d7..60f7536c8839 100755
@@ -31,9 +31,10 @@ class FillTests(TestList):
     def __init__(self, config_path, verbose):
         self.tests = {}
         self.spreadsheet_data = {}
-        self.ignore_fields = []
         self.verbose = verbose
 
+        self.update_fields = []
+
         # Read current documentation
         TestList.__init__(self, config_path)
 
@@ -78,7 +79,9 @@ class FillTests(TestList):
             if "sublevel" in item["_properties_"]:
                 update = item["_properties_"].get("update-from-file")
                 if update:
-                    self.ignore_fields.append(field)
+                    continue
+
+            self.update_fields.append(field)
 
     def add_field(self, dic, field, value):
         """
@@ -276,8 +279,22 @@ class FillTests(TestList):
 
             test_nr = self.tests[testname]["Test"]
 
+            # Update common fields
             doc_content = self.orig_doc[test_nr]
+            fields = set(self.doc[test_nr].keys()) | set(doc_content.keys())
 
+            for field in sorted(fields):
+                if field not in self.update_fields:
+                    continue
+
+                value = self.doc[test_nr].get(field, "")
+                doc_value = doc_content.get(field, "")
+
+                if doc_value == value:
+                    continue
+
+
+            # Update subtest fields
             for subtest, subtest_content in sorted(self.tests[testname]["subtests"].items()):
                 if "line" not in subtest_content:
                     print(f"Warning: didn't find where {subtest} is documented.")
@@ -298,11 +315,7 @@ class FillTests(TestList):
                 fields = set(subtest_content.keys()) | set(doc_content.keys())
 
                 for field in sorted(fields):
-                    if field not in self.props:
-                        continue
-
-                    if args.ignore_lists:
-                        if field in self.ignore_fields:
+                    if field not in self.update_fields:
                             continue
 
                     value = subtest_content.get(field, "")
Signature · 1 line
2.43.2
#20 lore raw

PATCH 10/10 scripts/xls_to_doc.py: add a logic to simplify tags

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

When there are common fields at the test and they were updated, reflect the changes at the test level if all subtests have equal values at the same field(s).

---
 scripts/xls_to_doc.py | 133 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 121 insertions(+), 12 deletions(-)
scripts/xls_to_doc.py +121 -12
index 60f7536c8839..6492c5d8337a 100755
@@ -8,6 +8,7 @@
 """Import contents of a XLS file into testplan documentation."""
 
 import argparse
+import copy
 import json
 import os
 import re
@@ -38,7 +39,7 @@ class FillTests(TestList):
         # Read current documentation
         TestList.__init__(self, config_path)
 
-        self.orig_doc = self.doc.copy()
+        self.orig_doc = copy.deepcopy(self.doc)
 
         self.testname_regex = re.compile(r'^\s*(igt@[^\n\@]+)\@?(\S*)\s*')
         self.key_has_wildcard = re.compile(r'\%?arg\[(\d+)\]')
@@ -152,11 +153,26 @@ class FillTests(TestList):
 
         return self.spreadsheet_data
 
-    def change_value(self, content, subtest, line, field, value):
+    def change_value(self, content, test, subtest, line, field, value):
         """
         Change the contents of a source file to update its documentation.
         """
 
+        if test:
+            line = 0
+            while True:
+                line += 1
+                if line >= len(content):
+                    break
+
+                file_line = content[line]
+
+                match = re.match(r'^\s*\* ?TEST:\s*(.*)', file_line)
+                if match:
+                    break
+
+            line += 1
+
         current_field = None
         found_line = None
         i = line
@@ -173,11 +189,14 @@ class FillTests(TestList):
             file_line = re.sub(r'^\s*\* ?', '', file_line)
 
             match = re.match(r'^SUBTESTS?:\s*(.*)', file_line)
-            if match and match.group(1) != subtest:
-                break
+            if match:
+                if subtest and match.group(1) != subtest:
+                    break
+                if test:
+                    break
 
             match = re.match(r'^TEST:\s*(.*)', file_line)
-            if match and match.group(1) != subtest:
+            if match:
                 break
 
             match = re.match(r'arg\[(\d+)\]:\s*(.*)', file_line)
@@ -208,11 +227,22 @@ class FillTests(TestList):
 
                     content[i] = ""
 
-        if value != "":
-            if found_line:
+        if i > len(content):
+            if test:
+                print(f"Warning: coun't find doc string for test {subtest}, field {field}")
+            else:
+                print(f"Warning: coun't find doc string for subtest {subtest}, field {field} on line {line}")
+
+            return
+
+        if found_line:
+            if value != "":
                 content[found_line] = f' * {field}: {value}\n'
-                return
+            else:
+                content[found_line] = ""
+            return
 
+        if value != "":
             if i > 2 and re.match(r'\s*\*\s*$', content[i - 1]):
                 i -= 1
 
@@ -261,6 +291,78 @@ class FillTests(TestList):
             for key, value in row.items():
                 self.tests[testname]["subtests"][subtest][key] = value
 
+    def simplify_doc_strings(self):
+        """
+        Group common properties at TEST level if all subtests have identical
+        values for such property.
+        """
+
+        print("Handling common information on test from subtests")
+
+        for testname in self.tests:
+            # Get common properties
+            common = {}
+            test_nr = self.tests[testname].get("Test")
+            for key, value in self.doc[test_nr].items():
+                # Ignore description when checking common fields
+                if key.lower() == "description":
+                    continue
+
+                if key in self.update_fields:
+                    common[key] = value
+
+            # Step 1: verify common items
+            first = True
+            for subtest in sorted(list(self.tests[testname]["subtests"].keys())):
+                if subtest.count("@") > 1:
+                    print(f"Warning: don't simplify dynamic subtest: {testname}{subtest}")
+                    continue
+
+                # Store common items
+                subtest_fields = sorted(self.tests[testname]["subtests"][subtest].keys())
+                for k in subtest_fields:
+                    # Ignore description when checking common fields
+                    if k.lower() == "description":
+                        continue
+
+                    # Ignore internal fields
+                    if k not in self.update_fields:
+                        continue
+
+                    val = self.tests[testname]["subtests"][subtest][k]
+                    val = val.strip()
+                    val = re.sub(r" +", " ", val)
+                    val = re.sub(r"([^\.])\s?\n\s*([A-Z])", r"\1.\n\2", val)
+                    self.tests[testname]["subtests"][subtest][k] = val
+
+                    if first and val != '':
+                        common[k] = val
+                    else:
+                        if k not in common:
+                            continue
+                        if common[k] != val:
+                            del common[k]
+
+                first = False
+
+                # Remove keys that aren't common to all subtests
+                for k in list(common.keys()):
+                    if k not in subtest_fields:
+                        del common[k]
+
+            # Step 2: drop common items from subtests
+            for subtest, fields in list(self.tests[testname]["subtests"].items()):
+                for k, val in list(fields.items()):
+                    if k not in common:
+                        continue
+
+                    if val == common[k]:
+                        self.tests[testname]["subtests"][subtest][k] = ""
+
+            # Step 3: store the modified common properties
+            for k, val in common.items():
+                self.doc[test_nr][k] = val
+
     def update_test_file(self, testname, args):
         """
         Update a C source file using the contents of self.tests as
@@ -293,6 +395,7 @@ class FillTests(TestList):
                 if doc_value == value:
                     continue
 
+                self.change_value(content, True, testname, 0, field, value)
 
             # Update subtest fields
             for subtest, subtest_content in sorted(self.tests[testname]["subtests"].items()):
@@ -300,7 +403,6 @@ class FillTests(TestList):
                     print(f"Warning: didn't find where {subtest} is documented.")
                     continue
 
-                line = subtest_content['line']
                 subtest_nr = subtest_content['subtest_nr']
 
                 if subtest_nr not in self.doc[test_nr]["subtest"]:
@@ -310,6 +412,7 @@ class FillTests(TestList):
                         print(f"Warning: test {testname}, subtest {subtest} is not documented.")
                     continue
 
+                line = self.doc[test_nr]["_subtest_line_"][subtest_nr]
                 doc_content = self.orig_doc[test_nr]["subtest"][subtest_nr]
 
                 fields = set(subtest_content.keys()) | set(doc_content.keys())
@@ -342,7 +445,7 @@ class FillTests(TestList):
                     # Just in case, handle continuation lines
                     value = re.sub(r"\n", "\n *   ", value)
 
-                    self.change_value(content, subtest, line, field, value)
+                    self.change_value(content, False, subtest, line, field, value)
 
                     # Update line numbers after insert
                     skip = True
@@ -391,7 +494,7 @@ def main():
     parser = argparse.ArgumentParser(description=__doc__)
     parser.add_argument("--config", required=True,
                         help="JSON file describing the test plan template")
-    parser.add_argument("--xls", required=True,
+    parser.add_argument("--xls",
                         help="Input XLS file.")
     parser.add_argument("--sheets", nargs="*",
                         help="Input only some specific sheets from the XLS file.")
@@ -399,13 +502,19 @@ def main():
                         help='Ignore fields that are updated via test lists')
     parser.add_argument("--store-json", action="store_true",
                         help="Generate JSON files with documentation. Useful for debugging purposes.")
+    parser.add_argument("--simplify", action="store_true",
+                        help="Run a simplify logic to cleanup TEST common fields.")
     parser.add_argument('-v', '--verbose', action='count', default=0)
 
     parse_args = parser.parse_args()
 
     fill_test = FillTests(parse_args.config, parse_args.verbose)
 
-    fill_test.parse_spreadsheet(parse_args.xls, parse_args.sheets)
+    if parse_args.xls:
+        fill_test.parse_spreadsheet(parse_args.xls, parse_args.sheets)
+
+    if parse_args.simplify:
+        fill_test.simplify_doc_strings()
 
     if "store_json" in parse_args:
         print("Generating fill_test.json debug file")
Signature · 1 line
2.43.2
Acked-by on v1 10/10
#21 lore raw

Re: [PATCH i-g-t 10/10] scripts/xls_to_doc.py: add a logic to simplify tags

Hi Mauro,

Quoted 7 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

When there are common fields at the test and they were updated, reflect the changes at the test level if all subtests have equal values at the same field(s).

Quoted 242 lines
---
 scripts/xls_to_doc.py | 133 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 121 insertions(+), 12 deletions(-)
scripts/xls_to_doc.py +121 -12
index 60f7536c8839..6492c5d8337a 100755
@@ -8,6 +8,7 @@
 """Import contents of a XLS file into testplan documentation."""
 
 import argparse
+import copy
 import json
 import os
 import re
@@ -38,7 +39,7 @@ class FillTests(TestList):
         # Read current documentation
         TestList.__init__(self, config_path)
 
-        self.orig_doc = self.doc.copy()
+        self.orig_doc = copy.deepcopy(self.doc)
 
         self.testname_regex = re.compile(r'^\s*(igt@[^\n\@]+)\@?(\S*)\s*')
         self.key_has_wildcard = re.compile(r'\%?arg\[(\d+)\]')
@@ -152,11 +153,26 @@ class FillTests(TestList):
 
         return self.spreadsheet_data
 
-    def change_value(self, content, subtest, line, field, value):
+    def change_value(self, content, test, subtest, line, field, value):
         """
         Change the contents of a source file to update its documentation.
         """
 
+        if test:
+            line = 0
+            while True:
+                line += 1
+                if line >= len(content):
+                    break
+
+                file_line = content[line]
+
+                match = re.match(r'^\s*\* ?TEST:\s*(.*)', file_line)
+                if match:
+                    break
+
+            line += 1
+
         current_field = None
         found_line = None
         i = line
@@ -173,11 +189,14 @@ class FillTests(TestList):
             file_line = re.sub(r'^\s*\* ?', '', file_line)
 
             match = re.match(r'^SUBTESTS?:\s*(.*)', file_line)
-            if match and match.group(1) != subtest:
-                break
+            if match:
+                if subtest and match.group(1) != subtest:
+                    break
+                if test:
+                    break
 
             match = re.match(r'^TEST:\s*(.*)', file_line)
-            if match and match.group(1) != subtest:
+            if match:
                 break
 
             match = re.match(r'arg\[(\d+)\]:\s*(.*)', file_line)
@@ -208,11 +227,22 @@ class FillTests(TestList):
 
                     content[i] = ""
 
-        if value != "":
-            if found_line:
+        if i > len(content):
+            if test:
+                print(f"Warning: coun't find doc string for test {subtest}, field {field}")
+            else:
+                print(f"Warning: coun't find doc string for subtest {subtest}, field {field} on line {line}")
+
+            return
+
+        if found_line:
+            if value != "":
                 content[found_line] = f' * {field}: {value}\n'
-                return
+            else:
+                content[found_line] = ""
+            return
 
+        if value != "":
             if i > 2 and re.match(r'\s*\*\s*$', content[i - 1]):
                 i -= 1
 
@@ -261,6 +291,78 @@ class FillTests(TestList):
             for key, value in row.items():
                 self.tests[testname]["subtests"][subtest][key] = value
 
+    def simplify_doc_strings(self):
+        """
+        Group common properties at TEST level if all subtests have identical
+        values for such property.
+        """
+
+        print("Handling common information on test from subtests")
+
+        for testname in self.tests:
+            # Get common properties
+            common = {}
+            test_nr = self.tests[testname].get("Test")
+            for key, value in self.doc[test_nr].items():
+                # Ignore description when checking common fields
+                if key.lower() == "description":
+                    continue
+
+                if key in self.update_fields:
+                    common[key] = value
+
+            # Step 1: verify common items
+            first = True
+            for subtest in sorted(list(self.tests[testname]["subtests"].keys())):
+                if subtest.count("@") > 1:
+                    print(f"Warning: don't simplify dynamic subtest: {testname}{subtest}")
+                    continue
+
+                # Store common items
+                subtest_fields = sorted(self.tests[testname]["subtests"][subtest].keys())
+                for k in subtest_fields:
+                    # Ignore description when checking common fields
+                    if k.lower() == "description":
+                        continue
+
+                    # Ignore internal fields
+                    if k not in self.update_fields:
+                        continue
+
+                    val = self.tests[testname]["subtests"][subtest][k]
+                    val = val.strip()
+                    val = re.sub(r" +", " ", val)
+                    val = re.sub(r"([^\.])\s?\n\s*([A-Z])", r"\1.\n\2", val)
+                    self.tests[testname]["subtests"][subtest][k] = val
+
+                    if first and val != '':
+                        common[k] = val
+                    else:
+                        if k not in common:
+                            continue
+                        if common[k] != val:
+                            del common[k]
+
+                first = False
+
+                # Remove keys that aren't common to all subtests
+                for k in list(common.keys()):
+                    if k not in subtest_fields:
+                        del common[k]
+
+            # Step 2: drop common items from subtests
+            for subtest, fields in list(self.tests[testname]["subtests"].items()):
+                for k, val in list(fields.items()):
+                    if k not in common:
+                        continue
+
+                    if val == common[k]:
+                        self.tests[testname]["subtests"][subtest][k] = ""
+
+            # Step 3: store the modified common properties
+            for k, val in common.items():
+                self.doc[test_nr][k] = val
+
     def update_test_file(self, testname, args):
         """
         Update a C source file using the contents of self.tests as
@@ -293,6 +395,7 @@ class FillTests(TestList):
                 if doc_value == value:
                     continue
 
+                self.change_value(content, True, testname, 0, field, value)
 
             # Update subtest fields
             for subtest, subtest_content in sorted(self.tests[testname]["subtests"].items()):
@@ -300,7 +403,6 @@ class FillTests(TestList):
                     print(f"Warning: didn't find where {subtest} is documented.")
                     continue
 
-                line = subtest_content['line']
                 subtest_nr = subtest_content['subtest_nr']
 
                 if subtest_nr not in self.doc[test_nr]["subtest"]:
@@ -310,6 +412,7 @@ class FillTests(TestList):
                         print(f"Warning: test {testname}, subtest {subtest} is not documented.")
                     continue
 
+                line = self.doc[test_nr]["_subtest_line_"][subtest_nr]
                 doc_content = self.orig_doc[test_nr]["subtest"][subtest_nr]
 
                 fields = set(subtest_content.keys()) | set(doc_content.keys())
@@ -342,7 +445,7 @@ class FillTests(TestList):
                     # Just in case, handle continuation lines
                     value = re.sub(r"\n", "\n *   ", value)
 
-                    self.change_value(content, subtest, line, field, value)
+                    self.change_value(content, False, subtest, line, field, value)
 
                     # Update line numbers after insert
                     skip = True
@@ -391,7 +494,7 @@ def main():
     parser = argparse.ArgumentParser(description=__doc__)
     parser.add_argument("--config", required=True,
                         help="JSON file describing the test plan template")
-    parser.add_argument("--xls", required=True,
+    parser.add_argument("--xls",
                         help="Input XLS file.")
     parser.add_argument("--sheets", nargs="*",
                         help="Input only some specific sheets from the XLS file.")
@@ -399,13 +502,19 @@ def main():
                         help='Ignore fields that are updated via test lists')
     parser.add_argument("--store-json", action="store_true",
                         help="Generate JSON files with documentation. Useful for debugging purposes.")
+    parser.add_argument("--simplify", action="store_true",
+                        help="Run a simplify logic to cleanup TEST common fields.")
     parser.add_argument('-v', '--verbose', action='count', default=0)
 
     parse_args = parser.parse_args()
 
     fill_test = FillTests(parse_args.config, parse_args.verbose)
 
-    fill_test.parse_spreadsheet(parse_args.xls, parse_args.sheets)
+    if parse_args.xls:
+        fill_test.parse_spreadsheet(parse_args.xls, parse_args.sheets)
+
+    if parse_args.simplify:
+        fill_test.simplify_doc_strings()
 
     if "store_json" in parse_args:
         print("Generating fill_test.json debug file")
Signature · 1 line
2.43.2
#22 lore raw

[PATCH 11/10] scripts/xls_to_doc.py: make pylint happy

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Pylint is too picky. Still, it is useful to run it, as sometimes it could point to real issues.

So, let's make it happy by:
- disabling R0902, which is one of those "too many" warnings (IMO, it doesn't make sense to limit the number of times some thing can be used inside a code;

- disabling another warning about not using .items(). On that particular case, IMO it will make the code less clearer for reviewers and future maintainership, e. g.:

test_nr = self.tests[testname].get("Test")

and similar occurrences for self.tests[testname] is a lot clearer than:

	for testname, value in self.tests.items():
		...
		test_nr = value.get("Test")
		...
		value["subtests"][subtest][k] = val

	(and other similar occurrences)

ok, a better name than "value" might help, but still the obvious choice would be "test", "test_testname" and such, which just makes the code more obfuscated.

So, ignore the warning for good.

- remove a blank line before a docstring comment;

- remove a currently unused argument from update_files;

- fix indent on a single line.

No functional changes.

---
 scripts/xls_to_doc.py | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
scripts/xls_to_doc.py +7 -8
index 6492c5d8337a..50ae56477647 100755
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-# pylint: disable=C0301,R0912,R0913,R0914,R0915,R1702
+# pylint: disable=C0301,R0902,R0912,R0913,R0914,R0915,R1702
 # SPDX-License-Identifier: (GPL-2.0 OR MIT)
 
 ## Copyright (C) 2023    Intel Corporation                 ##
@@ -97,7 +97,6 @@ class FillTests(TestList):
         dic[field] = value
 
     def process_spreadsheet_sheet(self, sheet):
-
         """
         Convert a single sheet into a dictionary.
 
@@ -299,7 +298,7 @@ class FillTests(TestList):
 
         print("Handling common information on test from subtests")
 
-        for testname in self.tests:
+        for testname in self.tests:                  # pylint: disable=C0206
             # Get common properties
             common = {}
             test_nr = self.tests[testname].get("Test")
@@ -363,7 +362,7 @@ class FillTests(TestList):
             for k, val in common.items():
                 self.doc[test_nr][k] = val
 
-    def update_test_file(self, testname, args):
+    def update_test_file(self, testname):
         """
         Update a C source file using the contents of self.tests as
         the source of data to be filled at the igt_doc documentation
@@ -419,7 +418,7 @@ class FillTests(TestList):
 
                 for field in sorted(fields):
                     if field not in self.update_fields:
-                            continue
+                        continue
 
                     value = subtest_content.get(field, "")
                     doc_value = doc_content.get(field, "")
@@ -472,7 +471,7 @@ class FillTests(TestList):
         except EnvironmentError:
             print(f'Failed to write to {sourcename}')
 
-    def update_test_files(self, args):
+    def update_test_files(self):
         """
         Populate all test files with the documentation from self.tests.
         """
@@ -481,7 +480,7 @@ class FillTests(TestList):
             print("Update source files")
 
         for testname in self.tests:
-            self.update_test_file(testname, args)
+            self.update_test_file(testname)
 
 ######
 # Main
@@ -525,7 +524,7 @@ def main():
         with open("doc.json", "w", encoding='utf8') as write_file:
             json.dump(fill_test.doc, write_file, indent=4)
 
-    fill_test.update_test_files(parse_args)
+    fill_test.update_test_files()
 
 
 if __name__ == '__main__':
Signature · 1 line
2.43.2
#23 lore raw

Re: [PATCH 11/10] scripts/xls_to_doc.py: make pylint happy

Hi Mauro,

Quoted 35 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Pylint is too picky. Still, it is useful to run it, as sometimes it could point to real issues.

So, let's make it happy by:
- disabling R0902, which is one of those "too many" warnings (IMO, it doesn't make sense to limit the number of times some thing can be used inside a code;

- disabling another warning about not using .items(). On that particular case, IMO it will make the code less clearer for reviewers and future maintainership, e. g.:

test_nr = self.tests[testname].get("Test")

and similar occurrences for self.tests[testname] is a lot clearer than:

	for testname, value in self.tests.items():
		...
		test_nr = value.get("Test")
		...
		value["subtests"][subtest][k] = val

	(and other similar occurrences)

ok, a better name than "value" might help, but still the obvious choice would be "test", "test_testname" and such, which just makes the code more obfuscated.

So, ignore the warning for good.

- remove a blank line before a docstring comment;

Quoted 7 lines

- remove a currently unused argument from update_files;

- fix indent on a single line.

No functional changes.

Quoted 80 lines
---
 scripts/xls_to_doc.py | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
scripts/xls_to_doc.py +7 -8
index 6492c5d8337a..50ae56477647 100755
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-# pylint: disable=C0301,R0912,R0913,R0914,R0915,R1702
+# pylint: disable=C0301,R0902,R0912,R0913,R0914,R0915,R1702
 # SPDX-License-Identifier: (GPL-2.0 OR MIT)
 
 ## Copyright (C) 2023    Intel Corporation                 ##
@@ -97,7 +97,6 @@ class FillTests(TestList):
         dic[field] = value
 
     def process_spreadsheet_sheet(self, sheet):
-
         """
         Convert a single sheet into a dictionary.
 
@@ -299,7 +298,7 @@ class FillTests(TestList):
 
         print("Handling common information on test from subtests")
 
-        for testname in self.tests:
+        for testname in self.tests:                  # pylint: disable=C0206
             # Get common properties
             common = {}
             test_nr = self.tests[testname].get("Test")
@@ -363,7 +362,7 @@ class FillTests(TestList):
             for k, val in common.items():
                 self.doc[test_nr][k] = val
 
-    def update_test_file(self, testname, args):
+    def update_test_file(self, testname):
         """
         Update a C source file using the contents of self.tests as
         the source of data to be filled at the igt_doc documentation
@@ -419,7 +418,7 @@ class FillTests(TestList):
 
                 for field in sorted(fields):
                     if field not in self.update_fields:
-                            continue
+                        continue
 
                     value = subtest_content.get(field, "")
                     doc_value = doc_content.get(field, "")
@@ -472,7 +471,7 @@ class FillTests(TestList):
         except EnvironmentError:
             print(f'Failed to write to {sourcename}')
 
-    def update_test_files(self, args):
+    def update_test_files(self):
         """
         Populate all test files with the documentation from self.tests.
         """
@@ -481,7 +480,7 @@ class FillTests(TestList):
             print("Update source files")
 
         for testname in self.tests:
-            self.update_test_file(testname, args)
+            self.update_test_file(testname)
 
 ######
 # Main
@@ -525,7 +524,7 @@ def main():
         with open("doc.json", "w", encoding='utf8') as write_file:
             json.dump(fill_test.doc, write_file, indent=4)
 
-    fill_test.update_test_files(parse_args)
+    fill_test.update_test_files()
 
 
 if __name__ == '__main__':
Signature · 1 line
2.43.2
#24 lore raw

✓ CI.xeBAT: success for More improvements to scripts/xls_to_doc.py

In reply to Mauro Carvalho Chehab
== Series Details ==

== Series Details ==

Series: More improvements to scripts/xls_to_doc.py
URL : https://patchwork.freedesktop.org/series/131130/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_7762_BAT -> XEIGTPW_10834_BAT
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Participating hosts (4 -> 4)
------------------------------

No changes in participating hosts

Known issues
------------

Here are the changes found in XEIGTPW_10834_BAT that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@xe_exec_threads@threads-mixed-shared-vm-basic:
- bat-pvc-2: [PASS][1] -> [DMESG-WARN][2] ([Intel XE#1238])
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7762/bat-pvc-2/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10834/bat-pvc-2/igt@[email protected]

[Intel XE#1238]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/1238

Build changes
-------------

* IGT: IGT_7762 -> IGTPW_10834

IGTPW_10834: 10834
IGT_7762: 7725ae2998aed37bcc2e38926e404e5eec143451 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
xe-939-9bedef916cef04bba9e98430c1c1de637219a573: 9bedef916cef04bba9e98430c1c1de637219a573

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10834/index.html

#25 lore raw

✗ Fi.CI.BAT: failure for More improvements to scripts/xls_to_doc.py

In reply to Mauro Carvalho Chehab
== Series Details ==

== Series Details ==

Series: More improvements to scripts/xls_to_doc.py
URL : https://patchwork.freedesktop.org/series/131130/
State : failure

== Summary ==

CI Bug Log - changes from IGT_7762 -> IGTPW_10834
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_10834 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in IGTPW_10834, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/index.html

Participating hosts (37 -> 35)
------------------------------

Additional (2): bat-dg2-11 bat-mtlp-8
Missing (4): fi-blb-e6850 bat-kbl-2 fi-cfl-8109u fi-snb-2520m

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_10834:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@requests:
- bat-dg2-8: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7762/bat-dg2-8/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-8/igt@i915_selftest@[email protected]

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@i915_pm_rpm@module-reload:
- {bat-mtlp-9}: [PASS][3] -> [WARN][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7762/bat-mtlp-9/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-9/igt@[email protected]

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-nv12@pipe-d-dp-3:
- {bat-arls-4}: [PASS][5] -> [FAIL][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7762/bat-arls-4/igt@kms_pipe_crc_basic@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-arls-4/igt@kms_pipe_crc_basic@[email protected]

Known issues
------------

Here are the changes found in IGTPW_10834 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@debugfs_test@basic-hwmon:
- bat-mtlp-8: NOTRUN -> [SKIP][7] ([i915#9318])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]
- bat-jsl-1: NOTRUN -> [SKIP][8] ([i915#9318])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-jsl-1/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- bat-jsl-1: NOTRUN -> [SKIP][9] ([i915#2190])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-jsl-1/igt@[email protected]

* igt@gem_lmem_swapping@verify-random:
- bat-mtlp-8: NOTRUN -> [SKIP][10] ([i915#4613]) +3 other tests skip
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]
- bat-jsl-1: NOTRUN -> [SKIP][11] ([i915#4613]) +3 other tests skip
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-jsl-1/igt@[email protected]

* igt@gem_mmap@basic:
- bat-dg2-11: NOTRUN -> [SKIP][12] ([i915#4083])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]
- bat-mtlp-8: NOTRUN -> [SKIP][13] ([i915#4083])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]

* igt@gem_mmap_gtt@basic:
- bat-mtlp-8: NOTRUN -> [SKIP][14] ([i915#4077]) +2 other tests skip
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]

* igt@gem_render_tiled_blits@basic:
- bat-mtlp-8: NOTRUN -> [SKIP][15] ([i915#4079]) +1 other test skip
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]

* igt@gem_tiled_fence_blits@basic:
- bat-dg2-11: NOTRUN -> [SKIP][16] ([i915#4077]) +2 other tests skip
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]

* igt@gem_tiled_pread_basic:
- bat-dg2-11: NOTRUN -> [SKIP][17] ([i915#4079]) +1 other test skip
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@gem_tiled_pread_basic.html

* igt@i915_pm_rps@basic-api:
- bat-dg2-11: NOTRUN -> [SKIP][18] ([i915#6621])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]
- bat-mtlp-8: NOTRUN -> [SKIP][19] ([i915#6621])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]

* igt@kms_addfb_basic@addfb25-x-tiled-mismatch-legacy:
- bat-dg2-11: NOTRUN -> [SKIP][20] ([i915#4212]) +7 other tests skip
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]

* igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
- bat-mtlp-8: NOTRUN -> [SKIP][21] ([i915#5190])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]
- bat-dg2-11: NOTRUN -> [SKIP][22] ([i915#5190])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]

* igt@kms_addfb_basic@basic-y-tiled-legacy:
- bat-mtlp-8: NOTRUN -> [SKIP][23] ([i915#4212]) +8 other tests skip
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]
- bat-dg2-11: NOTRUN -> [SKIP][24] ([i915#4215] / [i915#5190])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- bat-dg2-11: NOTRUN -> [SKIP][25] ([i915#4103] / [i915#4213]) +1 other test skip
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- bat-mtlp-8: NOTRUN -> [SKIP][26] ([i915#4213]) +1 other test skip
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]
- bat-jsl-1: NOTRUN -> [SKIP][27] ([i915#4103]) +1 other test skip
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-jsl-1/igt@[email protected]

* igt@kms_dsc@dsc-basic:
- bat-dg2-11: NOTRUN -> [SKIP][28] ([i915#3555] / [i915#3840])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]
- bat-mtlp-8: NOTRUN -> [SKIP][29] ([i915#3555] / [i915#3840] / [i915#9159])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]
- bat-jsl-1: NOTRUN -> [SKIP][30] ([i915#3555] / [i915#9886])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-jsl-1/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- bat-mtlp-8: NOTRUN -> [SKIP][31]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]
- bat-jsl-1: NOTRUN -> [SKIP][32]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-jsl-1/igt@[email protected]
- bat-dg2-11: NOTRUN -> [SKIP][33]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]

* igt@kms_force_connector_basic@prune-stale-modes:
- bat-dg2-11: NOTRUN -> [SKIP][34] ([i915#5274])
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]
- bat-mtlp-8: NOTRUN -> [SKIP][35] ([i915#5274])
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]

* igt@kms_pm_backlight@basic-brightness:
- bat-dg2-11: NOTRUN -> [SKIP][36] ([i915#5354])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]

* igt@kms_psr@psr-primary-mmap-gtt@edp-1:
- bat-mtlp-8: NOTRUN -> [SKIP][37] ([i915#4077] / [i915#9688])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@kms_psr@[email protected]

* igt@kms_psr@psr-sprite-plane-onoff:
- bat-dg2-11: NOTRUN -> [SKIP][38] ([i915#9732]) +3 other tests skip
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]

* igt@kms_setmode@basic-clone-single-crtc:
- bat-dg2-11: NOTRUN -> [SKIP][39] ([i915#3555])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]
- bat-mtlp-8: NOTRUN -> [SKIP][40] ([i915#3555] / [i915#8809])
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]
- bat-jsl-1: NOTRUN -> [SKIP][41] ([i915#3555])
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-jsl-1/igt@[email protected]

* igt@prime_vgem@basic-fence-flip:
- bat-dg2-11: NOTRUN -> [SKIP][42] ([i915#3708])
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]

* igt@prime_vgem@basic-fence-mmap:
- bat-dg2-11: NOTRUN -> [SKIP][43] ([i915#3708] / [i915#4077]) +1 other test skip
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]
- bat-mtlp-8: NOTRUN -> [SKIP][44] ([i915#3708] / [i915#4077]) +1 other test skip
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]

* igt@prime_vgem@basic-fence-read:
- bat-mtlp-8: NOTRUN -> [SKIP][45] ([i915#3708]) +1 other test skip
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]

* igt@prime_vgem@basic-read:
- bat-dg2-11: NOTRUN -> [SKIP][46] ([i915#3291] / [i915#3708]) +2 other tests skip
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-dg2-11/igt@[email protected]

* igt@prime_vgem@basic-write:
- bat-mtlp-8: NOTRUN -> [SKIP][47] ([i915#10216] / [i915#3708])
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/bat-mtlp-8/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[i915#10216]: https://gitlab.freedesktop.org/drm/intel/issues/10216
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3840]: https://gitlab.freedesktop.org/drm/intel/issues/3840
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
[i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#8809]: https://gitlab.freedesktop.org/drm/intel/issues/8809
[i915#9159]: https://gitlab.freedesktop.org/drm/intel/issues/9159
[i915#9318]: https://gitlab.freedesktop.org/drm/intel/issues/9318
[i915#9688]: https://gitlab.freedesktop.org/drm/intel/issues/9688
[i915#9732]: https://gitlab.freedesktop.org/drm/intel/issues/9732
[i915#9886]: https://gitlab.freedesktop.org/drm/intel/issues/9886

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_7762 -> IGTPW_10834

CI-20190529: 20190529
CI_DRM_14430: 9bedef916cef04bba9e98430c1c1de637219a573 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_10834: 10834
IGT_7762: 7725ae2998aed37bcc2e38926e404e5eec143451 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10834/index.html

#26 lore raw

✗ Fi.CI.BUILD: failure for More improvements to scripts/xls_to_doc.py (rev2)

In reply to Mauro Carvalho Chehab
== Series Details ==

== Series Details ==

Series: More improvements to scripts/xls_to_doc.py (rev2)
URL : https://patchwork.freedesktop.org/series/131130/
State : failure

== Summary ==

Applying: scripts/xls_to_doc.py: make the message about wildcards clearer
Applying: scripts/xls_to_doc.py: don't ignore the last column
Applying: scripts/xls_to_doc.py: be clearer when ignoring a value in verbose mode
Applying: scripts/xls_to_doc.py: detect field removal
Applying: scripts/xls_to_doc.py: improve the addition logic
Applying: scripts/xls_to_doc.py: preserve line for found fields
Applying: scripts/xls_to_doc.py: don't duplicate a common field
Applying: scripts/xls_to_doc.py: reduce verbosity for writing message
Applying: scripts/xls_to_doc.py: better handle common attributes
Applying: scripts/xls_to_doc.py: make pylint happy
Using index info to reconstruct a base tree...
M scripts/xls_to_doc.py
Falling back to patching base and 3-way merge...
Auto-merging scripts/xls_to_doc.py
CONFLICT (content): Merge conflict in scripts/xls_to_doc.py
Patch failed at 0010 scripts/xls_to_doc.py: make pylint happy
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".