librus-python-api 1.10.1__py3-none-any.whl → 1.10.2__py3-none-any.whl

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,7 +1,7 @@
1
1
  """Independent bounded async client. General live compatibility is unqualified."""
2
2
 
3
3
  # Before the imports: config reads it for the User-Agent.
4
- __version__ = "1.10.1"
4
+ __version__ = "1.10.2"
5
5
 
6
6
  from librus_python_api.attachments import AttachmentStream, ModernAttachmentStream
7
7
  from librus_python_api.budget import RequestBudget
@@ -203,8 +203,11 @@ def _lesson(
203
203
  raw_number, combined, topic, z_value, symbol = values
204
204
  if raw_number not in {"", "-"} and re.fullmatch(r"[0-9]{1,2}", raw_number) is None:
205
205
  raise LibrusError(ErrorKind.PARSE)
206
- # Some schools render "<b>Subject</b>, <br>Teacher" or pad the comma.
206
+ # Some schools render "<b>Subject</b>, <br>Teacher" or pad the comma. More
207
+ # than one comma leaves the subject/teacher boundary ambiguous, so fail.
207
208
  names = [name.strip() for name in combined.split(",")]
209
+ if len(names) > 2:
210
+ raise LibrusError(ErrorKind.PARSE)
208
211
  subject, teacher = (names[0], names[1]) if len(names) == 2 else (combined, None)
209
212
  if not subject or teacher == "":
210
213
  raise LibrusError(ErrorKind.PARSE)
@@ -1052,8 +1052,12 @@ HOMEWORK_MARK_DONE_HANDLER = (
1052
1052
  r"\s*showConfirmQuestion\(\s*[0-9]{1,64}\s*,\s*[0-9]{1,64}\s*\);?\s*"
1053
1053
  )
1054
1054
  WEEKDAY_LABELS = ("pon.", "wt.", "śr.", "czw.", "pt.", "sob.", "ndz.")
1055
- # Grade tooltips also use the short Sunday display label.
1056
- CIVIL_DATE_WEEKDAY_LABELS = frozenset((*WEEKDAY_LABELS, "nd."))
1055
+ # Accepted labels per weekday (Monday first) after a civil date. Grade
1056
+ # tooltips also use the short Sunday display label.
1057
+ CIVIL_DATE_WEEKDAY_LABELS: tuple[tuple[str, ...], ...] = (
1058
+ *((label,) for label in WEEKDAY_LABELS[:-1]),
1059
+ (WEEKDAY_LABELS[-1], "nd."),
1060
+ )
1057
1061
  # Observed page-level notices shown instead of the requested content.
1058
1062
  PAGE_NOTICES = MappingProxyType(
1059
1063
  {
@@ -164,14 +164,16 @@ def tooltip_line(chunk: str) -> str:
164
164
  def civil_date(value: str | None) -> date:
165
165
  """An ISO date, optionally followed by its weekday label in parentheses."""
166
166
  match = re.fullmatch(r"([0-9]{4}-[0-9]{2}-[0-9]{2})(?: \(([^()]+)\))?", value or "")
167
- if match is None or (
168
- match[2] is not None and match[2] not in CIVIL_DATE_WEEKDAY_LABELS
169
- ):
167
+ if match is None:
170
168
  raise LibrusError(ErrorKind.PARSE)
171
169
  try:
172
- return date.fromisoformat(match[1])
170
+ day = date.fromisoformat(match[1])
173
171
  except ValueError:
174
172
  pass
173
+ else:
174
+ # A label must name the date's own weekday, as for homework dates.
175
+ if match[2] is None or match[2] in CIVIL_DATE_WEEKDAY_LABELS[day.weekday()]:
176
+ return day
175
177
  raise LibrusError(ErrorKind.PARSE)
176
178
 
177
179
 
@@ -2201,6 +2201,9 @@ class AccountClient:
2201
2201
  error.kind,
2202
2202
  )
2203
2203
  raise
2204
+ # Reinsert so iteration order follows refresh time: eviction then drops
2205
+ # the least recently refreshed entry, not the one just read again.
2206
+ self._cache.pop(key, None)
2204
2207
  self._cache[key] = (time.monotonic(), result)
2205
2208
  if len(self._cache) > ACCOUNT_RESULT_CACHE_SIZE:
2206
2209
  del self._cache[next(iter(self._cache))]
@@ -2589,6 +2592,7 @@ class AccountClient:
2589
2592
  reference=identifier,
2590
2593
  content_type=JSON,
2591
2594
  )
2595
+ self._metadata.pop(key, None) # refresh order, as in _cached
2592
2596
  self._metadata[key] = time.monotonic(), value
2593
2597
  if len(self._metadata) > ATTENDANCE_METADATA_CACHE_SIZE:
2594
2598
  del self._metadata[next(iter(self._metadata))]
@@ -2612,15 +2616,14 @@ class AccountClient:
2612
2616
  )
