librus-python-api 1.8.4__tar.gz → 1.10.0__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.
Files changed (59) hide show
  1. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/API.md +90 -1
  2. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/CHANGELOG.md +88 -0
  3. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/PKG-INFO +12 -5
  4. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/README.md +11 -4
  5. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/pyproject.toml +6 -0
  6. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/__init__.py +13 -1
  7. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/config.py +59 -2
  8. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/diagnostics.py +3 -1
  9. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/gateway_grades.py +33 -74
  10. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/grade_records.py +178 -22
  11. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/inspect_page.py +11 -0
  12. librus_python_api-1.10.0/src/librus_python_api/justifications.py +238 -0
  13. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/models.py +133 -0
  14. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/parsers.py +7 -0
  15. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/service.py +65 -16
  16. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/uv.lock +7 -3
  17. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/.gitignore +0 -0
  18. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/LICENSE +0 -0
  19. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/SECURITY.md +0 -0
  20. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/_notification_bootstrap.py +0 -0
  21. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/_notification_codec.py +0 -0
  22. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/_storage.py +0 -0
  23. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/_windows_filesystem.py +0 -0
  24. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/announcements.py +0 -0
  25. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/attachment_routes.py +0 -0
  26. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/attachments.py +0 -0
  27. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/attendance.py +0 -0
  28. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/attendance_frequency.py +0 -0
  29. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/budget.py +0 -0
  30. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/checkpoint.py +0 -0
  31. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/class_free_days.py +0 -0
  32. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/completed_lessons.py +0 -0
  33. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/detail_fields.py +0 -0
  34. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/exceptions.py +0 -0
  35. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/files.py +0 -0
  36. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/formative_grades.py +0 -0
  37. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/grade_parsers.py +0 -0
  38. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/homework_range.py +0 -0
  39. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/lifecycle.py +0 -0
  40. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/markup.py +0 -0
  41. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/message_content.py +0 -0
  42. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/messages.py +0 -0
  43. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/modern_body.py +0 -0
  44. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/modern_mailbox.py +0 -0
  45. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/modern_messages.py +0 -0
  46. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/notification_models.py +0 -0
  47. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/notification_persistence.py +0 -0
  48. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/notification_workflow.py +0 -0
  49. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/notifications.py +0 -0
  50. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/parsing.py +0 -0
  51. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/persistence.py +0 -0
  52. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/py.typed +0 -0
  53. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/recipients.py +0 -0
  54. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/scheduler.py +0 -0
  55. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/school_reads.py +0 -0
  56. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/school_year_archive.py +0 -0
  57. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/sending.py +0 -0
  58. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/timetable.py +0 -0
  59. {librus_python_api-1.8.4 → librus_python_api-1.10.0}/src/librus_python_api/transport.py +0 -0
