Skip to content

Commit 5453926

Browse files
authored
Add options to only show certain build times (#307)
1 parent 0f2598a commit 5453926

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

check_times.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
$ python check_times.py
1111
"""
1212

13+
import argparse
1314
import gzip
1415
import tomllib
1516
from pathlib import Path
@@ -78,17 +79,36 @@ def calc_time(lines: list[str]) -> None:
7879

7980

8081
if __name__ == "__main__":
81-
print("Build times (HTML only; English)")
82-
print("=======================")
83-
print()
84-
calc_time(get_lines("docsbuild-only-html-en.log"))
85-
86-
print("Build times (HTML only)")
87-
print("=======================")
88-
print()
89-
calc_time(get_lines("docsbuild-only-html.log"))
90-
91-
print("Build times (no HTML)")
92-
print("=====================")
93-
print()
94-
calc_time(get_lines("docsbuild-no-html.log"))
82+
parser = argparse.ArgumentParser(
83+
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
84+
)
85+
ALL_BUILDS = ("no-html", "only-html", "only-html-en")
86+
parser.add_argument(
87+
"--select-output",
88+
choices=ALL_BUILDS,
89+
nargs="*",
90+
help="Choose what builds to show (default: all).",
91+
)
92+
args = parser.parse_args()
93+
parser.suggest_on_error = True
94+
95+
if not args.select_output:
96+
args.select_output = ALL_BUILDS
97+
98+
if "only-html-en" in args.select_output:
99+
print("Build times (HTML only; English)")
100+
print("=======================")
101+
print()
102+
calc_time(get_lines("docsbuild-only-html-en.log"))
103+
104+
if "only-html" in args.select_output:
105+
print("Build times (HTML only)")
106+
print("=======================")
107+
print()
108+
calc_time(get_lines("docsbuild-only-html.log"))
109+
110+
if "no-html" in args.select_output:
111+
print("Build times (no HTML)")
112+
print("=====================")
113+
print()
114+
calc_time(get_lines("docsbuild-no-html.log"))

0 commit comments

Comments
 (0)