summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/main.py b/main.py
index f987060..3b49d66 100755
--- a/main.py
+++ b/main.py
@@ -21,10 +21,14 @@ def getweek(d):
return d.isocalendar().week + i["output"]["week_drift"]
def getgloballectureslot(d):
dname=d.strftime("%A").lower()
- if dname in i["semester"]["lectures"]["slots"].keys():
- start=datetime.strptime(i["semester"]["lectures"]["slots"][dname]["start"], "%H:%M")
- end=datetime.strptime(i["semester"]["lectures"]["slots"][dname]["end"], "%H:%M")
- return (start,end)
+ slots=i["semester"]["lectures"]["slots"]
+ if dname in slots.keys():
+ start,end, room=(None,None,None)
+ if "start" in slots[dname].keys():
+ start=datetime.strptime(i["semester"]["lectures"]["slots"][dname]["start"], "%H:%M")
+ end=datetime.strptime(i["semester"]["lectures"]["slots"][dname]["end"], "%H:%M")
+ room=slots[dname]["room"] if "room" in slots[dname].keys() else None
+ return (start,end, room)
return None
def getassign(d):
val=""
@@ -42,16 +46,20 @@ def getlecture(d):
date=parse_date(i["lectures"][l]["date"])
if d==date:
# Time
- startT, endT = (None, None)
+ startT, endT, room = (None, None, None)
+ if slot is not None:
+ startT, endT, room=slot
if "slot" in i["lectures"][l]:
- startT=datetime.strptime(i["lectures"][l]["slot"]["start"], "%H:%M")
- endT=datetime.strptime(i["lectures"][l]["slot"]["end"], "%H:%M")
- elif slot is not None:
- startT, endT=slot
+ if "start" in i["lectures"][l]["slot"].keys():
+ startT=datetime.strptime(i["lectures"][l]["slot"]["start"], "%H:%M")
+ endT=datetime.strptime(i["lectures"][l]["slot"]["end"], "%H:%M")
+ room=i["lectures"][l]["slot"]["room"] if "room" in i["lectures"][l]["slot"].keys() else None
# Content
text=textwrap.fill(i["lectures"][l]["name"],o["text_wrap"])
if o["show_lecturers"]:
text+="\n"+textwrap.fill("("+i["lectures"][l]["who"]+")",o["text_wrap"])
+ if o["show_room"] and room is not None:
+ text=textwrap.fill(o["labels"]["rooms"].format(room),o["text_wrap"])+"\n"+text
if o["show_time"] and (startT,endT) != (None, None):
timeT=textwrap.fill(startT.strftime(i["output"]["time_format"])+"-"+endT.strftime(i["output"]["time_format"]),o["text_wrap"])
text=timeT+"\n"+text