Skip to content

Commit

Permalink
Merge Timetables and ForeignTimetables into one module
Browse files Browse the repository at this point in the history
  • Loading branch information
BelKed committed Jul 18, 2024
1 parent 6e94768 commit d07b41d
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 188 deletions.
15 changes: 7 additions & 8 deletions edupage_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from edupage_api.classrooms import Classroom, Classrooms
from edupage_api.cloud import Cloud, EduCloudFile
from edupage_api.custom_request import CustomRequest
from edupage_api.foreign_timetables import ForeignTimetables, LessonSkeleton
from edupage_api.grades import EduGrade, Grades, Term
from edupage_api.login import Login, TwoFactorLogin
from edupage_api.lunches import Lunch, Lunches
Expand Down Expand Up @@ -152,7 +151,7 @@ def send_message(

return Messages(self).send_message(recipients, body)

def get_timetable(self, date: date) -> Optional[Timetable]:
def get_my_timetable(self, date: date) -> Optional[Timetable]:
"""Get timetable for the logged-in user on a specified date.
Args:
Expand All @@ -162,7 +161,7 @@ def get_timetable(self, date: date) -> Optional[Timetable]:
Optional[Timetable]: `Timetable` object for the specified date, if available; otherwise, `None`.
"""

return Timetables(self).get_timetable(date)
return Timetables(self).get_my_timetable(date)

def get_lunches(self, date: date) -> Optional[Lunch]:
"""Get lunches.
Expand Down Expand Up @@ -269,24 +268,24 @@ def get_school_year(self) -> int:
Returns:
int: The starting year of the current school year.
"""
return ForeignTimetables(self).get_school_year()
return Timetables(self).get_school_year()

def get_foreign_timetable(
def get_timetable(
self,
target: Union[EduTeacher, EduStudent, Class, Classroom],
date: date,
) -> Optional[list[LessonSkeleton]]:
) -> Optional[Timetable]:
"""Get timetable of a teacher, student, class, or classroom for a specific date.
Args:
target (Union[EduTeacher, EduStudent, Class, Classroom]): The target entity whose timetable you want.
date (datetime.date): The date for which you want the timetable.
Returns:
Optional[list[LessonSkeleton]]: A list of `LessonSkeleton` objects representing the lessons for the target entity during the specified date. Returns `None` if no timetable is found.
Optional[Timetable]: `Timetable` object for the specified date, if available; otherwise, `None`.
"""

return ForeignTimetables(self).get_foreign_timetable(target, date)
return Timetables(self).get_timetable(target, date)

def get_next_ringing_time(self, date_time: datetime) -> RingingTime:
"""Get the next lesson's ringing time for given `date_time`.
Expand Down
172 changes: 0 additions & 172 deletions edupage_api/foreign_timetables.py

This file was deleted.

Loading

0 comments on commit d07b41d

Please sign in to comment.