From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Katarzyna Piecielska <katarzyna.piecielska@intel.com>
Subject: [PATCH i-g-t 5/6] scripts/xls_to_doc.py: document all functions
Date: Wed, 13 Mar 2024 08:56:08 +0100 [thread overview]
Message-ID: <20240313075813.1114081-6-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20240313075813.1114081-1-mauro.chehab@linux.intel.com>
From: Mauro Carvalho Chehab <mchehab@kernel.org>
Add a short description of what function does.
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
scripts/xls_to_doc.py | 47 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 45 insertions(+), 2 deletions(-)
diff --git a/scripts/xls_to_doc.py b/scripts/xls_to_doc.py
index cf2cfe2fe233..477a1561ee16 100755
--- a/scripts/xls_to_doc.py
+++ b/scripts/xls_to_doc.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# pylint: disable=C0301,R0912,R0913,R0914,R0915,C0116
+# pylint: disable=C0301,R0912,R0913,R0914,R0915
# SPDX-License-Identifier: (GPL-2.0 OR MIT)
## Copyright (C) 2023 Intel Corporation ##
@@ -77,6 +77,10 @@ class FillTests(TestList):
self.ignore_fields.append(field)
def add_field(self, dic, field, value):
+ """
+ Add a value to a field, alphabetically sorting it.
+ """
+
if field in dic and dic[field] != '':
fields = sorted(dic[field].split(", "))
fields.append(value)
@@ -86,6 +90,13 @@ class FillTests(TestList):
def process_spreadsheet_sheet(self, sheet):
+ """
+ Convert a single sheet into a dictionary.
+
+ Please notice that an empty row means to ignore the rest of the
+ sheet.
+ """
+
column_list = []
for cell in sheet[1]:
column_list.append(cell.value)
@@ -117,6 +128,10 @@ class FillTests(TestList):
i += 1
def read_spreadsheet_file(self, fname, sheets):
+ """
+ Read a XLS file, processing all sheets and returing a dict with
+ all lines from all sheets altogether.
+ """
# Iterate the loop to read the cell values
wb = load_workbook(filename=fname)
@@ -131,6 +146,9 @@ class FillTests(TestList):
return self.spreadsheet_data
def change_value(self, content, subtest, line, field, value):
+ """
+ Change the contents of a source file to update its documentation.
+ """
current_field = None
i = line
@@ -185,6 +203,21 @@ class FillTests(TestList):
content.insert(i, f' * {field}: {value}\n')
def parse_spreadsheet(self, fname, sheets=None):
+ """
+ Convert a spreadsheet file into a recursive dictionary.
+
+ It assumes that the first column at the parsed sheets will contain
+ an IGT test name in the format:
+
+ igt@<testname>@<subtest>
+
+ And the other columns will have the field name at the first line.
+
+ On success, it will return a dictionary with this format:
+
+ self.tests[testname]["subtests"][subtest][field] = value
+ """
+
if not os.path.isfile(fname):
print(f'Warning: {fname} not found. Skipping spreadsheet parser')
return
@@ -213,6 +246,12 @@ class FillTests(TestList):
self.tests[testname]["subtests"][subtest][key] = value
def update_test_file(self, testname, args):
+ """
+ Update a C source file using the contents of self.tests as
+ the source of data to be filled at the igt_doc documentation
+ comments.
+ """
+
try:
sourcename = self.tests[testname]["File"]
with open(sourcename, 'r', encoding='utf8') as in_fp:
@@ -288,7 +327,9 @@ class FillTests(TestList):
print(f'Failed to write to {sourcename}')
def update_test_files(self, args):
- """ Populate documentation """
+ """
+ Populate all test files with the documentation from self.tests.
+ """
for testname in self.tests:
self.update_test_file(testname, args)
@@ -299,6 +340,8 @@ class FillTests(TestList):
def main():
+ """Main program"""
+
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--config", required=True,
help="JSON file describing the test plan template")
--
2.43.2
next prev parent reply other threads:[~2024-03-13 7:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 7:56 [PATCH i-g-t 0/6] Do several cleanups at scripts/xls_to_doc.py Mauro Carvalho Chehab
2024-03-13 7:56 ` [PATCH i-g-t 1/6] scripts/xls_to_doc.py: use a main() function Mauro Carvalho Chehab
2024-03-13 7:56 ` [PATCH i-g-t 2/6] scripts/xls_to_doc.py: beautify its coding style Mauro Carvalho Chehab
2024-03-13 7:56 ` [PATCH i-g-t 3/6] scripts/xls_to_doc.py: cleanup argparse logic Mauro Carvalho Chehab
2024-03-13 7:56 ` [PATCH i-g-t 4/6] scripts/xls_to_doc.py: fix issues with python < 3.7 Mauro Carvalho Chehab
2024-03-13 7:56 ` Mauro Carvalho Chehab [this message]
2024-03-13 7:56 ` [PATCH i-g-t 6/6] scripts/xls_to_doc.py: don't be verbose by default Mauro Carvalho Chehab
2024-03-13 9:05 ` ✓ CI.xeBAT: success for Do several cleanups at scripts/xls_to_doc.py Patchwork
2024-03-13 9:09 ` ✓ Fi.CI.BAT: " Patchwork
2024-03-13 10:28 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-03-13 11:04 ` [PATCH i-g-t 0/6] " Piecielska, Katarzyna
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=20240313075813.1114081-6-mauro.chehab@linux.intel.com \
--to=mauro.chehab@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=katarzyna.piecielska@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.