Skip to content

Commit c3bc0bd

Browse files
committed
Add options to only show certain build times
1 parent 599b4ff commit c3bc0bd

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

check_times.py

Lines changed: 36 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,38 @@ 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+
parser.add_argument(
86+
"--html-en", action="store_true", help="Show HTML-only (English) build times"
87+
)
88+
parser.add_argument(
89+
"--html", action="store_true", help="Show HTML-only build times"
90+
)
91+
parser.add_argument(
92+
"--no-html", action="store_true", help="Show no-HTML build times"
93+
)
94+
args = parser.parse_args()
95+
96+
# If none specified, show all
97+
if not (args.html_en or args.html or args.no_html):
98+
args.html_en = args.html = args.no_html = True
99+
100+
if args.html_en:
101+
print("Build times (HTML only; English)")
102+
print("=======================")
103+
print()
104+
calc_time(get_lines("docsbuild-only-html-en.log"))
105+
106+
if args.html:
107+
print("Build times (HTML only)")
108+
print("=======================")
109+
print()
110+
calc_time(get_lines("docsbuild-only-html.log"))
111+
112+
if args.no_html:
113+
print("Build times (no HTML)")
114+
print("=====================")
115+
print()
116+
calc_time(get_lines("docsbuild-no-html.log"))

0 commit comments

Comments
 (0)