nusmods-api 0.2.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nusmods_api-0.2.0 → nusmods_api-0.3.1}/PKG-INFO +3 -1
- {nusmods_api-0.2.0 → nusmods_api-0.3.1}/README.md +2 -0
- {nusmods_api-0.2.0 → nusmods_api-0.3.1}/pyproject.toml +1 -1
- {nusmods_api-0.2.0 → nusmods_api-0.3.1}/pyproject.toml.orig +1 -1
- {nusmods_api-0.2.0 → nusmods_api-0.3.1}/src/nusmods_api/client.py +3 -3
- {nusmods_api-0.2.0 → nusmods_api-0.3.1}/src/nusmods_api/models.py +9 -5
- {nusmods_api-0.2.0 → nusmods_api-0.3.1}/src/nusmods_api/__init__.py +0 -0
- {nusmods_api-0.2.0 → nusmods_api-0.3.1}/src/nusmods_api/cache.py +0 -0
- {nusmods_api-0.2.0 → nusmods_api-0.3.1}/src/nusmods_api/exceptions.py +0 -0
- {nusmods_api-0.2.0 → nusmods_api-0.3.1}/src/nusmods_api/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: nusmods-api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: A Python wrapper for the NUSMods API
|
|
5
5
|
Author: kommade
|
|
6
6
|
Author-email: kommade <khoojarrell@gmail.com>
|
|
@@ -182,6 +182,8 @@ The package exposes frozen dataclasses for common API response types:
|
|
|
182
182
|
|
|
183
183
|
Some model fields retain the NUSMods API naming convention, such as
|
|
184
184
|
`moduleCode`, `classNo`, `startTime`, `lessonType`, and `examDate`.
|
|
185
|
+
`ExamTimetable.examDate` is represented as a `datetime` and preserves the
|
|
186
|
+
time and timezone supplied by the API.
|
|
185
187
|
|
|
186
188
|
## Error handling
|
|
187
189
|
|
|
@@ -172,6 +172,8 @@ The package exposes frozen dataclasses for common API response types:
|
|
|
172
172
|
|
|
173
173
|
Some model fields retain the NUSMods API naming convention, such as
|
|
174
174
|
`moduleCode`, `classNo`, `startTime`, `lessonType`, and `examDate`.
|
|
175
|
+
`ExamTimetable.examDate` is represented as a `datetime` and preserves the
|
|
176
|
+
time and timezone supplied by the API.
|
|
175
177
|
|
|
176
178
|
## Error handling
|
|
177
179
|
|
|
@@ -6,7 +6,7 @@ import re
|
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
8
8
|
import requests
|
|
9
|
-
from datetime import datetime
|
|
9
|
+
from datetime import datetime
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
from urllib.parse import parse_qs, urlparse
|
|
12
12
|
|
|
@@ -387,8 +387,8 @@ class NUSModsClient:
|
|
|
387
387
|
def _exam_sort_key(
|
|
388
388
|
self,
|
|
389
389
|
exam: ExamTimetable,
|
|
390
|
-
) -> tuple[
|
|
390
|
+
) -> tuple[datetime, str]:
|
|
391
391
|
return (
|
|
392
|
-
exam.examDate or
|
|
392
|
+
exam.examDate or datetime.max,
|
|
393
393
|
exam.moduleCode,
|
|
394
394
|
)
|
|
@@ -88,13 +88,13 @@ class SemesterData:
|
|
|
88
88
|
"""Semester data for a module."""
|
|
89
89
|
|
|
90
90
|
semester: int
|
|
91
|
-
examDate:
|
|
91
|
+
examDate: datetime | None = None
|
|
92
92
|
examDuration: int | None = None
|
|
93
93
|
timetable: list[Lesson] | None = None
|
|
94
94
|
|
|
95
95
|
def __post_init__(self) -> None:
|
|
96
|
-
if self.examDate is not None and not isinstance(self.examDate,
|
|
97
|
-
object.__setattr__(self, "examDate",
|
|
96
|
+
if self.examDate is not None and not isinstance(self.examDate, datetime):
|
|
97
|
+
object.__setattr__(self, "examDate", parse_datetime(self.examDate))
|
|
98
98
|
|
|
99
99
|
@dataclass(frozen=True)
|
|
100
100
|
class ModuleCondensed:
|
|
@@ -138,7 +138,7 @@ class ExamTimetable:
|
|
|
138
138
|
"""Exam timetable for a module."""
|
|
139
139
|
|
|
140
140
|
moduleCode: str
|
|
141
|
-
examDate:
|
|
141
|
+
examDate: datetime | None = None
|
|
142
142
|
examDuration: int | None = None
|
|
143
143
|
|
|
144
144
|
@dataclass(frozen=True)
|
|
@@ -148,7 +148,7 @@ class Timetable:
|
|
|
148
148
|
weekly: list[LessonWithModule]
|
|
149
149
|
exams: list[ExamTimetable]
|
|
150
150
|
|
|
151
|
-
def get_day_schedule(self, day: str) -> list[
|
|
151
|
+
def get_day_schedule(self, day: str) -> list[LessonWithModule]:
|
|
152
152
|
"""Get the lessons for a specific day of the week."""
|
|
153
153
|
if day not in {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}:
|
|
154
154
|
raise ValueError("Day must be one of Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday")
|
|
@@ -168,6 +168,10 @@ def parse_date(value: str) -> date:
|
|
|
168
168
|
return datetime.fromisoformat(value.replace("Z", "+00:00")).date()
|
|
169
169
|
|
|
170
170
|
|
|
171
|
+
def parse_datetime(value: str) -> datetime:
|
|
172
|
+
return datetime.fromisoformat(value.replace("Z", "+00:00"))
|
|
173
|
+
|
|
174
|
+
|
|
171
175
|
def parse_weeks(value: list[int] | dict[str, Any]) -> LessonWeeks:
|
|
172
176
|
if isinstance(value, list):
|
|
173
177
|
return value
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|