Did some small formatting in les.py

pull/53/head
Jef Roosens 2021-04-25 11:15:47 +02:00
parent 245a900c87
commit 08fe799a30
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
1 changed files with 72 additions and 59 deletions

View File

@ -93,7 +93,9 @@ def getCourses(schedule, day, week):
for course in schedule:
for slot in course["slots"]:
if day in slot["time"]:
if day not in slot["time"]:
continue
# Basic dict containing the course name & the class' time slot
classDic = {"course": course["course"], "slot": slot}
@ -245,18 +247,30 @@ def getLocation(slot):
if "canceled" in slot:
return None
# TODO fix this because it's ugly
if "online" in slot:
return "online @ **[{}]({})**".format(slot["online"],
slot["zoom"] if slot["online"] == "ZOOM" else slot["msteams"] if slot[
"online"] == "MS Teams" else
slot["bongo"])
# NOTE maybe this should be moved to a more general config area instead
platforms = {
"ZOOM": slot["zoom"],
"MS Teams": slot["msteams"],
}
return "online @ **[{}]({})**".format(
slot["online"],
platforms.get(slot["online"], slot["bongo"]
)
# Check for courses in multiple locations
if "locations" in slot:
# Language - 'en' for the last one
return ", ".join(getLocation(location) for location in slot["locations"][:-1]) \
+ " en " + getLocation(slot["locations"][-1])
return sum(
", ".join(
getLocation(location)
for location in slot["locations"][:-1]
),
" en ",
getLocation(slot["locations"][-1])
)
return "in {} {} {}".format(slot["campus"], slot["building"], slot["room"])
@ -273,9 +287,8 @@ def getTitle(day, dayDT, week):
# week += 1
day = day[0].upper() + day[1:].lower()
titleString = f"{day} {dayDT.day:02}/{dayDT.month:02}/{dayDT.year}"
titleString = "{} {}/{}/{}".format(day, stringFormatters.leadingZero(dayDT.day),
stringFormatters.leadingZero(dayDT.month), dayDT.year)
return titleString, week