-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelps.py
75 lines (63 loc) · 2.29 KB
/
helps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import subprocess
import sys
from pathlib import Path
def write_output(file, text):
for line in text.splitlines():
file.write(f"\t{line}\n")
file.write("\n")
def generate_help_files():
output_path = Path(__file__).parent / "source" / "usage" / "helps"
output_path.mkdir(parents=True, exist_ok=True)
with open(output_path / "dgcv.rst", "w") as file:
file.write(".. code-block:: console\n\n")
output = subprocess.run(
["dgcv", "--help"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
)
write_output(file, output.stdout)
with open(output_path / "anonymize.rst", "w") as file:
file.write(".. code-block:: console\n\n")
output = subprocess.run(
["dgcv", "anonymize", "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
write_output(file, output.stdout)
with open(output_path / "compile.rst", "w") as file:
file.write(".. code-block:: console\n\n")
output = subprocess.run(
["dgcv", "compile", "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
write_output(file, output.stdout)
with open(output_path / "generate.rst", "w") as file:
file.write(".. code-block:: console\n\n")
output = subprocess.run(
["dgcv", "generate", "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
write_output(file, output.stdout)
with open(output_path / "performance.rst", "w") as file:
file.write(".. code-block:: console\n\n")
output = subprocess.run(
["dgcv", "performance", "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
write_output(file, output.stdout)
with open(output_path / "validate.rst", "w") as file:
file.write(".. code-block:: console\n\n")
output = subprocess.run(
["dgcv", "validate", "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
write_output(file, output.stdout)
if __name__ == "__main__":
sys.exit(generate_help_files())