events module
- class events.AcademicalEvent(name: str, begin: datetime.datetime, end: datetime.datetime, professor: backend.professors.Professor, classrooms: Optional[Iterable[backend.classrooms.Classroom]] = None, id: Optional[str] = None, weight: Union[int, float] = 5, code: Optional[str] = None, prefix: Optional[str] = None, note: Optional[str] = None)
Bases:
events.CustomEvent
An academical event is an object used to represent any event in the academical calendar.
It subclasses CustomEvent.
- Parameters
name (str) – the name of the event
begin (datetime) – the start of the event
end (datetime) – the end of the event
professor (Professor) – the professor(s) in charge of this event
classrooms (Optional[List[Classroom]]) – all the classrooms were this event takes place
id (Optional[str]) – the id of the event
weight (Union[int, float]) – the weight attributed to the event
code (Optional[str]) – code of the course related to this event
prefix (Optional[str]) – the prefix used for to describe the type of event
note – a note to be added to the event description
- KEYWORDS = ()
- get_id() str
Returns the id of this event.
- Returns
the id of the event
- Return type
str
- json(color='')
Returns the event as a json-like format.
- Parameters
color (str) – the color of the event
- Returns
a dictionary containing relevant information
- Return type
Dict[str, Any]
- classmethod matches(string)
- class events.CustomEvent(weight: Union[int, float] = 5, **kwargs: Any)
Bases:
ics.event.Event
Subclass of ics.Event, implementing more methods useful to know if two events are conflicting.
- Parameters
weight (Union[int, float]) – the weight of this event
kwargs (Any) – parameters passed to
ics.Event()
constructor, but should as least contain : - name: str - begin: datetime - end: datetime - location: str - description: str
- DEFAULT_COLOR = '#9e742f'
- get_week() int
Returns the week of this event in the gregorian calendar, starting at 0 for the first week.
- Returns
the week number relative to gregorian calendar numbering
- Return type
int
- intersects(other: events.CustomEvent) bool
Returns whether two events intersect each other.
- Parameters
other (CustomEvent) – the event to compare with
- Returns
true if both events intersect
- Return type
bool
- json(color: Optional[str] = None) Dict[str, Any]
Returns the event as a json-like format.
- Parameters
color (str) – the color of the event
- Returns
a dictionary containing relevant information
- Return type
Dict[str, Any]
- overlap(other: events.CustomEvent) float
If both events intersect, returns the product of the weights.
- Parameters
other (CustomEvent) – the event to compare with
- Returns
self.weight * other.weight if intersect, else 0
- Return type
float
- set_weight(weight: float)
changes the weight of the event.
- Parameters
weight (float) – the weight
- class events.EventCM(**kwargs)
Bases:
events.AcademicalEvent
- KEYWORDS = ('cm', 'cours', 'magistral')
- PREFIX = 'CM: '
- alarms: List[BaseAlarm]
- attendees: Set[Attendee]
- categories: Set[str]
- created: Optional[ArrowLike]
- description: Optional[str]
- last_modified: Optional[ArrowLike]
- location: Optional[str]
- organizer: Optional[Organizer]
- transparent: Optional[bool]
- uid: str
- url: Optional[str]
- class events.EventEXAM(**kwargs)
Bases:
events.AcademicalEvent
- KEYWORDS = ('partiel', 'ecrit', 'oral', 'interro', 'test')
- PREFIX = 'EXAM: '
- alarms: List[BaseAlarm]
- attendees: Set[Attendee]
- categories: Set[str]
- created: Optional[ArrowLike]
- description: Optional[str]
- last_modified: Optional[ArrowLike]
- location: Optional[str]
- organizer: Optional[Organizer]
- transparent: Optional[bool]
- uid: str
- url: Optional[str]
- class events.EventEXTERN(**kwargs)
Bases:
events.AcademicalEvent
- KEYWORDS = ('extern',)
- PREFIX = 'EXT: '
- alarms: List[BaseAlarm]
- attendees: Set[Attendee]
- categories: Set[str]
- created: Optional[ArrowLike]
- description: Optional[str]
- classmethod from_event(event: ics.event.Event, code: str) events.EventEXTERN
- last_modified: Optional[ArrowLike]
- location: Optional[str]
- organizer: Optional[Organizer]
- transparent: Optional[bool]
- uid: str
- url: Optional[str]
- class events.EventLABO(**kwargs)
Bases:
events.AcademicalEvent
- KEYWORDS = 'labo'
- PREFIX = 'LABO: '
- alarms: List[BaseAlarm]
- attendees: Set[Attendee]
- categories: Set[str]
- created: Optional[ArrowLike]
- description: Optional[str]
- last_modified: Optional[ArrowLike]
- location: Optional[str]
- organizer: Optional[Organizer]
- transparent: Optional[bool]
- uid: str
- url: Optional[str]
- class events.EventORAL(**kwargs)
Bases:
events.AcademicalEvent
- KEYWORDS = ('oral',)
- PREFIX = 'ORAL: '
- alarms: List[BaseAlarm]
- attendees: Set[Attendee]
- categories: Set[str]
- created: Optional[ArrowLike]
- description: Optional[str]
- last_modified: Optional[ArrowLike]
- location: Optional[str]
- organizer: Optional[Organizer]
- transparent: Optional[bool]
- uid: str
- url: Optional[str]
- class events.EventOTHER(**kwargs)
Bases:
events.AcademicalEvent
- KEYWORDS = ('autre', 'info', 'monitorat', 'consult', 'copie')
- PREFIX = 'OTHER: '
- alarms: List[BaseAlarm]
- attendees: Set[Attendee]
- categories: Set[str]
- created: Optional[ArrowLike]
- description: Optional[str]
- last_modified: Optional[ArrowLike]
- location: Optional[str]
- organizer: Optional[Organizer]
- transparent: Optional[bool]
- uid: str
- url: Optional[str]
- class events.EventTP(**kwargs)
Bases:
events.AcademicalEvent
- KEYWORDS = ('tp', 'td', 'ape', 'app')
- PREFIX = 'TP: '
- alarms: List[BaseAlarm]
- attendees: Set[Attendee]
- categories: Set[str]
- created: Optional[ArrowLike]
- description: Optional[str]
- last_modified: Optional[ArrowLike]
- location: Optional[str]
- organizer: Optional[Organizer]
- transparent: Optional[bool]
- uid: str
- url: Optional[str]
- class events.RecurringCustomEvent(end_recurrence, freq, **kwargs)
Bases:
events.CustomEvent
Subclass of CustomEvent, representing a recurring event, according to iCalendar’s rules.
- Parameters
end_recurrence (datetime) – the end of the recurrence
freq (Iterable[str]) – the frequency of the recurrence
kwargs (Any) – parameters passed to
CustomEvent()
constructor
- DEFAULT_COLOR = '#8a7451'
- alarms: List[BaseAlarm]
- attendees: Set[Attendee]
- categories: Set[str]
- created: Optional[ArrowLike]
- description: Optional[str]
- json(color=None)
Returns the event as a json-like format.
- Parameters
color (str) – the color of the event
- Returns
a dictionary containing relevant information
- Return type
Dict[str, Any]
- last_modified: Optional[ArrowLike]
- location: Optional[str]
- organizer: Optional[Organizer]
- transparent: Optional[bool]
- uid: str
- url: Optional[str]
- events.extract_code(course_id: str) str
Extracts a code from a course id.
- Parameters
course_id (str) – str given by ADE API to represent the id
- Returns
The code of the course. None if nothing matched the pattern required
- Return type
str
- events.extract_datetime(date: str, start: str, end: str) Tuple[datetime.datetime, datetime.datetime]
Parses infos to return the start and end time of an event.
- Parameters
date (str) – the date matching %d/%m/%Y format
start (str) – the start hour matching %H:%M format
end (str) – the end hour matching %H:%M format
- Returns
datetime objects (start date, end date)
- Return type
Tuple[datetime, datetime]
- events.extract_type(course_type: str, course_id: str) Type[events.AcademicalEvent]
Extract the type of Academical event from course type or course id. Sometimes, information from ADE API is wrong…
- Parameters
course_type (str) – string given by ADE API to represent the type
course_id (str) – string given by ADE API to represent the id
- Returns
the type of the event
- Return type
Type[AcademicalEvent]
- events.pretty_date_formatter(arrow) str
- events.pretty_formatter(arrow) str
- events.pretty_hour_formatter(arrow) str
- events.remove_accents(input_str: str) str
- events.remove_prefix(s: str, prefix: str) str
- events.sanitize_string(input_str: str) str