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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nusmods-api
3
- Version: 0.2.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
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nusmods-api"
3
- version = "0.2.0"
3
+ version = "0.3.1"
4
4
  description = "A Python wrapper for the NUSMods API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.15.0"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nusmods-api"
3
- version = "0.2.0"
3
+ version = "0.3.1"
4
4
  description = "A Python wrapper for the NUSMods API"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -6,7 +6,7 @@ import re
6
6
  from typing import Any
7
7
 
8
8
  import requests
9
- from datetime import datetime, date
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[date, str]:
390
+ ) -> tuple[datetime, str]:
391
391
  return (
392
- exam.examDate or date.max,
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: date | None = None
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, date):
97
- object.__setattr__(self, "examDate", parse_date(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: date | None = None
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[Lesson]:
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