From f9f96251a5628f45bf0394f8d8bc5891e1ca0f2a Mon Sep 17 00:00:00 2001 From: Pascal Jodlowski Date: Tue, 17 Sep 2024 20:43:34 +0200 Subject: [PATCH] :bug: fix attendance semester order during first semester --- librus_apix/attendance.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/librus_apix/attendance.py b/librus_apix/attendance.py index 64e87cc..7510310 100644 --- a/librus_apix/attendance.py +++ b/librus_apix/attendance.py @@ -33,12 +33,14 @@ ``` """ -from typing import List, Dict, Tuple +from dataclasses import dataclass +from typing import Dict, List, Tuple + from bs4 import BeautifulSoup, NavigableString, Tag + from librus_apix.client import Client +from librus_apix.exceptions import ArgumentError, ParseError from librus_apix.helpers import no_access_check -from librus_apix.exceptions import ParseError, ArgumentError -from dataclasses import dataclass @dataclass @@ -317,5 +319,10 @@ def get_attendance(client: Client, sort_by: str = "all") -> List[List[Attendance attendance_semesters[semester].append( _create_attendance(single, semester) ) - # returned reverse so first semester is first. Might break if there is only one semester? but idk - return list(reversed(attendance_semesters)) + match semester: + case 0: + return list(attendance_semesters) + case 1: + return list(reversed(attendance_semesters)) + case _: + raise ParseError("Couldn't find attendance semester")