-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.py
76 lines (56 loc) · 1.9 KB
/
publish.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
76
import argparse
from pathlib import Path
from multiprocessing import Process
from src.publish import (
StationsChangelogWriter, ElevatorsChangelogWriter, ParkingChangelogWriter
)
from src.summary import summary
PATH = Path(__file__).resolve().parent
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--stations", type=str, nargs="?",
help="Path to stations snapshots",
)
parser.add_argument(
"--elevators", type=str, nargs="?",
help="Path to elevators snapshots",
)
parser.add_argument(
"--parking", type=str, nargs="?",
help="Path to parking snapshots",
)
parser.add_argument(
"--readme", type=bool, nargs="?", default=False, const=True,
help="Render new README.md",
)
parser.add_argument(
"--website", type=bool, nargs="?", default=False, const=True,
help="Publish the frontend/ website to docs/",
)
return parser.parse_args()
def render_readme():
markdown = (PATH / "templates" / "README.md").read_text()
markdown = markdown % {
"summary_parking": summary("parking"),
"summary_elevators": summary("elevators"),
"summary_stations": summary("stations"),
}
(PATH / "README.md").write_text(markdown)
def main(args):
procs = []
if args.stations:
procs.append(Process(target=lambda : StationsChangelogWriter().publish_files(args.stations)))
if args.elevators:
procs.append(Process(target=lambda : ElevatorsChangelogWriter().publish_files(args.elevators)))
if args.parking:
procs.append(Process(target=lambda : ParkingChangelogWriter().publish_files(args.parking)))
if procs:
[t.start() for t in procs]
[t.join() for t in procs]
if args.readme:
render_readme()
if args.website:
publish_website()
if __name__ == "__main__":
main(parse_args())