forked from chuwyton/TokyoGTFS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_gtfs.py
50 lines (38 loc) · 1.29 KB
/
run_gtfs.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
import argparse
import time
import sys
import os
from src.static_buses import BusParser
from src.static_trains import TrainParser
from src.const import HEADER
if __name__ == "__main__":
args_parser = argparse.ArgumentParser()
args_parser.add_argument("-a", "--apikey", metavar="YOUR_APIKEY",
help="apikey from api.odpt.org")
args = args_parser.parse_args()
# Apikey checks
if args.apikey:
apikey = args.apikey
elif os.path.exists("apikey.txt"):
with open("apikey.txt", mode="r", encoding="utf8") as f:
apikey = f.read().strip()
else:
sys.exit(
"No apikey!\n"
"Provide it inside command line argument '--apikey',\n"
"Or put it inside a file named 'apikey.txt'."
)
start_time = time.time()
print(HEADER)
print("=== Trains GTFS ===")
print("Warming up")
TrainParser.parse(apikey)
total_time = time.time() - start_time
print("=== Trains GTFS: Finished in {} s ===".format(round(total_time, 2)))
start_time = time.time()
print(HEADER)
print("=== Buses GTFS ===")
print("Warming up")
BusParser.parse(apikey)
total_time = time.time() - start_time
print("=== Buses GTFS: Finished in {} s ===".format(round(total_time, 2)))