Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [PATCH i-g-t] scripts/doc_to_xls.py: fix spreadsheet generation
Date: Tue,  2 Apr 2024 10:57:02 +0200	[thread overview]
Message-ID: <20240402085702.830658-1-mauro.chehab@linux.intel.com> (raw)

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

The logic which sets the max_length is wrong: it shall always use
sheet[0], as this may be the only only row on a table.

Yet, it might be possible that a caller to test_to_xls() would
have been sending a completely empty sheet. While this doesn't
occur currently, it doesn't hurt adding an explicit check,
reporting a warning if this is indeed the case.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 scripts/doc_to_xls.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/scripts/doc_to_xls.py b/scripts/doc_to_xls.py
index 448ff18429b6..3b10a6e9ae83 100755
--- a/scripts/doc_to_xls.py
+++ b/scripts/doc_to_xls.py
@@ -16,6 +16,8 @@ from openpyxl.styles import Font
 from openpyxl.utils import get_column_letter
 from openpyxl import Workbook
 
+from sys import stderr
+
 from test_list import TestList
 
 EPILOG = """
@@ -47,16 +49,20 @@ def tests_to_xls(tests, fname):
         test = tests[row]
         sheet_name = test.title
 
+        sheet = test.get_spreadsheet(expand_fields)
+        # Ignore empty sheets
+        if not len(sheet):
+            print(f"Warning: sheet '{test.title}' is empty!", file=stderr)
+            continue
+
         if not ws:
             ws = wb.active
             ws.title = sheet_name
         else:
             ws = wb.create_sheet(sheet_name)
 
-        sheet = test.get_spreadsheet(expand_fields)
-
         max_length = []
-        for col in range(len(sheet[row])):
+        for col in range(len(sheet[0])):
             max_length.append(0)
 
         for row in range(len(sheet)):
-- 
2.44.0


             reply	other threads:[~2024-04-02  8:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02  8:57 Mauro Carvalho Chehab [this message]
2024-04-02 11:41 ` ✓ Fi.CI.BAT: success for scripts/doc_to_xls.py: fix spreadsheet generation Patchwork
2024-04-02 12:10 ` ✓ CI.xeBAT: " Patchwork
2024-04-02 12:22 ` [PATCH i-g-t] " Kamil Konieczny
2024-04-02 22:44 ` ✗ Fi.CI.IGT: failure for " Patchwork
2024-04-04 11:32   ` Kamil Konieczny

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=20240402085702.830658-1-mauro.chehab@linux.intel.com \
    --to=mauro.chehab@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox