diff options
author | Mauro Carvalho Chehab <mchehab@kernel.org> | 2024-04-02 10:54:00 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2024-04-02 14:29:39 +0200 |
commit | 65f9348bee307be999118cd6c7ea8df67f4713cf (patch) | |
tree | d1afd07f7b29ca17c3deab774b9fe25c5dfe5808 /scripts | |
parent | ea51cff570e13d7ced5409244af61a0690fbc8e2 (diff) |
scripts/doc_to_xls.py: fix spreadsheet generation
The logic which sets the max_length is wrong: it shall always use
sheet[0], as this may be the 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>
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/doc_to_xls.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/scripts/doc_to_xls.py b/scripts/doc_to_xls.py index 448ff1842..3b10a6e9a 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)): |