2613
2617
  except LibrusError as error:
2614
2618
  # An unavailable or unexpected collection degrades to the original
2615
- # per-reference lookups. Deadlines, budgets, cancellation and session
2616
- # failures still propagate. Only deterministic outcomes are cached.
2619
+ # per-reference lookups for this call only; the next call reads the
2620
+ # collection again. Deadlines, budgets, cancellation and session
2621
+ # failures still propagate. Only parsed maps are cached.
2617
2622
  if error.kind not in _METADATA_MAP_FALLBACK:
2618
2623
  raise
2619
2624
  if error.kind is ErrorKind.LIMIT:
2620
2625
  budget.check() # An exhausted caller budget is not a large collection.
2621
- if error.kind is ErrorKind.CONNECTION:
2622
- return MappingProxyType({})
2623
- value = MappingProxyType({})
2626
+ return MappingProxyType({})
2624
2627
  self._metadata_maps[endpoint] = time.monotonic(), value
2625
2628
  return value
2626
2629
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: librus-python-api
3
- Version: 1.10.1
3
+ Version: 1.10.2
4
4
  Summary: Independent bounded async Librus Synergia client
5
5
  Project-URL: Repository, https://github.com/krzysztofbury/librus-python-api
6
6
  Project-URL: Issues, https://github.com/krzysztofbury/librus-python-api/issues
@@ -42,7 +42,9 @@ private ACLs. Windows installations include `pywin32` and `tzdata` automatically
42
42
  Network paths, reparse-point paths and unsafe storage permissions fail closed.
