schedules module#
- class schedules.Schedule(project_id: str, schedule_id: typing.Optional[int] = None, label: str = l'New schedule')[source]#
Bases:
objectA schedule is essentially a combination of courses stored as a master course, from which some events can be removed.
- Parameters
project_id – the schedule id matching this of the Database it is currently saved in. This parameter is automatically set when the schedule is saved for the first time.
- add_course(codes: Union[Iterable[str], str]) List[str][source]#
Adds one or many courses to the schedule.
- add_custom_event(event: backend.events.CustomEvent)[source]#
Adds a custom event to the schedule.
- Parameters
event (CustomEvent (or RecurringCustomEvent)) – the event to add
- compute_best(n_best: int = 5, safe_compute: bool = True) List[Iterable[backend.events.CustomEvent]][source]#
Computes best schedules trying to minimize conflicts selecting, for each type of event, one event.
- get_courses() List[backend.courses.Course][source]#
Returns all the courses of this schedule as a list.
- Returns
the courses
- Return type
List[Course]
- get_custom_event(id: str) Optional[backend.events.CustomEvent][source]#
Returns the custom event matching given id, or None if not found.
- Parameters
id (str) – the unique id of the event
- Returns
the custom event
- Return type
Optional[CustomEvent]
- get_custom_event_color(event: Optional[backend.events.CustomEvent] = None, id: Optional[str] = None) Optional[str][source]#
Returns the color of a given custom event
- Parameters
event (Optional[CustomEvent]) – the event to remove
id (Optional[str]) – the unique id of the event
- Returns
the color
- Return type
Optional[str]
- get_events(json: bool = False, schedule_number: int = 0) List[ics.event.Event][source]#
Extracts all the events matching ids in the filtered_subcodes list.
- get_ics_file(schedule_number: int = 0)[source]#
Returns the .ics (iCalendar) representation of this Schedule.
- get_summary() Dict[str, Dict[str, Set[str]]][source]#
Returns the summary of all activities within the schedule.
- remove_course(code: str)[source]#
Removes a course from the schedule.
- Parameters
code (str) – the code of the course to remove
- remove_custom_event(event: Optional[backend.events.CustomEvent] = None, id: Optional[str] = None)[source]#
Removes a custom event from the schedule. If this event is present multiple times in the schedule, only delete the first occurrence.
- Parameters
event (Optional[CustomEvent]) – the event to remove
id (Optional[str]) – the unique id of the event
- schedules.default_dict_any_to_set() collections.defaultdict[source]#
Create a collections.defaultdict object mapping each key to a set.
- Returns
the dictionary
- Return type
- schedules.default_options() collections.defaultdict[source]#
Create a collections.defaultdict object mapping each key to a boolean. Default value is false.
- Returns
the dictionary
- Return type
- schedules.evaluate_week(week: Iterable[Iterable[backend.events.CustomEvent]], fts: Optional[Iterable[backend.events.CustomEvent]] = None) float[source]#
Evaluates how much a given week contains conflicts.
- Parameters
week (Iterable[Iterable[evt.CustomEvent]]) – events in a week as provided by
Schedule.compute_best()fts (Iterable[evt.CustomEvent]) – additional events to take into account
- Returns
the sum of all the conflicts
- Return type