timetable¶
-
feupy.timetable.
parse_current_timetable
(credentials: feupy._Credentials.Credentials, url: str, ignore_coherence: bool = False)¶ Attempts to return the related timetable that is valid today as a list of dictionaries. If no timetable is valid today, it returns None.
Parameters: - credentials (
feupy.Credentials
) – Afeupy.Credentials
object - url (str) – The url of the timetable page
- ignore_coherence (
bool
, optional) – Whether or not this function should raise aCoherenceError
exception if the information of a class can not be fetched
Returns: A list of dicts (e.g. see
parse_timetable()
) or None- credentials (
-
feupy.timetable.
parse_timetables
(credentials: feupy._Credentials.Credentials, url: str, ignore_coherence: bool = False) → dict¶ Returns the timetables related to this timetable (including) as a dictionary.
Parameters: - credentials (
feupy.Credentials
) – Afeupy.Credentials
object - url (str) – The url of the timetable page
- ignore_coherence (
bool
, optional) – Whether or not this function should raise aCoherenceError
exception if the information of a class can not be fetched
Returns: A dictionary which maps a tuple with two
datetime.date
objects, start and finish (the time span in which this timetable was/is valid), to a list of dictionaries (e.g. seeparse_timetable()
).Example:
from feupy import timetable, Credentials from pprint import pprint timetable_url = "https://sigarra.up.pt/feup/pt/hor_geral.turmas_view?pv_turma_id=207783&pv_periodos=1&pv_ano_lectivo=2017" creds = Credentials() pprint(timetable.parse_timetables(creds, timetable_url)) # You'll get something like this: {(datetime.date(2017, 9, 24), datetime.date(2017, 10, 28)): [{'class type': 'TP', 'classes': ('1MIEIC01',), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(11, 0), 'room': ('B232A',), 'start': datetime.time(9, 0), 'teachers': (Teacher(212345),), 'weekday': 'Monday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(13, 0), 'room': ('B003',), 'start': datetime.time(11, 0), 'teachers': (Teacher(212345),), 'weekday': 'Monday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(10, 0), 'room': ('B001',), 'start': datetime.time(8, 30), 'teachers': (Teacher(212345), Teacher(212345)), 'weekday': 'Tuesday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(11, 30), 'room': ('B001',), 'start': datetime.time(10, 0), 'teachers': (Teacher(212345),), 'weekday': 'Tuesday'}, {'class type': 'TP', 'classes': ('1MIEIC02',), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(13, 30), 'room': ('B110',), 'start': datetime.time(11, 30), 'teachers': (Teacher(212345),), 'weekday': 'Tuesday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(10, 0), 'room': ('B001',), 'start': datetime.time(8, 30), 'teachers': (Teacher(212345),), 'weekday': 'Wednesday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(11, 30), 'room': ('B001',), 'start': datetime.time(10, 0), 'teachers': (Teacher(212345), Teacher(212345)), 'weekday': 'Wednesday'}, {'class type': 'TP', 'classes': ('1MIEIC03',), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(13, 30), 'room': ('B205',), 'start': datetime.time(11, 30), 'teachers': (Teacher(212345),), 'weekday': 'Wednesday'}, ... ], (datetime.date(2017, 10, 29), datetime.date(2017, 11, 4)): [{'class type': 'TP', 'classes': ('1MIEIC04',), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(11, 0), 'room': ('B232A',), 'start': datetime.time(9, 0), 'teachers': (Teacher(212345),), 'weekday': 'Monday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(13, 0), 'room': ('B003',), 'start': datetime.time(11, 0), 'teachers': (Teacher(212345),), 'weekday': 'Monday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(10, 0), 'room': ('B001',), 'start': datetime.time(8, 30), 'teachers': (Teacher(212345), Teacher(212345)), 'weekday': 'Tuesday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(11, 30), 'room': ('B001',), 'start': datetime.time(10, 0), 'teachers': (Teacher(212345),), 'weekday': 'Tuesday'}, {'class type': 'TP', 'classes': ('1MIEIC06',), 'curricular unit': CurricularUnit(399800), 'finish': datetime.time(13, 30), 'room': ('B110',), 'start': datetime.time(11, 30), 'teachers': (Teacher(212345),), 'weekday': 'Tuesday'}, ...] }
- credentials (
-
feupy.timetable.
parse_timetable
(credentials: feupy._Credentials.Credentials, url: str, ignore_coherence: bool = False) → list¶ Parses the events (including overlaps) of the timetable with the given url as a list of dictionaries.
Each dictionary represents an timetable event (a class) and has 8 keys:
key value “class type” (str) E.g. “T”, “TP”, etc. “classes” (tuple(str)) The classes that are being taught “curricular unit” ( feupy.CurricularUnit
) The subject being teached“finish” ( datetime.time
) The finish time of the event“room” (tuple(str)) The rooms in which the event will take place “start” ( datetime.time
) The start time of the event“teachers” (tuple( feupy.Teacher
))“weekday” (str) Parameters: - credentials (
feupy.Credentials
) – Afeupy.Credentials
object - url (str) – The url of the timetable page
- ignore_coherence (
bool
, optional) – Whether or not this function should raise aCoherenceError
exception if the information of a class can not be fetched
Returns: A list of dicts
Example:
from feupy import timetable, Credentials from pprint import pprint timetable_url = "https://sigarra.up.pt/feup/pt/hor_geral.turmas_view?pv_turma_id=207783&pv_periodos=1&pv_ano_lectivo=2017" creds = Credentials() pprint(timetable.parse_timetable(creds, timetable_url)) # You'll get something like this: [{'class type': 'TP', 'classes': ('1MIEIC01',), 'curricular unit': CurricularUnit(399999), 'finish': datetime.time(11, 0), 'room': ('B232A',), 'start': datetime.time(9, 0), 'teachers': (Teacher(212345),), 'weekday': 'Monday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399999), 'finish': datetime.time(13, 0), 'room': ('B003',), 'start': datetime.time(11, 0), 'teachers': (Teacher(212345),), 'weekday': 'Monday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399999), 'finish': datetime.time(10, 0), 'room': ('B001',), 'start': datetime.time(8, 30), 'teachers': (Teacher(212345), Teacher(212345)), 'weekday': 'Tuesday'}, {'class type': 'T', 'classes': ('1MIEIC01', '1MIEIC02', '1MIEIC03', '1MIEIC04', '1MIEIC05', '1MIEIC06', '1MIEIC07', '1MIEIC08'), 'curricular unit': CurricularUnit(399999), 'finish': datetime.time(11, 30), 'room': ('B001',), 'start': datetime.time(10, 0), 'teachers': (Teacher(212345),), 'weekday': 'Tuesday'}, {'class type': 'TP', 'classes': ('1MIEIC02',), 'curricular unit': CurricularUnit(399999), 'finish': datetime.time(13, 30), 'room': ('B110',), 'start': datetime.time(11, 30), 'teachers': (Teacher(212345),), 'weekday': 'Tuesday'}, ... ]
- credentials (