示例#1
0
 def fromDict(valueDict: dict, globalTasks=None):
     parsedDate = util.dateStringToArrow(valueDict["dateString"]).date()
     timeSlots = [
         TimeSlot.fromDict(t, globalTasks=globalTasks)
         for t in valueDict["timeSlots"]
     ]
     appointments = [
         Appointment.fromDict(appDict)
         for appDict in valueDict["appointments"]
     ]
     isSpecial = valueDict["special"]
     return Day(parsedDate, timeSlots, appointments, special=isSpecial)
示例#2
0
def initDay(day: Day, config: {}) -> None:
    if day.special:  # No defaults are applied
        return

    if day.date.weekday() >= 5:  # Weekend (Sat/Sun)
        lst = config["weekendTimeSlots"]
    else:
        lst = config["weekdayTimeSlots"]

    for timeSlotDict in lst:
        timeSlot = TimeSlot.fromDict(
            timeSlotDict,
            temporary=True)  # These automatic TimeSlots are NOT persisted
        try:
            day.addTimeSlot(timeSlot)
        except ValueError:
            if timeSlot in day.timeSlots:
                pass  # Already added
            else:
                # In case of overlap, avoid a crash by not applying the default timeSlot
                print(
                    f"WARNING: Default TimeSlot {timeSlot} could not be added to {day} because it overlaps with an existing TimeSlot!"
                )
示例#3
0
 def fromDict(valueDict: dict):
     name = valueDict["name"]
     task = valueDict["task"]
     timeSlot = TimeSlot.fromDict(valueDict["timeSlot"])
     return Appointment(name, timeSlot, task=task)