forked from patricksanders/marta-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (36 loc) · 1.05 KB
/
main.py
File metadata and controls
50 lines (36 loc) · 1.05 KB
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 json
from getVehicles import getBuses, getTrains
def main():
route = ""
# Input function to obtain route number from user
route = getInput("route")
# Call getBuses function with user-defined route number
getBuses(route)
station = ""
# Input function to obtain route number from user
station = getInput("station")
# Call getBuses function with user-defined route number
getTrains(station)
def usage():
print("\n\n--help\n\nThis is how you use it.\n\n")
def getInput(mode):
vehicle = ""
if (mode == "route"):
vehicle = "Buses"
else:
vehicle = "Trains"
message = '\n\n*******Get' + vehicle + '*******\n\nPlease enter a route number\n\n(leave blank for all routes)\n\n(type \'?\' for a list of ' + mode + 's)\n\n'
userInput = input(message)
if (userInput == "?"):
showJSON(mode)
userInput = getInput(mode)
return userInput
def showJSON(mode):
json_data = open('json')
data = json.load(json_data)
print("\n\nList of " + mode + "s:\n")
for i in data[mode]:
print(i)
json_data.close()
if __name__ == '__main__':
main()