@@ -223,11 +223,85 @@ source)` with an aware UTC timestamp.
223
223
  - `descriptive`: `DescriptiveGrade`, including publications (`PUBLICATION`).
224
224
  - `descriptive_summaries`: undated semester text, never in date windows.
225
225
  - `averages`: `SchoolAverage` as school-provided text. Nothing is computed.
226
+ - `corrections` (1.9.0): `GradeCorrection`s, see
227
+ [grade IDs and corrections](#grade-ids-and-corrections-190).
228
+ - `behaviour_points` (1.10.0): `BehaviourPoints`, see
229
+ [behaviour points](#behaviour-points-1100).
226
230
  - `grades_window(start=None, end=None, view=GradeView.ALL)` filters the selected
227
231
  collection to inclusive civil dates. Either boundary may be omitted; two
228
232
  supplied dates may be at most 370 days apart. `GradeWindow.view` records the
229
233
  selection. It reuses only that view's cache; averages and undated summaries
230
- remain outside the window.
234
+ remain outside the window. `GradeWindow.corrections` keeps every correction
235
+ with at least one of its grades in the window, whole.
236
+ `GradeWindow.behaviour_points` keeps each item with an entry in the window,
237
+ with only those entries.
238
+
239
+ ### Grade IDs and corrections (1.9.0)
240
+
241
+ Requested in krzysztofbury/librus-mcp#88.
242
+
243
+ - `NumericGrade.grade_id` and `DescriptiveGrade.grade_id` hold the grade's own
244
+ Librus ID from its detail link (`/przegladaj_oceny/szczegoly/<digits>`). It
245
+ stays the same across reads and views, so it tells apart two grades with the
246
+ same value, category and day. It is `None` for formative, point and
247
+ behaviour links and for entries without a link; at most one of `grade_id`,
248
+ `formative_id` and `point_grade_id` is set. Like those, it is a computed
249
+ property, not a field, so stored notification identities do not change.
250
+ The detail link is recognised, never requested.
251
+ - `GradeRecords.corrections` holds one `GradeCorrection(subject, semester,
252
+ grade_ids)` per correction bracket. In the all view Librus shows a corrected
253
+ grade and its correction together as `[1 5]`; `grade_ids` lists them in page
254
+ order, at least two: the first is the corrected original and each later
255
+ grade corrects the ones before it, so the last is the latest correction.
256
+ The grades themselves stay ordinary records in `numeric` (or `descriptive`).
257
+ - `corrections` holds what the page brackets, in any view. Only the all view
258
+ was seen to bracket corrections: the week view showed a correction without
259
+ its bracket, often without its original (2026-11-08), so its `corrections`
260
+ came back `()`, and last-login is expected to behave the same. An empty
261
+ `corrections` in those views therefore does not mean nothing was
262
+ corrected. The correction's tooltip still has its `Poprawa oceny` line (the
263
+ original's value and category, no ID), which never creates a link.
264
+ - The bracket is the only source of a link. A bracket in a layout not seen
265
+ live (unbalanced, nested, around a single grade, with attributes, not
266
+ directly in the grade cell, or around an entry without an ordinary grade
267
+ link, such as a point or formative entry) raises `ParseError` instead of
268
+ returning the grades without it. In the point table, where no bracket was
269
+ seen, only a period grade's bracket repeated from the ordinary table is
270
+ accepted. Comments inside a bracket are ignored. Failure diagnostics and
271
+ `inspect_page grades` (its `corrections` count) show the brackets.
272
+ See [correction brackets](contracts/grades.md#grade-ids-and-correction-brackets-190-librus-mcp88).
273
+
274
+ ### Behaviour points (1.10.0)
275
+
276
+ Asked for in #76. Schools that grade behaviour with points show them in the
277
+ `Zachowanie` row of the grades page. `GradeRecords.behaviour_points` holds one
278
+ `BehaviourPoints(semester, tally, entries)` per period cell with points, apart
279
+ from grades; no grade or summary type is reused.
280
+
281
+ - `semester` is the period whose current-grade column holds the cell.
282
+ - `tally` is the integer the cell shows. Whether it is the starting points or a
283
+ running total is not established, so it is not interpreted, and `entries`
284
+ are never summed or compared with it.
285
+ - Each `BehaviourPointEntry(points, detail_id, category, day, metadata)` has its
286
+ signed points, the ID of its behaviour detail link (recognised, never
287
+ requested), its tooltip's unlabelled first line as `category`, `day` from
288
+ `Data wystawienia`, and the labelled lines (`Zakres od`, `Zakres do`,
289
+ `Data wystawienia`, `Dodał`, `Komentarz`) in `metadata`.
290
+ - A cell with the tally alone has no entries. A page without points gives `()`.
291
+ - Any other tooltip label, a missing first line or date, other content beside
292
+ the tally or a tally outside the behaviour row raises `ParseError`. Entries
293
+ count toward the grade record bound (`LimitError`). A tally alone in a cell
294
+ spanning both periods parses but gives no item, since its period would be a
295
+ guess.
296
+ - `grades_window(...)` keeps an item when one of its entries falls in the
297
+ window, with only those entries and the tally; a tally alone stays outside,
298
+ like averages.
299
+ - Grades, averages and notification identities are the same as before; behaviour
300
+ grade symbols (1.8.3) stay `NumericGrade`s. `inspect_page grades` reports
301
+ `behaviour_points` and `behaviour_point_entries` counts.
302
+
303
+ The layout comes from two schools' pages seen offline (2026-10-18); no live
304
+ login with points was available. See [grades](contracts/grades.md).
231
305
 
232
306
  ### School-year archive (1.3.0)
233
307
 
@@ -356,6 +430,21 @@ optional paired `lesson_no_from`/`lesson_no_to`. One bounded read-only GET;
356
430
  reference URLs are not followed and type labels are not inferred. An explicit
357
431
  empty collection returns `items=()`. See [contract](contracts/class-free-days.md).
358
432
 
433
+ ### e-Justifications
434
+
435
+ `justifications(*, budget=None, max_age_seconds=0.0)` returns frozen
436
+ `Justifications` with `identity`, `window_start`, `window_end`, `items` and
437
+ `observation`. Each `Justification` has civil `start`/`end`, `lessons` (lesson
438
+ numbers of a one-day entry, empty for a range), `absence_count`, `content`,
439
+ `teachers`, naive local `sent_at`, `status` (`JustificationStatus.SENT`,
440
+ `JUSTIFIED` or `REJECTED`), `decided_by` (the decider's name as text, or
441
+ `None`) and `has_attachment`. One GET of the list in the window the page shows
442
+ by default; entries sent before `window_start` may be missing. Only a login
443
+ whose identity response reports `Me.Account.GroupId` 5 (both parent logins
444
+ observed) sends the request; any other or missing group (8 on both student
445
+ logins, where the page ends the session) raises `UnsupportedCapabilityError`
446
+ without it. See [contract](contracts/justifications.md).
447
+
359
448
  ### Weekly timetable
360
449
 
361
450
  `timetable(monday)` takes a `date` that is a Monday and returns `Timetable` with
@@ -1,5 +1,93 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.0 (2026-11-13) - Behaviour points and e-Justifications
4
+
5
+ Thank you, @sanyok-ua, for reporting #76 and asking for behaviour points as a
6
+ value. Existing signatures are unchanged; the additions are listed below.
7
+
8
+ - Grades: `GradeRecords.behaviour_points` and `GradeWindow.behaviour_points`
9
+ hold the `Zachowanie` row's points (#138), apart from grades, as
10
+ `BehaviourPoints(semester, tally, entries)` with `BehaviourPointEntry(points,
11
+ detail_id, category, day, metadata)`. The tally is the integer the cell
12
+ shows; it is not interpreted as starting points or a running total, and
13
+ entries are never summed. A window keeps an item with an entry inside it,
14
+ with only those entries. Pages without points give `()`; grades, averages and
15
+ notification identities do not change.
16
+ - Grades: a point entry's tooltip is now read. A label other than `Zakres od`,
17
+ `Zakres do`, `Data wystawienia`, `Dodał` and `Komentarz`
18
+ (`config.BEHAVIOUR_POINT_LABELS`), a missing first line or a missing date
19
+ raises `ParseError`; before, the tooltip was not read and such a page
20
+ parsed. So does a point table showing different points for the same period.
21
+ A tally alone in a cell spanning both periods still parses and gives no
22
+ item, since its period would be a guess.
23
+ - Point entries count toward `GRADE_MAX_RECORDS` with the grades; an item the
24
+ point table repeats counts once.
25
+ - `inspect_page grades` reports `behaviour_points` and
26
+ `behaviour_point_entries` counts.
27
+ - The layout follows two schools' pages seen offline on 2026-10-18 with
28
+ original synthetic fixtures; no live login with points was available.
29
+
30
+ - New read `AccountClient.justifications()` returns the e-Justifications list
31
+ (`/eusprawiedliwienia`) as typed `Justifications`: the page's default window
32
+ (`window_start`, `window_end`) and each `Justification` with its period or
33
+ day and lessons, absence count, content, notified teachers, sent time,
34
+ `JustificationStatus` and the decider's name. One GET, no filter POST; older
35
+ entries may be missing. Structure observed on two parent logins on
36
+ 2026-11-13 (issue #137).
37
+ - `justifications()` sends its request only for a login whose identity
38
+ reports `Me.Account.GroupId` 5 (both parent logins observed). Any other or
39
+ missing group raises `UnsupportedCapabilityError` with no request: opening
40
+ the list on a student login (`GroupId` 8) ends its session (owner live
41
+ check, 2026-11-13). A parent login that gets the logged-out page signs in
42
+ again once, as for any read. `GroupId` is parsed internally as an optional
43
+ integer; `Identity` is unchanged.
44
+ - New route `justifications` in `config.ENDPOINTS` and the OpenAPI contract;
45
+ `inspect_page justifications`; the list's header labels are named in failure
46
+ diagnostics.
47
+ - Weekly live check: new step `justifications` (slot 0 `any`, slot 1
48
+ `unavailable`).
49
+
50
+ Other changes:
51
+
52
+ - Gateway grades: the pagination check reads the member recorded on
53
+ 2026-11-13 (`pagination` = `{limit, page, total}` integers) and nothing else,
54
+ instead of guessing key names. A total above the items received or a page
55
+ other than 1 still fails as `UNSUPPORTED_CAPABILITY`; non-integer or
56
+ inconsistent values fail as `PARSE`. A PartialGrades response without the
57
+ member is rejected; Subjects (no member) parses. Users now validates the
58
+ member when present. Requests are unchanged (#136).
59
+
60
+ ## 1.9.0 (2026-11-08) - Grade IDs and correction links
61
+
62
+ Thank you, @nawa, for raising krzysztofbury/librus-mcp#88 with a clear
63
+ description of the markup and the use case. Existing signatures are
64
+ unchanged; the additions are listed below.
65
+
66
+ - Grades: `NumericGrade.grade_id` and `DescriptiveGrade.grade_id` give each
67
+ ordinary grade its stable Librus ID from its detail link. They are computed
68
+ properties, like `formative_id`, so stored notification identities do not
69
+ change. The new `config.GRADE_DETAIL_PATH_PREFIX` is recognised, never
70
+ requested.
71
+ - Grades: `GradeRecords.corrections` and `GradeWindow.corrections` link a
72
+ corrected grade to its corrections. Each `GradeCorrection(subject,
73
+ semester, grade_ids)` lists, original first, the grades the all view shows
74
+ in one correction bracket (seen live on 2026-11-08 on a student and a parent
75
+ login, structure only). The week view showed no brackets, so its
76
+ `corrections` came back empty: there it means "not shown", not "not
77
+ corrected". Chains of more than two grades are accepted.
78
+ - `inspect_page grades` reports the number of `corrections`.
79
+ - Grades: a bracket in a layout not seen live (unbalanced, nested, around a
80
+ single grade, with attributes, outside the grade cell, or around a point,
81
+ formative or unlinked entry) now raises `ParseError`. Before, the brackets
82
+ were ignored and such a page parsed.
83
+ - Grades: failure diagnostics show correction brackets as `'['` and `']'`
84
+ instead of masked text.
85
+ - Docs: 1.8.4 described a week-view grade with two `Poprawa oceny` lines as
86
+ correcting two grades. A structure-only comparison with the all view shows
87
+ both lines name the same original, the first ending in a comma, so the
88
+ repeated line is not a record of several corrected grades. Parsing is
89
+ unchanged; `contracts/grades.md` and the config comment are corrected.
90
+
3
91
  ## 1.8.4 (2026-11-08) - Multi-line formative tooltips, grade checks in every view, calendar consent
4
92
 
5
93
  Signatures are unchanged.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: librus-python-api
3
- Version: 1.8.4
3
+ Version: 1.10.0
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,8 +42,15 @@ 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.8.4` reads multi-line formative assessment text and repeated
46
- corrections in grade tooltips, checks the new-schema grade table in every grade view and reports
45
+ **Status:** `1.10.0` returns behaviour points as a typed value
46
+ (`GradeRecords.behaviour_points`), reads the e-Justifications list on parent
47
+ logins (`AccountClient.justifications()`) and checks the gateway grade
48
+ pagination member recorded live.
49
+ `1.9.0` gives every ordinary grade its stable Librus ID (`grade_id`)
50
+ and links a corrected grade to its corrections, as the all view brackets them
51
+ (`GradeRecords.corrections`, [grade corrections](API.md#grade-ids-and-corrections-190)).
52
+ `1.8.4` reads multi-line formative assessment text and repeated
53
+ correction lines in grade tooltips, checks the new-schema grade table in every grade view and reports
47
54
  missing calendar-consumption consent as `ConsentRequiredError`.
48
55
  `1.8.3` reads behaviour grade symbols, filled descriptive
49
56
  grade tables, the "Aktualnie brak ogłoszeń" page and absences excused
@@ -69,7 +76,7 @@ See [limitations](#supported-features-and-limitations) below.
69
76
  Install the exact release from PyPI after its gated publication completes:
70
77
 
71
78
  ```sh
72
- python -m pip install librus-python-api==1.8.4
79
+ python -m pip install librus-python-api==1.10.0
73
80
  ```
74
81
 
75
82
  Pin the exact version qualified by your application. Before publication, use a
@@ -85,7 +92,7 @@ python -m pip install .
85
92
  To install a locally built wheel instead:
86
93
 
87
94
  ```sh
88
- python -m pip install ./dist/librus_python_api-1.8.4-py3-none-any.whl
95
+ python -m pip install ./dist/librus_python_api-1.10.0-py3-none-any.whl
89
96
  ```
90
97
 
91
98
  No console script or background process is installed: import the library in your
@@ -16,8 +16,15 @@ private ACLs. Windows installations include `pywin32` and `tzdata` automatically
16
16
  Network paths, reparse-point paths and unsafe storage permissions fail closed.
17
17
  See [platform requirements](contracts/persistence.md#windows-disk-boundary-25).
18
18
 
19
- **Status:** `1.8.4` reads multi-line formative assessment text and repeated
20
- corrections in grade tooltips, checks the new-schema grade table in every grade view and reports
19
+ **Status:** `1.10.0` returns behaviour points as a typed value
20
+ (`GradeRecords.behaviour_points`), reads the e-Justifications list on parent
21
+ logins (`AccountClient.justifications()`) and checks the gateway grade
22
+ pagination member recorded live.
23
+ `1.9.0` gives every ordinary grade its stable Librus ID (`grade_id`)
24
+ and links a corrected grade to its corrections, as the all view brackets them
25
+ (`GradeRecords.corrections`, [grade corrections](API.md#grade-ids-and-corrections-190)).
26
+ `1.8.4` reads multi-line formative assessment text and repeated
27
+ correction lines in grade tooltips, checks the new-schema grade table in every grade view and reports
21
28
  missing calendar-consumption consent as `ConsentRequiredError`.
22
29
  `1.8.3` reads behaviour grade symbols, filled descriptive
23
30
  grade tables, the "Aktualnie brak ogłoszeń" page and absences excused
@@ -43,7 +50,7 @@ See [limitations](#supported-features-and-limitations) below.
43
50
  Install the exact release from PyPI after its gated publication completes:
44
51
 
45
52
  ```sh
46
- python -m pip install librus-python-api==1.8.4
53
+ python -m pip install librus-python-api==1.10.0
47
54
  ```
48
55
 
49
56
  Pin the exact version qualified by your application. Before publication, use a
@@ -59,7 +66,7 @@ python -m pip install .
59
66
  To install a locally built wheel instead:
60
67
 
61
68
  ```sh
62
- python -m pip install ./dist/librus_python_api-1.8.4-py3-none-any.whl
69
+ python -m pip install ./dist/librus_python_api-1.10.0-py3-none-any.whl
63
70
  ```
64
71
 
65
72
  No console script or background process is installed: import the library in your
@@ -44,6 +44,12 @@ dev = [
44
44
  "pytest-timeout>=2.3,<3",
45
45
  ]
46
46
 
47
+ [tool.uv]
48
+ # Supply-chain window: resolution ignores files uploaded in the last 7 days,
49
+ # so a freshly published (possibly compromised) release never reaches the lock.
50
+ # The lock stores only the window, so it does not change from day to day.
51
+ exclude-newer = "7 days"
52
+
47
53
  [tool.hatch.version]
48
54
  path = "src/librus_python_api/__init__.py"
49
55
 
@@ -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.8.4"
4
+ __version__ = "1.10.0"
5
5
 
6
6
  from librus_python_api.attachments import AttachmentStream, ModernAttachmentStream
7
7
  from librus_python_api.budget import RequestBudget
@@ -38,6 +38,8 @@ from librus_python_api.models import (
38
38
  AttendanceView,
39
39
  AttendanceWindow,
40
40
  Availability,
41
+ BehaviourPointEntry,
42
+ BehaviourPoints,
41
43
  ClassFreeDay,
42
44
  ClassFreeDays,
43
45
  CompletedLesson,
@@ -53,6 +55,7 @@ from librus_python_api.models import (
53
55
  FrequencyMeasure,
54
56
  GatewayAttendance,
55
57
  GatewayAttendanceRecord,
58
+ GradeCorrection,
56
59
  GradeKind,
57
60
  GradeRecords,
58
61
  Grades,
@@ -63,6 +66,9 @@ from librus_python_api.models import (
63
66
  HomeworkItem,
64
67
  HomeworkRangeRequest,
65
68
  Identity,
69
+ Justification,
70
+ Justifications,
71
+ JustificationStatus,
66
72
  LuckyNumber,
67
73
  MessageAttachment,
68
74
  MessageAttachmentReference,
@@ -258,6 +264,9 @@ __all__ = [
258
264
  "DescriptiveGradeSummary",
259
265
  "FinalGrades",
260
266
  "FormativeGrade",
267
+ "BehaviourPointEntry",
268
+ "BehaviourPoints",
269
+ "GradeCorrection",
261
270
  "GradeKind",
262
271
  "GradeRecords",
263
272
  "Grades",
@@ -265,6 +274,9 @@ __all__ = [
265
274
  "GradeView",
266
275
  "GradeWindow",
267
276
  "Identity",
277
+ "Justification",
278
+ "Justifications",
279
+ "JustificationStatus",
268
280
  "LibrusService",
269
281
  "LuckyNumber",
270
282
  "NumericGrade",
@@ -503,6 +503,17 @@ ENDPOINTS: Mapping[str, Endpoint] = MappingProxyType(
503
503
  True,
504
504
  Evidence.INDEPENDENTLY_OBSERVED,
505
505
  ),
506
+ # The e-Justifications list as the page shows it unfiltered. Both
507
+ # parent logins got it, both student logins the "Brak dostępu"
508
+ # page (2026-11-13). The filter form's POST is not used.
509
+ Endpoint(
510
+ "justifications",
511
+ "GET",
512
+ "/eusprawiedliwienia",
513
+ SideEffect.NONE,
514
+ True,
515
+ Evidence.INDEPENDENTLY_OBSERVED,
516
+ ),
506
517
  Endpoint(
507
518
  "gateway_attendance",
508
519
  "GET",
@@ -724,8 +735,10 @@ GRADE_INLINE_DETAIL_LABEL = "Ocena"
724
735
  # multi-line grade comment was observed on 2026-10-27. A formative mirror's
725
736
  # assessment text after `Ocena` also spans lines (2026-11-08, markup.py).
726
737
  TOOLTIP_MULTILINE_LABELS = frozenset({"Komentarz"})
727
- # Labels a tooltip may repeat. A grade correcting two earlier grades lists one
728
- # `Poprawa oceny` line per corrected grade in the week view (2026-11-08).
738
+ # Labels a tooltip may repeat. In the week view a correction listed
739
+ # `Poprawa oceny` twice, both naming the same original grade, the first ending
740
+ # in a comma; the all view showed it once (2026-11-08). The tooltip is no
741
+ # record of which grades were corrected: correction brackets are.
729
742
  TOOLTIP_REPEATABLE_LABELS = frozenset({"Poprawa oceny"})
730
743
  # Tooltip labels observed on grade, attendance and point pages. Diagnostics
731
744
  # show only these by name; any other label is masked as teacher-entered text.
@@ -769,6 +782,12 @@ GRADE_VIEW_FIELDS = MappingProxyType(
769
782
  )
770
783
  GRADE_CURRENT_HEADER = "Oceny bieżące"
771
784
  GRADE_EMPTY_MARKERS = frozenset({"", "-", "Brak ocen"})
785
+ # The all view wraps a corrected grade and its correction in a bare <span>
786
+ # directly in the grade cell: its text is "[", its children are the grade
787
+ # boxes in page order (original first) and the last box's tail is "]" (owner
788
+ # logins, structure-only, 2026-11-08). The week view showed no brackets, even
789
+ # with the original in the same cell. Groups of more than two are accepted.
790
+ GRADE_CORRECTION_BRACKETS = ("[", "]")
772
791
  GRADE_AVERAGE_HEADERS = MappingProxyType(
773
792
  {"Średnia ocen": 1, "Średnia ocen z drugiego okresu": 2, "Średnia roczna": 0}
774
793
  )
@@ -869,8 +888,17 @@ FORMATIVE_DETAIL_PATH_PREFIX = "/przegladaj_oceny/szczegoly/ksztaltujace/"
869
888
  BEHAVIOUR_POINTS_DETAIL_PATH_PREFIX = "/przegladaj_oceny/zachowanie_szczegoly/"
870
889
  # Tooltip labels of a behaviour grade symbol entry (#114, synthetic example).
871
890
  BEHAVIOUR_GRADE_LABELS = frozenset({"Data wystawienia", "Dodał", "Komentarz"})
891
+ # Tooltip labels after a behaviour-point entry's unlabelled first line, as the
892
+ # 1.6.2 synthetic entry has them; any other label fails the read (#138).
893
+ BEHAVIOUR_POINT_LABELS = frozenset(
894
+ {"Zakres od", "Zakres do", "Data wystawienia", "Dodał", "Komentarz"}
895
+ )
872
896
  # Recognition only: point-grade detail links are classified, never requested.
873
897
  POINT_GRADE_DETAIL_PATH_PREFIX = "/przegladaj_oceny_punktowe/szczegoly/"
898
+ # Recognition only: an ordinary grade's own detail link gives its stable grade
899
+ # ID (librus-mcp#88); the page is never requested. Formative links share this
900
+ # prefix but have no digits-only rest, so they never yield a grade ID.
901
+ GRADE_DETAIL_PATH_PREFIX = "/przegladaj_oceny/szczegoly/"
874
902
  FORMATIVE_HEADERS = (
875
903
  "przedmiot",
876
904
  "ocena kształtująca",
@@ -1022,6 +1050,35 @@ PAGE_NOTICES = MappingProxyType(
1022
1050
  )
1023
1051
  MODULE_UNAVAILABLE_PATH = "/modul_niedostepny"
1024
1052
  CLASS_FREE_DAYS_MAX_RECORDS = 4096
1053
+ # e-Justifications list (`/eusprawiedliwienia`, structure observed on two
1054
+ # parent logins on 2026-11-13). The list table's classes, its seven header
1055
+ # cells in page order (`td`, not `th`, in `thead`) and the status words. The
1056
+ # status words are the filter's options; `odrzucone` has not been seen on an
1057
+ # entry. A decided entry adds " (" + the deciding person's name + ")".
1058
+ JUSTIFICATION_TABLE_CLASSES = frozenset({"decorated", "stretch", "center"})
1059
+ JUSTIFICATION_HEADERS = (
1060
+ "Załącznik",
1061
+ "Okres usprawiedliwienia",
1062
+ "Liczba usprawiedliwionych nieobecności",
1063
+ "Treść",
1064
+ "Powiadomieni nauczyciele",
1065
+ "Data wysłania",
1066
+ "Status",
1067
+ )
1068
+ JUSTIFICATION_STATUSES = MappingProxyType(
1069
+ {"wysłane": "sent", "usprawiedliwione": "justified", "odrzucone": "rejected"}
1070
+ )
1071
+ # `Me.Account.GroupId` of the logins that may request the list: 5 on both
1072
+ # parent logins, 8 on both student logins (one school, 2026-11-13). Opening
1073
+ # the list on a student login ends its session, so any other or missing group
1074
+ # is refused before the request.
1075
+ JUSTIFICATION_ACCOUNT_GROUP = 5
1076
+ # The filter form's date inputs, filled with the window the list shows.
1077
+ JUSTIFICATION_WINDOW_FIELDS = ("data_od", "data_do")
1078
+ JUSTIFICATION_MAX_ITEMS = 512
1079
+ JUSTIFICATION_MAX_CONTENT_LENGTH = 8192
1080
+ JUSTIFICATION_MAX_TEACHERS = 64
1081
+ JUSTIFICATION_MAX_TOTAL_TEXT_LENGTH = 262144
1025
1082
  COMPLETED_LESSONS_MAX_WINDOW_DAYS = 371
1026
1083
  COMPLETED_LESSONS_MAX_PAGE_COUNT = 1000
1027
1084
  COMPLETED_LESSONS_MAX_PAGE_ITEMS = 256
@@ -245,7 +245,8 @@ def _redaction_vocabulary() -> tuple[
245
245
  # Lazy: config imports models, which this module also imports.
246
246
  from librus_python_api import config
247
247
 
248
- texts = set(config.GRADE_EMPTY_MARKERS) | {
248
+ texts = set(config.GRADE_EMPTY_MARKERS) | set(config.GRADE_CORRECTION_BRACKETS)
249
+ texts |= {
249
250
  config.GRADE_CURRENT_HEADER,
250
251
  config.GRADE_INLINE_DETAIL_LABEL,
251
252
  config.GRADE_PREDICTED_ANNUAL_HEADER,
@@ -254,6 +255,7 @@ def _redaction_vocabulary() -> tuple[
254
255
  *config.GRADE_PERIOD_HEADERS,
255
256
  *config.GRADE_PREDICTED_PERIOD_HEADERS,
256
257
  *config.GRADE_AVERAGE_HEADERS,
258
+ *config.JUSTIFICATION_HEADERS,
257
259
  }
258
260
  texts |= {label.casefold() for label in config.FORMATIVE_HEADERS}
259
261
  profile = (*config.PROFILE_LABELS, *config.PROFILE_OWNER_LABELS)
@@ -4,8 +4,10 @@ The grades page of a school on the new descriptive grading schema renders a
4
4
  subject table whose semester cells are empty; the page script then loads the
5
5
  grades from gateway JSON routes. Routes and field names come from public client
6
6
  code and the official page script. One authorized read on 2026-10-28 parsed four
7
- PartialGrades records on one school; pagination keys are still unknown, so every
8
- unexpected shape fails instead of producing a partial collection.
7
+ PartialGrades records on one school. A structure-only read on 2026-11-13 recorded
8
+ the pagination member, `{"limit", "page", "total"}` integers beside `data` or
9
+ `Users` (Subjects has none), and only that member is checked; every unexpected
10
+ shape fails instead of producing a partial collection.
9
11
 
10
12
  Another school renders the same table with plain text in its semester cells and
11
13
  no script hooks (#115, from a reporter's synthetic example). The grade record
@@ -55,29 +57,6 @@ _DATE = re.compile(
55
57
  r"(?:[T ][0-9]{2}:[0-9]{2}(?::[0-9]{2}(?:\.[0-9]{1,9})?)?"
56
58
  r"(?:Z|[+-][0-9]{2}:?[0-9]{2})?)?"
57
59
  )
58
- # Keys (lower case, without separators) that, in any object beside `data`,
59
- # show that the collection continues on another page.
60
- _TOTAL_KEYS = frozenset(
61
- {
62
- "total",
63
- "totalcount",
64
- "totalitems",
65
- "totalrecords",
66
- "totalresults",
67
- "count",
68
- "itemcount",
69
- "itemscount",
70
- "recordcount",
71
- }
72
- )
73
- _PAGE_COUNT_KEYS = frozenset(
74
- {"pages", "totalpages", "pagecount", "pagescount", "lastpage", "numberofpages"}
75
- )
76
- _NEXT_KEYS = frozenset({"next", "nextpage", "nexturl", "nextpageurl", "nextlink"})
77
- _MORE_KEYS = frozenset({"hasmore", "hasnext", "hasnextpage", "more"})
78
- _PAGE_SIZE_KEYS = frozenset(
79
- {"limit", "perpage", "pagesize", "itemsperpage", "pagelimit"}
80
- )
81
60
 
82
61
 
83
62
  class _TokenInfoWire(BaseModel):
@@ -199,52 +178,33 @@ def _decode_collection(body: bytes, key: str, maximum: int) -> dict[str, Any]:
199
178
  return data
200
179
 
201
180
 
202
- def _count(value: Any) -> int | None:
203
- if type(value) is int:
204
- return value
205
- if type(value) is str and re.fullmatch(r"[0-9]{1,18}", value):
206
- return int(value)
207
- return None
181
+ def _check_pagination(
182
+ envelope: dict[str, Any], received: int, *, required: bool
183
+ ) -> None:
184
+ """Read the recorded `pagination` member; anything else decides nothing.
208
185
 
209
-
210
- def _continues(envelope: dict[str, Any], received: int) -> bool:
211
- """Whether a pagination member shows more items than this response holds.
212
-
213
- No paginated response was observed, so its field names are unknown. Every
214
- object beside `data`, to depth three, is checked for obvious signals: a
215
- total above the items received, more than one page, a next link or page,
216
- a true has-more flag, or a full page of a stated size with no total.
186
+ Observed 2026-11-13: `{"limit": int, "page": int, "total": int}` beside
187
+ `data` (PartialGrades) or `Users`. Subjects carries no member. Only the
188
+ first page is ever read, so the member must show page 1 and a total equal
189
+ to the items received (the limit is not a fixed page size and is only
190
+ checked to be an integer). Anything else fails instead of returning a
191
+ possibly partial collection.
217
192
  """
218
- totals: list[int] = []
219
- sizes: list[int] = []
220
- more = False
221
- pending: list[tuple[dict[str, Any], int]] = [
222
- ({k: v for k, v in envelope.items() if k != "data"}, 0)
223
- ]
224
- while pending:
225
- item, depth = pending.pop()
226
- for key, value in item.items():
227
- name = re.sub(r"[^a-z]", "", str(key).lower())
228
- if name in _NEXT_KEYS:
229
- more = more or value not in (None, "", False, {}, [])
230
- continue
231
- if isinstance(value, dict):
232
- if depth < 3:
233
- pending.append((value, depth + 1))
234
- continue
235
- number = _count(value)
236
- if name in _TOTAL_KEYS and number is not None:
237
- totals.append(number)
238
- elif name in _PAGE_COUNT_KEYS and number is not None:
239
- more = more or number > 1
240
- elif name in _MORE_KEYS:
241
- more = more or value is True
242
- elif name in _PAGE_SIZE_KEYS and number is not None:
243
- sizes.append(number)
244
- if any(total > received for total in totals):
245
- return True
246
- full_page = any(0 < size <= received for size in sizes)
247
- return more or (full_page and not totals)
193
+ if "pagination" not in envelope:
194
+ if required:
195
+ raise LibrusError(ErrorKind.PARSE)
196
+ return
197
+ member = envelope["pagination"]
198
+ if not isinstance(member, dict):
199
+ raise LibrusError(ErrorKind.PARSE)
200
+ limit, page, total = member.get("limit"), member.get("page"), member.get("total")
201
+ # `type(...) is int` rejects booleans, strings and floats.
202
+ if type(limit) is not int or type(page) is not int or type(total) is not int:
203
+ raise LibrusError(ErrorKind.PARSE)
204
+ if limit < 1 or total < received:
205
+ raise LibrusError(ErrorKind.PARSE)
206
+ if page != 1 or total > received:
207
+ raise LibrusError(ErrorKind.UNSUPPORTED_CAPABILITY)
248
208
 
249
209
 
250
210
  def parse_token_info(body: bytes) -> str:
@@ -281,9 +241,8 @@ def _day(value: str) -> date:
281
241
  def parse_partial_grades(body: bytes) -> tuple[PartialGrade, ...]:
282
242
  data = _decode_collection(body, "data", GRADE_MAX_RECORDS)
283
243
  wire = _validate(_PartialGradesWire, data)
284
- if _continues(data, len(wire.data)):
285
- # Returning the first page alone would be a silently partial result.
286
- raise LibrusError(ErrorKind.UNSUPPORTED_CAPABILITY)
244
+ # Returning the first page alone would be a silently partial result.
245
+ _check_pagination(data, len(wire.data), required=True)
287
246
  return tuple(
288
247
  PartialGrade(
289
248
  item.subjectId,
@@ -303,8 +262,7 @@ def parse_partial_grades(body: bytes) -> tuple[PartialGrade, ...]:
303
262
  def parse_gateway_subjects(body: bytes) -> Mapping[str, GatewaySubject]:
304
263
  data = _decode_collection(body, "data", DESCRIPTIVE_MAX_SUBJECTS)
305
264
  wire = _validate(_SubjectsWire, data)
306
- if _continues(data, len(wire.data)):
307
- raise LibrusError(ErrorKind.UNSUPPORTED_CAPABILITY)
265
+ _check_pagination(data, len(wire.data), required=False)
308
266
  result: dict[str, GatewaySubject] = {}
309
267
  numeric: set[int] = set()
310
268
  for item in wire.data:
@@ -323,6 +281,7 @@ def parse_gateway_users(body: bytes) -> Mapping[str, str]:
323
281
  """Account IDs to "LastName FirstName"; a user with neither is omitted."""
324
282
  data = _decode_collection(body, "Users", DESCRIPTIVE_MAX_USERS)
325
283
  wire = _validate(_UsersWire, data)
284
+ _check_pagination(data, len(wire.Users), required=False)
326
285
  result: dict[str, str] = {}
327
286
  seen: dict[str, tuple[str | None, str | None]] = {}
328
287
  for user in wire.Users: