mirror of https://github.com/stijndcl/didier
Did some small formatting in les.py
parent
245a900c87
commit
08fe799a30
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue