Support for CafeteriaB, Bistro, Cafeteria West and Hochschule

This commit is contained in:
mmk2410 2015-12-13 00:09:40 +01:00
parent 6c95755879
commit f685c8394f
2 changed files with 22 additions and 9 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
mensaplan.json

View File

@ -27,20 +27,34 @@ def print_usage():
""" """
print("Usage:") print("Usage:")
usage = """ usage = """
./mensaplan.py print ./mensaplan.py
Um das heutige Menue auszugeben. Print the todays menu.
./mensaplan.py print [mon, thu, wed, thur, fri] ./mensaplan.py print [mon, thu, wed, thur, fri]
Um das Menue des jeweiligen Tasges auszugeben. Print the menu of the given weekday.
""" """
print(usage) print(usage)
print("mmk2410 (c) 2015 MIT License") print("mmk2410 (c) 2015 MIT License")
if len(sys.argv) >= 2: if len(sys.argv) >= 2:
cmd = sys.argv[1] cmd = sys.argv[1]
if cmd == "print": if cmd == "help":
print_usage()
else:
if cmd == "mensa":
place = "Mensa"
elif cmd == "bistro":
place = "Bistro"
elif cmd == "cafeteriab":
place = "CB"
elif cmd == "west":
place = "West"
elif cmd == "hochschule":
place = "Prittwitzstr"
else:
print("You have to give a place as a agrument")
plan = get() plan = get()
print("Mensplan:") print("Menu:")
day = datetime.datetime.today().weekday() day = datetime.datetime.today().weekday()
if len(sys.argv) == 3: if len(sys.argv) == 3:
if sys.argv[2] == "mon": if sys.argv[2] == "mon":
@ -56,11 +70,9 @@ if len(sys.argv) >= 2:
else: else:
day = 5 day = 5
if day > 4: if day > 4:
print("Heute gibt es nichts zu essen. Bloed gelaufen :(") print("There is no information about the menu today.")
exit(5) exit(5)
for meal in plan["weeks"][1]["days"][day]["Mensa"]["meals"]: for meal in plan["weeks"][1]["days"][day][place]["meals"]:
print(meal["category"] + ": " + meal["meal"]) print(meal["category"] + ": " + meal["meal"])
else:
print_usage()
else: else:
print_usage() print_usage()