forked from chuwyton/TokyoGTFS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrains_gtfs.py
38 lines (30 loc) · 1.01 KB
/
trains_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
import argparse
import time
import sys
import os
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: Starting! ===")
print("Warming up")
TrainParser.parse(apikey)
total_time = time.time() - start_time
print("=== TokyoGTFS: Finished in {} s ===".format(round(total_time, 2)))