[PATCH i-g-t] scripts/doc_to_xls.py: fix spreadsheet generation
Kamil Konieczny
kamil.konieczny at linux.intel.com
Tue Apr 2 12:22:16 UTC 2024
Hi Mauro,
On 2024-04-02 at 10:57:02 +0200, Mauro Carvalho Chehab wrote:
> From: Mauro Carvalho Chehab <mchehab at 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.
s/only only/only/
With this fixed,
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
>
> 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 at 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
>
More information about the igt-dev
mailing list