Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
add failure handling to grade system
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja committed Jan 24, 2024
1 parent 5ce2868 commit 6582a0d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
25 changes: 17 additions & 8 deletions gimsisapi/formtagparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,12 @@ def get_grades(text):
grade_nonprimary.append(current_grade)
continue
grade_primary.append(current_grade)
total_perm += int(g)
total_perm_count += 1
total += int(g)
try:
total_perm += int(g)
total_perm_count += 1
total += int(g)
except Exception as e:
print(f"[GIMSIS FAILURE] Failure while parsing one of the grades: {e} {text}")

if len(grade_primary) > 0:
for grade in grade_primary:
Expand All @@ -357,7 +360,10 @@ def get_grades(text):
title = grade["title"].strip().splitlines()
if koncna:
g = grade.text.strip()
subject_grades["final"] = int(g)
try:
subject_grades["final"] = int(g)
except Exception as e:
print(f"[GIMSIS FAILURE] Failure while parsing finalized grade: {e} {text}")
continue

datum = title[0].replace("Ocena: ", "").strip()
Expand All @@ -380,10 +386,13 @@ def get_grades(text):
stalna,
),
)
total += int(g)
if stalna:
total_perm += int(g)
total_perm_count += 1
try:
total += int(g)
if stalna:
total_perm += int(g)
total_perm_count += 1
except Exception as e:
print(f"[GIMSIS FAILURE] Failure while parsing a grade: {e} {text}")
total_len = len(subject_grades[oc_obdobje]["grades"])
if total_len != 0:
subject_grades[oc_obdobje]["average"] = total/total_len
Expand Down
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ async def main():
# classes, days = await gimsis.fetch_timetable()
# print(classes, days)
# await gimsis.fetch_timetable("12 09 2022")
#absences = await gimsis.fetch_absences("01.09.2022", type=AbsenceType.by_days)
#print(absences)
absences = await gimsis.fetch_absences("01.09.2023", to_date="11.01.2024", type=AbsenceType.by_days)
print(absences)
# gradings = await gimsis.fetch_gradings()
# print(gradings)
grades = await gimsis.fetch_grades(year="2022")
print(grades)
#grades = await gimsis.fetch_grades(year="2022")
#print(grades)
#profile = await gimsis.my_profile()
#print(profile)
#teachers = await gimsis.fetch_teachers()
Expand Down

0 comments on commit 6582a0d

Please sign in to comment.