From c3bc0bddb2ab2ba6b70bc7afa97ca491ec9adea2 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 15 Aug 2025 18:49:37 +0300 Subject: [PATCH 1/2] Add options to only show certain build times --- check_times.py | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/check_times.py b/check_times.py index 2b3d2f9..30bb7e3 100644 --- a/check_times.py +++ b/check_times.py @@ -10,6 +10,7 @@ $ python check_times.py """ +import argparse import gzip import tomllib from pathlib import Path @@ -78,17 +79,38 @@ def calc_time(lines: list[str]) -> None: if __name__ == "__main__": - print("Build times (HTML only; English)") - print("=======================") - print() - calc_time(get_lines("docsbuild-only-html-en.log")) - - print("Build times (HTML only)") - print("=======================") - print() - calc_time(get_lines("docsbuild-only-html.log")) - - print("Build times (no HTML)") - print("=====================") - print() - calc_time(get_lines("docsbuild-no-html.log")) + parser = argparse.ArgumentParser( + description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter + ) + parser.add_argument( + "--html-en", action="store_true", help="Show HTML-only (English) build times" + ) + parser.add_argument( + "--html", action="store_true", help="Show HTML-only build times" + ) + parser.add_argument( + "--no-html", action="store_true", help="Show no-HTML build times" + ) + args = parser.parse_args() + + # If none specified, show all + if not (args.html_en or args.html or args.no_html): + args.html_en = args.html = args.no_html = True + + if args.html_en: + print("Build times (HTML only; English)") + print("=======================") + print() + calc_time(get_lines("docsbuild-only-html-en.log")) + + if args.html: + print("Build times (HTML only)") + print("=======================") + print() + calc_time(get_lines("docsbuild-only-html.log")) + + if args.no_html: + print("Build times (no HTML)") + print("=====================") + print() + calc_time(get_lines("docsbuild-no-html.log")) From 45f56e5e9785488982a9531b2d7bd7f4d4282e99 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 15 Aug 2025 19:42:44 +0300 Subject: [PATCH 2/2] Refactor to use --select-output --- check_times.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/check_times.py b/check_times.py index 30bb7e3..e3bbaea 100644 --- a/check_times.py +++ b/check_times.py @@ -82,34 +82,32 @@ def calc_time(lines: list[str]) -> None: parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter ) + ALL_BUILDS = ("no-html", "only-html", "only-html-en") parser.add_argument( - "--html-en", action="store_true", help="Show HTML-only (English) build times" - ) - parser.add_argument( - "--html", action="store_true", help="Show HTML-only build times" - ) - parser.add_argument( - "--no-html", action="store_true", help="Show no-HTML build times" + "--select-output", + choices=ALL_BUILDS, + nargs="*", + help="Choose what builds to show (default: all).", ) args = parser.parse_args() + parser.suggest_on_error = True - # If none specified, show all - if not (args.html_en or args.html or args.no_html): - args.html_en = args.html = args.no_html = True + if not args.select_output: + args.select_output = ALL_BUILDS - if args.html_en: + if "only-html-en" in args.select_output: print("Build times (HTML only; English)") print("=======================") print() calc_time(get_lines("docsbuild-only-html-en.log")) - if args.html: + if "only-html" in args.select_output: print("Build times (HTML only)") print("=======================") print() calc_time(get_lines("docsbuild-only-html.log")) - if args.no_html: + if "no-html" in args.select_output: print("Build times (no HTML)") print("=====================") print()