43
43
  See [platform requirements](contracts/persistence.md#windows-disk-boundary-25).
44
44
 
45
- **Status:** `1.10.1` reads descriptive grades that the new-schema table
45
+ **Status:** `1.10.2` rejects a date whose weekday label names another
46
+ day and a completed-lesson cell with more than one comma, and fixes two cache
47
+ bugs. `1.10.1` reads descriptive grades that the new-schema table
46
48
  shows as grade boxes. `1.10.0` returns behaviour points as a typed value
47
49
  (`GradeRecords.behaviour_points`), reads the e-Justifications list on parent
48
50
  logins (`AccountClient.justifications()`) and checks the gateway grade
@@ -77,7 +79,7 @@ See [limitations](#supported-features-and-limitations) below.
77
79
  Install the exact release from PyPI after its gated publication completes:
78
80
 
79
81
  ```sh
80
- python -m pip install librus-python-api==1.10.1
82
+ python -m pip install librus-python-api==1.10.2
81
83
  ```
82
84
 
83
85
  Pin the exact version qualified by your application. Before publication, use a
@@ -93,7 +95,7 @@ python -m pip install .
93
95
  To install a locally built wheel instead:
94
96
 
95
97
  ```sh
96
- python -m pip install ./dist/librus_python_api-1.10.1-py3-none-any.whl
98
+ python -m pip install ./dist/librus_python_api-1.10.2-py3-none-any.whl
97
99
  ```
98
100
 
99
101
  No console script or background process is installed: import the library in your
@@ -1,4 +1,4 @@
1
- librus_python_api/__init__.py,sha256=B1jXrv9nj2hglKP1WhRtawlFaSxLpldT4CAtXR7DAOw,6846
1
+ librus_python_api/__init__.py,sha256=mpHAI6zJzjN8ZTsBcSTN_Uk3E-IxoFDAsJ_FQ4TUR-8,6846
2
2
  librus_python_api/_notification_bootstrap.py,sha256=18nzH0doXBNaZXCz-_ckIvRrlHTWV5Mm1t5m2-5eYGI,4669
3
3
  librus_python_api/_notification_codec.py,sha256=hU6G3zGJ5fR8wfPC6fV2OqBKs-7XpT9eRnKO3FGsTzY,13451
4
4
  librus_python_api/_storage.py,sha256=M_6ZAzN4zs7laOdKJBRH1I2rvy3pgqYgC_MZtsd2xtM,15893
@@ -11,8 +11,8 @@ librus_python_api/attendance_frequency.py,sha256=SBhED5zuyRIHWdw4urFyTJYykb6EYB7
11
11
  librus_python_api/budget.py,sha256=8fvqT7eIxyVX2P2OBG27XsYHk_HbtSS4lzuecYpHtgs,2878
12
12
  librus_python_api/checkpoint.py,sha256=QBmG9GtpyaGRaFq-FXuGA3yR1BjuMFN9V3RTvvi_FNQ,1930
13
13
  librus_python_api/class_free_days.py,sha256=IwoCgr-9ZgEYYQ6717s4cDpyFzbosHMzESMabXJLGqA,2422
14
- librus_python_api/completed_lessons.py,sha256=ngGfBD6K4B6dR4elPYvNRvp40Q-GlrhUsUKqBbYY1KE,10727
15
- librus_python_api/config.py,sha256=10geLZ8ra4jVcTWHmFHp3TpZQe2cT094qgoBLit5a4Y,66003
14
+ librus_python_api/completed_lessons.py,sha256=X3NygnzEVaNM53mIf8wiIWF8GHvGCI4bmI0YROdXXLs,10875
15
+ librus_python_api/config.py,sha256=Ft-pQL1pZqUAM_m3zRCfsWCmYr4eZruL7kAe0gSKJ0w,66148
16
16
  librus_python_api/detail_fields.py,sha256=vDDi5sV-e30-42SF0hwAUoldiZ5wvYtb1UlLt03lBHw,1708
17
17
  librus_python_api/diagnostics.py,sha256=SFQ3Wq6JEFOEHjRKe0-8zcCeJ8c8Eq8lIkVk2_a8IKU,19126
18
18
  librus_python_api/exceptions.py,sha256=x8_z5UTNmuRINTK4buLYiKdYcFA2w6GZP9ZXOL-OnRU,5531
@@ -25,7 +25,7 @@ librus_python_api/homework_range.py,sha256=erYfvS6PhHU5XhnR6LkiLNy677hGVflY3UAuH
25
25
  librus_python_api/inspect_page.py,sha256=uSFJRcEd5m36kqqP6kf2uowB4x2RGNqyfnmaakVzL94,5938
26
26
  librus_python_api/justifications.py,sha256=ZzfeZR5TvYyArQ5Oqi6VM5JmBKS2lZok4UR7hc3dI4o,7799
27
27
  librus_python_api/lifecycle.py,sha256=XzA5CEdZFo7iL5IMUrawnRvf2m9BFe0OseP-fpQFaAE,856
28
- librus_python_api/markup.py,sha256=TzGt8pRed2n--BpxFtLY0eq1wzdOhvKhehS50uPBi1o,7935
28
+ librus_python_api/markup.py,sha256=UxZVG9cWZz8VWE--uAPLfyv1Ghcu6ZbFM6E5ysA3YLs,8041
29
29
  librus_python_api/message_content.py,sha256=v_qoEAoaYS0_9MQBaj57i5XnC7pzv_HHWefgTt4CNyM,9043
30
30
  librus_python_api/messages.py,sha256=K9F8XVs1SojfFpdxxLV8gx9E0g81YxEHjigDzLHmDCg,10230
31
31
  librus_python_api/models.py,sha256=Eeg0tQhhcP5r6cfU3JpT7I9MZ1ybQR6RnklJ1mgOznI,47125
@@ -45,10 +45,10 @@ librus_python_api/scheduler.py,sha256=3JplYxqvQdFz3aKXcoQUJHE9s3FPw_xRhQ2CPNLuQm
45
45
  librus_python_api/school_reads.py,sha256=YHta7DmhjS5vSa4Djq8pzp01-2jhVfGOo1Mnc738rV4,15209
46
46
  librus_python_api/school_year_archive.py,sha256=D0A1ywMKgoYgvi-d70__SFreMGvMb_72870Akkbb_m8,15492
47
47
  librus_python_api/sending.py,sha256=Nvvk2r-6D6Us53a2fH5GW9PcA6bWEfuOvy6c3M5QVcE,4549
48
- librus_python_api/service.py,sha256=1CcyudCv8K99d728TRqy7mWqJFjfmKqhTTjxFaMS1IM,105450
48
+ librus_python_api/service.py,sha256=0RQZW_jPwh8VJNphJ0NUcdeYR2VpZ30MQKns_12BsxU,105678
49
49
  librus_python_api/timetable.py,sha256=tX1QK9fQABxzfLaHHqTe8e6rAgdOkCoTOfAHdPwNmLE,9836
50
50
  librus_python_api/transport.py,sha256=yF-DnFy4xGYS_RWQ9161b9WJXOlYF8cFRgdjXmVVUIk,34988
51
- librus_python_api-1.10.1.dist-info/METADATA,sha256=hOoZx4SKC0mJH7zbsfaE6bKSkzdJFgD-FLJw-yVRgC4,15144
52
- librus_python_api-1.10.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
53
- librus_python_api-1.10.1.dist-info/licenses/LICENSE,sha256=IuerLb3cnZCsaB23znydjjvKqP-LmSJd3syKa9NGUts,1071
54
- librus_python_api-1.10.1.dist-info/RECORD,,
51
+ librus_python_api-1.10.2.dist-info/METADATA,sha256=ZYvel3prhVpM6ltwnf3cI2tjGkhbCGDPHE0IezmX2zM,15286
52
+ librus_python_api-1.10.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
53
+ librus_python_api-1.10.2.dist-info/licenses/LICENSE,sha256=IuerLb3cnZCsaB23znydjjvKqP-LmSJd3syKa9NGUts,1071
54
+ librus_python_api-1.10.2.dist-info/RECORD,,