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 6/6] scripts/xls_to_doc.py: don't be verbose by default
Date: Wed, 13 Mar 2024 08:56:09 +0100	[thread overview]
Message-ID: <20240313075813.1114081-7-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 verbosity parameter to hide messages used mostly for debugging
purposes, as, on several cases, the output may be misleading.

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

diff --git a/scripts/xls_to_doc.py b/scripts/xls_to_doc.py
index 477a1561ee16..a7eaeead1a49 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
+# pylint: disable=C0301,R0912,R0913,R0914,R0915,R1702
 # SPDX-License-Identifier: (GPL-2.0 OR MIT)
 
 ## Copyright (C) 2023    Intel Corporation                 ##
@@ -28,11 +28,13 @@ class FillTests(TestList):
     Fill documentation source code test comments from a spreadsheet.
     """
 
-    def __init__(self, config_path):
+    def __init__(self, config_path, verbose):
         self.tests = {}
         self.spreadsheet_data = {}
         self.ignore_fields = []
+        self.verbose = verbose
 
+        # Read current documentation
         TestList.__init__(self, config_path)
 
         self.testname_regex = re.compile(r'^\s*(igt@[^\n\@]+)\@?(\S*)\s*')
@@ -236,7 +238,7 @@ class FillTests(TestList):
                 subtest = ''
 
             if testname not in self.tests:
-                print(f"Ignoring {test}, as test is not documented.")
+                print(f"Warning: {testname} file is not present at JSON config file.")
                 continue
 
             if subtest not in self.tests[testname]["subtests"]:
@@ -272,7 +274,10 @@ class FillTests(TestList):
                 subtest_nr = subtest_content['subtest_nr']
 
                 if subtest_nr not in self.doc[test_nr]["subtest"]:
-                    print(f"Error: missing subtest {subtest_nr} at {self.doc[test_nr]['subtest']}")
+                    if self.verbose:
+                        print(f"Error: missing subtest {subtest_nr} at {self.doc[test_nr]['subtest']}")
+                    else:
+                        print(f"Warning: test {testname}, subtest {subtest} is not documented.")
                     continue
 
                 doc_content = self.doc[test_nr]["subtest"][subtest_nr]
@@ -292,11 +297,13 @@ class FillTests(TestList):
                             print(f"Warning: {subtest} field {field} has wildcards.")
                             continue
                         if doc_value == value:
-                            print(f"{testname}@{subtest} field {field}: Value unchanged. Ignoring it")
+                            if self.verbose > 1:
+                                print(f"{testname}@{subtest} field {field}: Value unchanged. Ignoring it")
                             continue
 
-                    print(f"Update {testname}@{subtest} field {field} on line {line}:")
-                    print(f"  Change from {doc_value} to {value}")
+                    if self.verbose > 0:
+                        print(f"Update {testname}@{subtest} field {field} on line {line}:")
+                        print(f"  Change from {doc_value} to {value}")
 
                     # Just in case, handle continuation lines
                     value = re.sub(r"\n", "\n *   ", value)
@@ -320,7 +327,9 @@ class FillTests(TestList):
 
         # Write changes
         try:
-            print(f"Writing to {sourcename}")
+            if self.verbose:
+                print(f"Writing to {sourcename}")
+
             with open(sourcename, 'w', encoding='utf8') as out_fp:
                 out_fp.write("".join(content))
         except EnvironmentError:
@@ -331,6 +340,9 @@ class FillTests(TestList):
         Populate all test files with the documentation from self.tests.
         """
 
+        if self.verbose == 0:
+            print("Update source files")
+
         for testname in self.tests:
             self.update_test_file(testname, args)
 
@@ -353,11 +365,11 @@ def main():
                         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.")
-
+    parser.add_argument('-v', '--verbose', action='count', default=0)
 
     parse_args = parser.parse_args()
 
-    fill_test = FillTests(parse_args.config)
+    fill_test = FillTests(parse_args.config, parse_args.verbose)
 
     fill_test.parse_spreadsheet(parse_args.xls, parse_args.sheets)
 
-- 
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 ` [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 ` [PATCH i-g-t 5/6] scripts/xls_to_doc.py: document all functions Mauro Carvalho Chehab
2024-03-13  7:56 ` Mauro Carvalho Chehab [this message]
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-7-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.