CurricularUnit¶
-
class
feupy.
CurricularUnit
(pv_ocorrencia_id: int, use_cache: bool = True, base_url: str = 'https://sigarra.up.pt/feup/en/', try_recovery: bool = True)¶ This class represents a FEUP curricular unit.
Parameters: - pv_ocorrencia_id (int) – The id of the curricular unit
- use_cache (
bool
, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra - base_url (
str
, optional) – The url of the faculty (in english) (defaults to “https://sigarra.up.pt/feup/en/”)
-
pv_ocorrencia_id
¶ The id of the curricular unit
Type: int
-
url
¶ The url of the curricular unit page
Type: str
-
name
¶ The name of the curricular unit
Type: str
-
code
¶ Type: str
-
acronym
¶ The acronym of the curricular unit
Type: str
-
academic_year
¶ The academic year in which this curricular unit was taught
Type: int
-
semester
¶ The semester in which this curricular unit was taught (either ‘1’, ‘2’, or ‘A’)
Type: str
-
has_moodle
¶ Whether or not this curricular unit has a moodle page
Type: bool
-
is_active
¶ Whether or not this curricular unit is active
Type: bool
-
webpage_url
¶ The webpage of this curricular unit, if it exists. Otherwise it’s set to None
Type: str or None
-
number_of_students
¶ Type: int
-
curricular_years
¶ usually 1-5
Type: tuple(int)
-
ECTS_credits
¶ Type: float
-
text
¶ Basically a text dump starting from “Teaching language”
Type: string
-
base_url
¶ The url of the curricular unit’s faculty (in english) (defaults to “https://sigarra.up.pt/feup/en/”)
Type: str
Example:
from feupy import CurricularUnit from pprint import pprint mpcp = CurricularUnit(419989) print(mpcp.name) # Microprocessors and Personal Computers print(mpcp.acronym) # MPCP print(mpcp.semester) # 2 for teacher in mpcp.teachers: print(teacher.name) # João Paulo de Castro Canas Ferreira # Bruno Miguel Carvalhido Lima # António José Duarte Araújo # João Paulo de Castro Canas Ferreira # João Paulo Filipe de Sousa pprint(vars(mpcp)) # You'll get something like this: {'ECTS_credits': 6.0, 'academic_year': 2018, 'acronym': 'MPCP', 'code': 'EIC0016', 'curricular_years': (1,), 'has_moodle': True, 'is_active': True, 'name': 'Microprocessors and Personal Computers', 'number_of_students': 220, 'pv_ocorrencia_id': 419989, 'regents': (Teacher(210963),), 'semester': '2', 'teachers': (Teacher(210963), Teacher(547486), Teacher(211636), Teacher(210963), Teacher(210660)), 'text': 'Teaching language\n' 'Portuguese\n' 'Objectives\n' 'BACKGROUND\n' 'The PC-compatible desktop and mobile platforms are an everyday tool ' 'in modern societies. Their architecture reflects the current ' 'technological development, but also defines the limits of the ' "computer's capabilities and performance. Variants of the ARM " 'instruction set are used today n most mobile platforms (tablets, ' 'mobile phones)in use today. Both system architecture and ISA have a ' 'deep impact on the day-to-day practice of informatics engineers.\n' 'SPECIFIC AIMS\n' 'The ... etc', 'url': 'https://sigarra.up.pt/feup/en/ucurr_geral.ficha_uc_view?pv_ocorrencia_id=419989', 'webpage_url': None}
-
all_timetables
(credentials: feupy._Credentials.Credentials, ignore_coherence: bool = False) → dict¶ Parses all the timetables related to this curricular unit (see
timetable.parse_timetables
for further info).Returns: A dictionary which maps a tuple with two datetime.date
objects, start and finish (the time span in which this timetable is valid), to a list of dictionaries (seetimetable.parse_timetable
for an example of such a list).
-
classes
(credentials: feupy._Credentials.Credentials, full_info=False, use_cache: bool = True) → dict¶ Returns a dictionary which maps a class name to a list of students (the students of that class).
Parameters: - credentials (
Credentials
) – ACredentials
object - full_info (
bool
, optional) – Returns a list of tuples. Each tuple contains the student, the allocation date, whether or not it was allocated by the administration, and whether or not the student is enrolled - use_cache (
bool
, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra
Returns: A dict
Example:
from feupy import CurricularUnit, Credentials from pprint import pprint mpcp = CurricularUnit(419989) creds = Credentials() pprint(mpcp.classes(creds)) # You'll get something like this: { '1MIEIC01': [Student(201800000), Student(201800001), Student(201800002), Student(201800003)], '1MIEIC02': [Student(201800004), Student(201800005), Student(201800006), Student(201800007), Student(201800008), Student(201800009), Student(201800010), Student(201800011), Student(201800012)], '...' : [...] }
- credentials (
-
contents
(credentials: feupy._Credentials.Credentials) → dict¶ Returns a nested dictionary structure, where each dictionary represents a folder. Every dictionary maps a string (the folder or file name) to either a dictionary (a nested folder) or a tuple (a file or a link).
- A tuple representing a file is made of 4 attributes:
- file type, either “file” or “link” (str)
- url (Note: you can download files by passing this url to
Credentials.download()
) (str) - info (str or None)
- upload date (Note: links will have this attribute always set to today) (
Datetime.Date
)
Parameters: credentials ( Credentials
) – ACredentials
objectReturns: A nested dictionary structure Example:
from feupy import CurricularUnit, Credentials from pprint import pprint mpcp = CurricularUnit(419989) creds = Credentials() pprint(mpcp.contents(creds)) # You'll get something like this: {'A folder': {'folderception': {'A file': ('file', 'https://sigarra.up.pt/feup/pt/conteudos_service.conteudos_cont?pct_id=012345&pv_cod=06ahastCa', None, datetime.date(2018, 10, 2)), 'Python': ('file', 'https://sigarra.up.pt/feup/pt/conteudos_service.conteudos_cont?pct_id=012346&pv_cod=06TtaSaPH7', 'aaaaaa', datetime.date(2018, 11, 13)), 'Simulator': ('link', 'https://github.com/hneemann/Digital', 'It\'s a simulator.', datetime.date(2019, 5, 25))}, 'jhbh': {'aa': ('link', 'https://salmanarif.bitbucket.io/visual/index.html', 'aaaaaa', datetime.date(2019, 8, 2)), 'bb': ('file', 'https://sigarra.up.pt/feup/pt/conteudos_service.conteudos_cont?pct_id=012347&pv_cod=06WjyvGato', 'banana', datetime.date(2018, 10, 12))}}}
-
exams
(use_cache: bool = True)¶ Returns a list of the exams of this curricular unit.
Parameters: use_cache ( bool
, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarraReturns: 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, base_url: str = 'https://sigarra.up.pt/feup/en/')¶ Scrapes the curricular unit webpage from the given
bs4.tag
object and returns aCurricularUnit
object.Parameters: - bs4_tag (
bs4.tag
) – - use_cache (
bool
, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra - base_url (
str
, optional) – The url of the faculty (in english) (defaults to “https://sigarra.up.pt/feup/en/”)
Returns: A
CurricularUnit
object- bs4_tag (
-
classmethod
from_url
(url: str, use_cache: bool = True, base_url: str = 'https://sigarra.up.pt/feup/en/')¶ Scrapes the curricular webpage from the given url and returns a
CurricularUnit
object.Parameters: - url (str) – The url of the curricular unit’s sigarra page
- use_cache (
bool
, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra - base_url (
str
, optional) – The url of the faculty (in english) (defaults to “https://sigarra.up.pt/feup/en/”)
Returns: A
CurricularUnit
objectExample:
from feupy import CurricularUnit url = "https://sigarra.up.pt/feup/pt/ucurr_geral.ficha_uc_view?pv_ocorrencia_id=419989" mpcp = CurricularUnit.from_url(url) print(mpcp.name) # Microprocessors and Personal Computers
-
grades_distribution
(credentials: feupy._Credentials.Credentials) → dict¶ Returns the distribution of the grades as a dict.
Parameters: credentials ( Credentials
) – ACredentials
objectReturns: A dictionary that maps the grade to the number of students that got that grade. Example:
from feupy import CurricularUnit, Credentials from pprint import pprint mpcp = CurricularUnit(419989) creds = Credentials() pprint(mpcp.grades_distribution(creds)) # You'll get something like this: {'RFC': 9, 'RFE': 17, 'RFF': 18, 5: 4, 6: 5, 7: 7, 8: 6, 9: 4, 10: 12, 11: 11, 12: 13, 13: 21, 14: 4, 15: 12, 16: 7, 17: 13, 18: 8, 19: 7, 20: 1}
-
other_occurrences
(use_cache: bool = True) → tuple¶ Returns the occurrences of this curricular unit from other years as a tuple of
CurricularUnit
objects.Parameters: use_cache ( bool
, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarraReturns: A tuple of CurricularUnit
objectsExample:
from feupy import CurricularUnit from pprint import pprint mpcp = CurricularUnit(419989) pprint(mpcp.other_occurrences()) # You'll get something like this: (CurricularUnit(436431), CurricularUnit(419989), CurricularUnit(399884), CurricularUnit(384929), CurricularUnit(368695), CurricularUnit(350451), CurricularUnit(333111), CurricularUnit(272647), CurricularUnit(272646), CurricularUnit(272645), CurricularUnit(272644), CurricularUnit(272642), CurricularUnit(272641), CurricularUnit(272640), CurricularUnit(272639))
-
results
(credentials: feupy._Credentials.Credentials, use_cache: bool = True) → dict¶ Returns a dictionary which maps a string representing the exams season (‘Época Normal (2ºS)’/’Época Recurso (2ºS)’) to a list of tuples.
- Each tuple in the list has two values:
- student (
Student
) - grade (str or int)
- student (
Parameters: - credentials (
Credentials
) – ACredentials
object - use_cache (
bool
, optional) – Attempts to use the cache if True, otherwise it will fetch from sigarra
Returns: A dict
Example:
from feupy import CurricularUnit, Credentials from pprint import pprint mpcp = CurricularUnit(419989) creds = Credentials() pprint(mpcp.results(creds)) # You'll get something like this: {'Época Normal (2ºS)': [(Student(201800001), 10), (Student(201800002), 13), (Student(201800003), 10), (Student(201800004), 'RFE'), (Student(201800005), 'RFF'), (Student(201800006), 'RFF'), ...], 'Época Recurso (2ºS)': [(Student(201800008), 11), (Student(201800009), 7), (Student(201800010), 8), (Student(201800011), 8), (Student(201800012), 'RFE'), (Student(201800013), 13), (Student(201800014), 5), (Student(201800019), 'RFC'), ...]}
-
statistics_history
(credentials: feupy._Credentials.Credentials) → list¶ Returns a list of tuples each representing an academic year.
- Contents of a tuple:
- academic year (int)
- registered students (int)
- evaluated students (int)
- approved students (int)
- evaluated students average grade (float)
- evaluated students standard deviation (float)
- approved students average grade (float)
- approved students standard deviation (float)
Parameters: credentials ( Credentials
) – ACredentials
objectReturns: A list of tuples Example:
from feupy import CurricularUnit, Credentials from pprint import pprint mpcp = CurricularUnit(419989) creds = Credentials() pprint(mpcp.statistics_history(creds)) # You will get something like this: [(2016, 208, 152, 120, 12.43, 3.75, 13.4, 2.5), (2017, 203, 149, 113, 12.08, 3.08, 12.27, 3.0), (2018, 203, 170, 133, 12.51, 3.76, 13.53, 2.76), ... ]
-
stats
(credentials: feupy._Credentials.Credentials) → tuple¶ - Returns a tuple with 3 ints:
- number of registered students
- number of evaluated students
- number of approved students
Parameters: credentials ( Credentials
) – ACredentials
objectReturns: A tuple with 3 ints Example:
from feupy import CurricularUnit, Credentials mpcp = CurricularUnit(419989) creds = Credentials() print(mpcp.stats(creds)) # You'll get something like this: (220, 185, 162)
-
students
(credentials: feupy._Credentials.Credentials, use_cache: bool = True) → list¶ Returns the students of this curricular unit as a list of tuples.
- Each tuple has 4 elements:
- student (
Student
) - status (str)
- number of registrations (int)
- type of student (str)
- student (
Parameters: - credentials (
Credentials
) – ACredentials
object - 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 CurricularUnit, Credentials from pprint import pprint mpcp = CurricularUnit(419989) creds = Credentials() pprint(mpcp.students(creds)) # You'll get something like this: [ ..., (Student(201812345), 'Ordinário', 1, 'Normal'), ... ]
-
timetable
(credentials: feupy._Credentials.Credentials, ignore_coherence: bool = False) → list¶ Returns the curricular unit’s current timetable as a list of dictionaries if possible, otherwise returns None. (see
timetable.parse_current_timetable()
for more info)Returns: A list of dicts