From 9ce4b0947c28d4cdbcab7ed53752f8e0b9ca08fe Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Mon, 26 Oct 2020 00:31:21 +0100 Subject: [PATCH] Create empty classes for rework, add basic implementation for Slot & Location --- data/les.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 data/les.py diff --git a/data/les.py b/data/les.py new file mode 100644 index 0000000..d6dd973 --- /dev/null +++ b/data/les.py @@ -0,0 +1,43 @@ +from functions.timeFormatters import timeFromInt + + +# A container class for classes +class Course: + # Initialize a course from the dict that the JSON contains + def __init__(self, courseInfo: dict): + self.name = courseInfo["course"] + + +# A slot in a course +class Slot: + def __init__(self, slot: dict): + self.day = slot["time"][0] + self.start = timeFromInt(slot["time"][1]) + self.end = timeFromInt(slot["time"][2]) + self.locations = self.getLocations(slot) + + def getLocations(self, slot: dict): + locations = [] + + # Slot has multiple locations + if "locations" in slot: + for location in slot["locations"]: + locations.append(Location(location)) + else: + # Slot has only one location + locations.append(Location(slot)) + + return locations + + +# A location where a course might take place +class Location: + def __init__(self, slot: dict): + self.campus = slot["campus"] + self.building = slot["building"] + self.room = slot["room"] + + +# A streaming platform +class Platform: + pass