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

Mauro Carvalho Chehab mauro.chehab at linux.intel.com
Thu Mar 14 10:29:15 UTC 2024


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

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.

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

diff --git a/scripts/xls_to_doc.py b/scripts/xls_to_doc.py
index 0aa774e811a3..749666faf41f 100755
--- a/scripts/xls_to_doc.py
+++ b/scripts/xls_to_doc.py
@@ -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
 
-- 
2.43.2



More information about the igt-dev mailing list