|
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,36 @@ 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 | + 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