All of lore.kernel.org
 help / color / mirror / Atom feed
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 3/6] scripts/xls_to_doc.py: cleanup argparse logic
Date: Wed, 13 Mar 2024 08:56:06 +0100	[thread overview]
Message-ID: <20240313075813.1114081-4-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 new parameter to optionally generate JSON debug files;
- don't use default formatter;
- don't use args SUPRESS;
- don't use an empty epilog.

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

diff --git a/scripts/xls_to_doc.py b/scripts/xls_to_doc.py
index 696fccd64a2b..7ea92a344aff 100755
--- a/scripts/xls_to_doc.py
+++ b/scripts/xls_to_doc.py
@@ -17,8 +17,6 @@ from openpyxl import load_workbook
 
 from test_list import TestList
 
-EPILOG = ""
-
 #
 # FillTests class definition
 #
@@ -300,10 +298,7 @@ class FillTests(TestList):
 
 
 def main():
-    parser = argparse.ArgumentParser(description=__doc__,
-                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter,
-                                     argument_default=argparse.SUPPRESS,
-                                     epilog=EPILOG)
+    parser = argparse.ArgumentParser(description=__doc__)
     parser.add_argument("--config", required=True,
                         help="JSON file describing the test plan template")
     parser.add_argument("--xls", required=True,
@@ -312,21 +307,24 @@ def main():
                         help="Input only some specific sheets from the XLS file.")
     parser.add_argument('--ignore-lists', action='store_false', default=True,
                         help='Ignore fields that are updated via test lists')
+    parser.add_argument("--store-json", action="store_true",
+                        help="Generate JSON files with documentation. Useful for debugging purposes.")
+
 
     parse_args = parser.parse_args()
 
     fill_test = FillTests(parse_args.config)
 
-    if "sheets" not in parse_args:
-        parse_args.sheets = None
-
     fill_test.parse_spreadsheet(parse_args.xls, parse_args.sheets)
 
-    # DEBUG: remove it later on
-    with open("fill_test.json", "w", encoding='utf8') as write_file:
-        json.dump(fill_test.tests, write_file, indent=4)
-    with open("doc.json", "w", encoding='utf8') as write_file:
-        json.dump(fill_test.doc, write_file, indent=4)
+    if "store_json" in parse_args:
+        print("Generating fill_test.json debug file")
+        with open("fill_test.json", "w", encoding='utf8') as write_file:
+            json.dump(fill_test.tests, write_file, indent=4)
+
+        print("Generating doc.json debug file")
+        with open("doc.json", "w", encoding='utf8') as write_file:
+            json.dump(fill_test.doc, write_file, indent=4)
 
     fill_test.update_test_files(parse_args)
 
-- 
2.43.2


  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 ` Mauro Carvalho Chehab [this message]
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 ` [PATCH i-g-t 5/6] scripts/xls_to_doc.py: document all functions Mauro Carvalho Chehab
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-4-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.