|
10 | 10 | $ python check_times.py
|
11 | 11 | """
|
12 | 12 |
|
| 13 | +import argparse |
13 | 14 | import gzip
|
14 | 15 | import tomllib
|
15 | 16 | from pathlib import Path
|
@@ -78,17 +79,38 @@ def calc_time(lines: list[str]) -> None:
|
78 | 79 |
|
79 | 80 |
|
80 | 81 | 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