diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-02-10 13:22:25 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-02-10 14:18:00 +0100 |
commit | 9f8fc934818c3ae7473fe6258056bc7c7bf9f718 (patch) | |
tree | a95e9e77c9d5b1b98152a6dda8d70d6ce19f7e5f /tools | |
parent | 609bd8121b9a45846b236ecf51226da026651d51 (diff) |
Silence the example_gallery tool
Add a --quiet option and use that for quiet builds.
Pick-to: 6.0
Task-number: PYSIDE-1490
Change-Id: I6b8a3fa159acb85dee5fbc064991a09a9fa6ceda
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/example_gallery/main.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tools/example_gallery/main.py b/tools/example_gallery/main.py index bdb983014..afacab628 100644 --- a/tools/example_gallery/main.py +++ b/tools/example_gallery/main.py @@ -38,7 +38,7 @@ ############### -""" +DESCRIPTION = """ This tool reads all the examples from the main repository that have a '.pyproject' file, and generates a special table/gallery in the documentation page. @@ -48,12 +48,16 @@ For the usage, simply run: since there is no special requirements. """ +from argparse import ArgumentParser, RawTextHelpFormatter import json import math from pathlib import Path from textwrap import dedent +opt_quiet = False + + def ind(x): return " " * 4 * x @@ -136,6 +140,12 @@ if __name__ == "__main__": columns = 5 gallery = "" + parser = ArgumentParser(description=DESCRIPTION, + formatter_class=RawTextHelpFormatter) + parser.add_argument('--quiet', '-q', action='store_true', + help='Quiet') + options = parser.parse_args() + opt_quiet = options.quiet # This main loop will be in charge of: # * Getting all the .pyproject files, @@ -193,9 +203,11 @@ if __name__ == "__main__": content_f += add_indent(_content, 1) content_f += "\n\n" out_f.write(content_f) - print(f"Written: {EXAMPLES_DOC}/{rst_file}") + if not opt_quiet: + print(f"Written: {EXAMPLES_DOC}/{rst_file}") else: - print("Empty '.pyproject' file, skipping") + if not opt_quiet: + print("Empty '.pyproject' file, skipping") base_content = dedent("""\ .. @@ -253,4 +265,5 @@ if __name__ == "__main__": for i in index_files: f.write(f" {i}\n") - print(f"Written index: {EXAMPLES_DOC}/index.rst") + if not opt_quiet: + print(f"Written index: {EXAMPLES_DOC}/index.rst") |