Course

class feupy.Course(pv_curso_id: int, pv_ano_lectivo: int = None, use_cache: bool = True)

This class represents a course as seen from its sigarra webpage.

Parameters:
  • pv_curso_id (int) – The id of the course, for example MIEIC’s id is 742
  • pv_ano_lectivo (int, optional) – The year of this course. It defaults to the current year (i.e. 2019, at the time of writing)
  • use_cache (bool, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra
pv_curso_id

The id of the course

Type:int
pv_ano_lectivo

The year of this course’s page

Type:int
url

Url of the course’s sigarra page

Type:str
name

The name the course

Type:str
official_code

The official code

Type:int
directors

The directors of this course

Type:tuple(Teacher)
acronym

The acronym of this course

Type:str
text

The text that can be found in the course’s page

Type:str or None

Example:

from feupy import Course

mieic = Course(742)

print(mieic.name)
# Master in Informatics and Computing Engineering

print(mieic.acronym)
# MIEIC

for director in mieic.directors:
    print(director.name)
# João Carlos Pascoal Faria
# Maria Cristina de Carvalho Alves Ribeiro
classes(credentials: feupy._Credentials.Credentials) → dict

Returns a dictionary which maps the course’s classes to their corresponding timetable links.

Parameters:credentials (Credentials) – A Credentials object
Returns:A dictionary

Example:

from feupy import Course, Credentials
from pprint import pprint

mieic = Course(742)

creds = Credentials()

pprint(mieic.classes(creds))

# You will get something like this:
{'1MIEIC01':'https://sigarra.up.pt/feup/pt/hor_geral.turmas_view?pv_turma_id=000001&pv_periodos=1&pv_ano_lectivo=2018',
'1MIEIC02': 'https://sigarra.up.pt/feup/pt/hor_geral.turmas_view?pv_turma_id=000002&pv_periodos=1&pv_ano_lectivo=2018',
'1MIEIC03': 'https://sigarra.up.pt/feup/pt/hor_geral.turmas_view?pv_turma_id=000003&pv_periodos=1&pv_ano_lectivo=2018',
'1MIEIC04': 'https://sigarra.up.pt/feup/pt/hor_geral.turmas_view?pv_turma_id=000004&pv_periodos=1&pv_ano_lectivo=2018',
'1MIEIC05': 'https://sigarra.up.pt/feup/pt/hor_geral.turmas_view?pv_turma_id=000005&pv_periodos=1&pv_ano_lectivo=2018',
'1MIEIC06': 'https://sigarra.up.pt/feup/pt/hor_geral.turmas_view?pv_turma_id=000006&pv_periodos=1&pv_ano_lectivo=2018',
...                                                                                                                   }

You can use the functions provided by timetable to get the timetables from the urls.

curricular_units(use_cache: bool = True) → list

Returns a list of CurricularUnit objects representing the curricular units of the course. Curricular units without a link are not included.

Parameters:use_cache (bool, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra
Returns:A list of CurricularUnit objects

Example:

from feupy import Course
from pprint import pprint

mieic = Course(742)

pprint(mieic.curricular_units())

# You will get something like this:
[CurricularUnit(419981),
 CurricularUnit(419982),
 CurricularUnit(419983),
 CurricularUnit(419984),
 CurricularUnit(419985),
 CurricularUnit(419986),
 CurricularUnit(419987),
 CurricularUnit(419988),
 CurricularUnit(419989),
 CurricularUnit(419990),
 CurricularUnit(419991),
 CurricularUnit(419992),
 CurricularUnit(419993),
 CurricularUnit(419994),
 CurricularUnit(419995),
 CurricularUnit(419996),
 ...                   ]
exams(use_cache: bool = True) → list

Returns a list of the exams of this course.

Parameters:use_cache (bool, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra
Returns:A list of dictionaries (see exams.exams() for more information about the dictionaries)
classmethod from_a_tag(bs4_tag: bs4.element.Tag, use_cache: bool = True)

Scrapes the course webpage from the given bs4.tag object and returns a Course object.

Parameters:
  • bs4_tag (bs4.tag) –
  • use_cache (bool, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra
Returns:

A Course object

classmethod from_url(url: str, use_cache: bool = True)

Scrapes the course webpage from the given url and returns a Course object.

Parameters:
  • url (str) – The url of the course’s sigarra page
  • use_cache (bool, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra
Returns:

A Course object

Example:

from feupy import Course

url = "https://sigarra.up.pt/feup/pt/cur_geral.cur_view?pv_curso_id=742&pv_ano_lectivo=2018"
mieic = Course.from_url(url)

print(mieic.name)
# Master in Informatics and Computing Engineering
syllabus(use_cache: bool = True) → list

Returns a list of tuples containing more information about the curricular units of the course.

Each tuple has 4 elements:
  1. keyword (str)
  2. course branch (either str or None, depending on whether or not the curricular unit belongs to a specific branch)
  3. curricular unit (CurricularUnit)
  4. is mandatory (bool)
Parameters:use_cache (bool, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra
Returns:A list of tuples

Example:

from feupy import Course
from pprint import pprint

miem = Course(743)

pprint(miem.syllabus())

# You will get something like this:
[
    ('Automation', 'Automation', CurricularUnit(418771), False),
    ('Automation', 'Automation', CurricularUnit(418770), False),
    ('Automation', 'Automation', CurricularUnit(418737), True),
    ('Automation', 'Automation', CurricularUnit(418746), True),
    ('Automation', 'Automation', CurricularUnit(418747), False),
    ('Automation', 'Automation', CurricularUnit(418736), True),
    ('Automation', 'Thermal Energy', CurricularUnit(418773), False),
    ('Automation', 'Thermal Energy', CurricularUnit(418736), False),
    ('Automation', 'Production Management', CurricularUnit(418773), False),
    ('Automation', 'Production Management', CurricularUnit(418736), False),
    ('Automation', 'Production, Conception and Manufacturing', CurricularUnit(418773), False),
    ('Automation', 'Structural Engineering and Machine Design', CurricularUnit(418736), False),
    ('Automation', None, CurricularUnit(418722), True),
    ('Personal and Interpersonal Skills', 'Automation', CurricularUnit(418787), False),
    ...
]