librus-python-api 1.12.0__tar.gz → 1.13.2__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 (60) hide show
  1. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/.gitignore +3 -2
  2. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/API.md +37 -2
  3. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/CHANGELOG.md +60 -0
  4. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/PKG-INFO +23 -4
  5. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/README.md +22 -3
  6. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/pyproject.toml +3 -1
  7. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/__init__.py +3 -1
  8. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/attendance_frequency.py +0 -1
  9. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/config.py +15 -4
  10. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/diagnostics.py +0 -1
  11. librus_python_api-1.13.2/src/librus_python_api/grade_detail.py +56 -0
  12. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/grade_records.py +1 -1
  13. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/justifications.py +4 -0
  14. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/markup.py +0 -1
  15. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/models.py +45 -0
  16. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/school_year_archive.py +34 -21
  17. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/service.py +33 -9
  18. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/uv.lock +162 -144
  19. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/LICENSE +0 -0
  20. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/SECURITY.md +0 -0
  21. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/_notification_bootstrap.py +0 -0
  22. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/_notification_codec.py +0 -0
  23. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/_storage.py +0 -0
  24. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/_windows_filesystem.py +0 -0
  25. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/announcements.py +0 -0
  26. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/attachment_routes.py +0 -0
  27. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/attachments.py +0 -0
  28. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/attendance.py +0 -0
  29. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/budget.py +0 -0
  30. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/checkpoint.py +0 -0
  31. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/class_free_days.py +0 -0
  32. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/completed_lessons.py +0 -0
  33. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/detail_fields.py +0 -0
  34. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/exceptions.py +0 -0
  35. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/files.py +0 -0
  36. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/formative_grades.py +0 -0
  37. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/gateway_grades.py +0 -0
  38. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/grade_parsers.py +0 -0
  39. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/homework_range.py +0 -0
  40. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/inspect_page.py +0 -0
  41. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/lifecycle.py +0 -0
  42. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/message_content.py +0 -0
  43. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/messages.py +0 -0
  44. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/modern_body.py +0 -0
  45. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/modern_mailbox.py +0 -0
  46. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/modern_messages.py +0 -0
  47. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/notification_models.py +0 -0
  48. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/notification_persistence.py +0 -0
  49. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/notification_workflow.py +0 -0
  50. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/notifications.py +0 -0
  51. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/parsers.py +0 -0
  52. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/parsing.py +0 -0
  53. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/persistence.py +0 -0
  54. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/py.typed +0 -0
  55. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/recipients.py +0 -0
  56. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/scheduler.py +0 -0
  57. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/school_reads.py +0 -0
  58. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/sending.py +0 -0
  59. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/timetable.py +0 -0
  60. {librus_python_api-1.12.0 → librus_python_api-1.13.2}/src/librus_python_api/transport.py +0 -0
@@ -38,8 +38,9 @@ private/
38
38
  raw-captures/
39
39
  live-artifacts/
40
40
 
41
- # Local documentation
42
- /docs/
41
+ # Local documentation; ADRs (docs/adr/, AGENTS.md) are tracked
42
+ /docs/*
43
+ !/docs/adr/
43
44
 
44
45
  # Editor and OS files
45
46
  .idea/
@@ -265,7 +265,8 @@ Requested in krzysztofbury/librus-mcp#88.
265
265
  behaviour links and for entries without a link; at most one of `grade_id`,
266
266
  `formative_id` and `point_grade_id` is set. Like those, it is a computed
267
267
  property, not a field, so stored notification identities do not change.
268
- The detail link is recognised, never requested.
268
+ `grades()` never requests the detail link; `grade_detail(grade_id)` reads
269
+ it on demand (see [full grade comments](#full-grade-comments-1130)).
269
270
  - `GradeRecords.corrections` holds one `GradeCorrection(subject, semester,
270
271
  grade_ids)` per correction bracket. In the all view Librus shows a corrected
271
272
  grade and its correction together as `[1 5]`; `grade_ids` lists them in page
@@ -289,6 +290,37 @@ Requested in krzysztofbury/librus-mcp#88.
289
290
  `inspect_page grades` (its `corrections` count) show the brackets.
290
291
  See [correction brackets](contracts/grades.md#grade-ids-and-correction-brackets-190-librus-mcp88).
291
292
 
293
+ ### Full grade comments (1.13.0)
294
+
295
+ Reported in #225. The grades list tooltip shortens a long comment to about 100
296
+ characters ending in `…`; `grades()` returns it as Librus shows it.
297
+
298
+ - `NumericGrade.comment_truncated` and `DescriptiveGrade.comment_truncated`
299
+ are `True` when `comment`, right-stripped, ends with `…` or `...`. Like
300
+ `grade_id`, they are computed properties, so stored notification identities
301
+ do not change.
302
+ - `grade_detail(grade_id)` takes a numeric string (a record's `grade_id`),
303
+ sends one GET of the grade's detail page and returns
304
+ `GradeDetail(identity, grade_id, fields, observation)`: ordered
305
+ `(label, value)` pairs as the page shows them, labels without a trailing
306
+ colon, values with line breaks and never shortened.
307
+ `GradeDetail.comment` is the full `Komentarz` text, or `None` when the
308
+ page has none. Anything else than a numeric string is `INVALID_INPUT`
309
+ before any request. Results are cached per login and grade ID like other
310
+ detail reads.
311
+ - Nothing calls it for you: read the detail of the grades whose
312
+ `comment_truncated` is `True`, one request each. See
313
+ [grade detail and full comments](contracts/grades.md#grade-detail-and-full-comments-1130-225)
314
+ and [ADR 0001](docs/adr/0001-grade-comments-on-demand.md).
315
+
316
+ ```python
317
+ grades = await client.grades()
318
+ for grade in grades.records.numeric:
319
+ if grade.comment_truncated and grade.grade_id is not None:
320
+ detail = await client.grade_detail(grade.grade_id)
321
+ full_comment = detail.comment
322
+ ```
323
+
292
324
  ### Behaviour points (1.10.0)
293
325
 
294
326
  Asked for in #76. Schools that grade behaviour with points show them in the
@@ -336,6 +368,9 @@ selection or chart request. This is separate from the modern message archive.
336
368
  not asserted to equal `SubjectGradeSummary.annual`.
337
369
  - `ArchiveDescriptive(label, text)` keeps whole-year text, with explicit BR
338
370
  boundaries as newlines. Source whitespace is normalized.
371
+ - One grade row can hold marks in some years and text in others (1.12.1). Each
372
+ year lists it under `subjects` or `descriptive` by that year's cells, so a
373
+ label can appear in both families across years, never twice in one year.
339
374
  - `behaviour_first_semester` and `behaviour_second_semester_and_year_end` retain
340
375
  positional text. Populated behaviour semantics have not been observed.
341
376
  - `ArchiveAbsences(unexcused, excused, late)` contains `ArchiveCounts` with the
@@ -471,7 +506,7 @@ empty collection returns `items=()`. See [contract](contracts/class-free-days.md
471
506
  `justifications(*, budget=None, max_age_seconds=0.0)` returns frozen
472
507
  `Justifications` with `identity`, `window_start`, `window_end`, `items` and
473
508
  `observation`. Each `Justification` has civil `start`/`end`, `lessons` (lesson
474
- numbers of a one-day entry, empty for a range), `absence_count`, `content`,
509
+ numbers of a one-day entry, empty for a range or a day listed without lessons), `absence_count`, `content`,
475
510
  `teachers`, naive local `sent_at`, `status` (`JustificationStatus.SENT`,
476
511
  `JUSTIFIED` or `REJECTED`), `decided_by` (the decider's name as text, or
477
512
  `None`) and `has_attachment`. One GET of the list in the window the page shows
@@ -1,5 +1,65 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 1.13.2 (2026-12-01) - Release qualification on GitHub's ReFS runner drive
6
+
7
+ 1.13.1 was tagged but never published: its Windows qualification failed once
8
+ GitHub began formatting the runners' D: drive with ReFS
9
+ (actions/runner-images#15315), where `RUNNER_TEMP` lives and where the
10
+ library, which stores state only on fixed NTFS volumes, correctly refused the
11
+ tests' state folders. The library is unchanged from 1.13.1; release
12
+ qualification now keeps its scratch folders on the Windows system drive.
13
+ 1.13.2 carries all of 1.13.1 and 1.13.0 below.
14
+
15
+ ## 1.13.1 (tagged 2026-12-01, never published) - e-Justifications listed by a bare date
16
+
17
+ 1.13.0 was tagged but never published: its release live check failed on
18
+ e-Justifications, as 1.12.1 also does since 2026-12-01. 1.13.1 carries all of
19
+ 1.13.0 below plus this fix.
20
+
21
+ - e-Justifications: an entry whose period is a bare `YYYY-MM-DD`, without
22
+ `lekcje: N`, failed the whole read with `PARSE`. Both parent logins showed
23
+ one on 2026-12-01. It is now a one-day entry with no lesson numbers
24
+ (`start == end`, `lessons == ()`). cra1zer2/Synapse also reads lessons as
25
+ optional.
26
+
27
+ ## 1.13.0 (tagged 2026-12-01, never published) - Full grade comments from the grade's detail page
28
+
29
+ A minor release: one new public read; existing signatures and records are
30
+ unchanged.
31
+
32
+ - Grades: Librus shortens a long grade comment in the grades list to about 100
33
+ characters ending in `…`, and `grades()` returned that text as the whole
34
+ comment (#225). The new `AccountClient.grade_detail(grade_id)` reads the
35
+ grade's own detail page (`/przegladaj_oceny/szczegoly/<id>`, new route
36
+ `grade_detail`) and returns `GradeDetail` with its labelled fields and the
37
+ full `comment`, line breaks kept. It is one request per call and only when
38
+ called: `grades()` still never requests the page, so grade records and
39
+ notification identities do not change
40
+ ([ADR 0001](docs/adr/0001-grade-comments-on-demand.md)).
41
+ - Grades: `NumericGrade.comment_truncated` and
42
+ `DescriptiveGrade.comment_truncated` (computed properties) tell which
43
+ comments end in `…` or `...` and so are worth a detail read.
44
+ - Weekly live check: a new `grade_detail` step reads one grade's detail after
45
+ `grades`, preferring a shortened comment, and fails when the full comment
46
+ does not begin with the tooltip text before the ellipsis.
47
+
48
+ ## 1.12.1 (2026-11-30) - School-year archive rows mixing marks and text
49
+
50
+ - School-year archive: a grade row may hold three marks for one year and a
51
+ descriptive text cell for another. Such rows appeared once Synergia filled
52
+ the archive with the previous year, and every archive read on that login
53
+ failed with `UNSUPPORTED_CAPABILITY`. Each year now lists the row under
54
+ `subjects` or `descriptive` by its own cells; any other geometry is still
55
+ unsupported.
56
+ - Weekly live check: a view Synergia itself marks as unavailable for now
57
+ (`temporarily_unavailable`, such as the school-year archive while it is
58
+ filled with last year's data) is listed under Warnings and no longer fails
59
+ the run. The notice stayed up for days and failed every run although
60
+ nothing had drifted. The release profile still fails on it, since that view
61
+ was not read.
62
+
3
63
  ## 1.12.0 (2026-11-24) - Attendance on schools' own types; colons in grade comments
4
64
 
5
65
  Follow-ups to librus-mcp#136, found by comparing each check with public Librus
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: librus-python-api
3
- Version: 1.12.0
3
+ Version: 1.13.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
@@ -36,13 +36,22 @@ Use it in personal scripts, notification services or application backends. One
36
36
  service can manage multiple logins while keeping their sessions and data separate.
37
37
  It is not an official Librus product.
38
38
 
39
+ > **Unofficial project.** This is an independent, private open-source project.
40
+ > It is not affiliated with, endorsed by or sponsored by Librus or its owner.
41
+ > "Librus" and "Librus Synergia" are trademarks of their owner, named here only
42
+ > to say which service this software works with. See
43
+ > [Trademarks and affiliation](#trademarks-and-affiliation).
44
+
39
45
  **Requirements:** Python 3.13 or newer. Disk workflows require a trusted local
40
46
  POSIX filesystem on Linux/macOS, or a fixed local NTFS volume on Windows with
41
47
  private ACLs. Windows installations include `pywin32` and `tzdata` automatically.
42
48
  Network paths, reparse-point paths and unsafe storage permissions fail closed.
43
49
  See [platform requirements](contracts/persistence.md#windows-disk-boundary-25).
44
50
 
45
- **Status:** `1.12.0` resolves a school's own attendance types, counts
51
+ **Status:** `1.13.2` reads a grade's full comment from its detail page
52
+ (`grade_detail`), which the grades list shortens, and e-Justifications
53
+ entries listed by a bare date (1.13.0 and 1.13.1 were never published). `1.12.1` reads school-year archive rows that hold marks for one
54
+ year and text for another. `1.12.0` resolves a school's own attendance types, counts
46
55
  attendance whose lesson or subject cannot be resolved apart instead of failing
47
56
  the subject frequency read, keeps grade comment lines that hold a colon as
48
57
  text and groups repeated gateway validation errors. `1.11.5` reads gateway attendance records whose ID is not a
@@ -93,7 +102,7 @@ See [limitations](#supported-features-and-limitations) below.
93
102
  Install the exact release from PyPI after its gated publication completes:
94
103
 
95
104
  ```sh
96
- python -m pip install librus-python-api==1.12.0
105
+ python -m pip install librus-python-api==1.13.2
97
106
  ```
98
107
 
99
108
  Pin the exact version qualified by your application. Before publication, use a
@@ -109,7 +118,7 @@ python -m pip install .
109
118
  To install a locally built wheel instead:
110
119
 
111
120
  ```sh
112
- python -m pip install ./dist/librus_python_api-1.12.0-py3-none-any.whl
121
+ python -m pip install ./dist/librus_python_api-1.13.2-py3-none-any.whl
113
122
  ```
114
123
 
115
124
  No console script or background process is installed: import the library in your
@@ -331,6 +340,16 @@ school data to public reports.
331
340
 
332
341
  MIT licensed. See [LICENSE][license].
333
342
 
343
+ ## Trademarks and affiliation
344
+
345
+ This is an independent, private open-source project. It is not affiliated with,
346
+ endorsed by, sponsored by or otherwise connected to Librus or its owner, and it
347
+ is not an official Librus product. "Librus", "Librus Synergia" and related
348
+ names and logos are trademarks of their owner. They are used here only to
349
+ describe which service this software works with; the author claims no rights to
350
+ them. Use of the service through this software remains subject to the
351
+ service's own terms.
352
+
334
353
  [api]: https://github.com/krzysztofbury/librus-python-api/blob/main/API.md
335
354
  [upgrade]: https://github.com/krzysztofbury/librus-python-api/blob/main/contracts/account-context.md
336
355
  [verification]: https://github.com/krzysztofbury/librus-python-api/blob/main/VERIFICATION.md
@@ -10,13 +10,22 @@ Use it in personal scripts, notification services or application backends. One
10
10
  service can manage multiple logins while keeping their sessions and data separate.
11
11
  It is not an official Librus product.
12
12
 
13
+ > **Unofficial project.** This is an independent, private open-source project.
14
+ > It is not affiliated with, endorsed by or sponsored by Librus or its owner.
15
+ > "Librus" and "Librus Synergia" are trademarks of their owner, named here only
16
+ > to say which service this software works with. See
17
+ > [Trademarks and affiliation](#trademarks-and-affiliation).
18
+
13
19
  **Requirements:** Python 3.13 or newer. Disk workflows require a trusted local
14
20
  POSIX filesystem on Linux/macOS, or a fixed local NTFS volume on Windows with
15
21
  private ACLs. Windows installations include `pywin32` and `tzdata` automatically.
16
22
  Network paths, reparse-point paths and unsafe storage permissions fail closed.
17
23
  See [platform requirements](contracts/persistence.md#windows-disk-boundary-25).
18
24
 
19
- **Status:** `1.12.0` resolves a school's own attendance types, counts
25
+ **Status:** `1.13.2` reads a grade's full comment from its detail page
26
+ (`grade_detail`), which the grades list shortens, and e-Justifications
27
+ entries listed by a bare date (1.13.0 and 1.13.1 were never published). `1.12.1` reads school-year archive rows that hold marks for one
28
+ year and text for another. `1.12.0` resolves a school's own attendance types, counts
20
29
  attendance whose lesson or subject cannot be resolved apart instead of failing
21
30
  the subject frequency read, keeps grade comment lines that hold a colon as
22
31
  text and groups repeated gateway validation errors. `1.11.5` reads gateway attendance records whose ID is not a
@@ -67,7 +76,7 @@ See [limitations](#supported-features-and-limitations) below.
67
76
  Install the exact release from PyPI after its gated publication completes:
68
77
 
69
78
  ```sh
70
- python -m pip install librus-python-api==1.12.0
79
+ python -m pip install librus-python-api==1.13.2
71
80
  ```
72
81
 
73
82
  Pin the exact version qualified by your application. Before publication, use a
@@ -83,7 +92,7 @@ python -m pip install .
83
92
  To install a locally built wheel instead:
84
93
 
85
94
  ```sh
86
- python -m pip install ./dist/librus_python_api-1.12.0-py3-none-any.whl
95
+ python -m pip install ./dist/librus_python_api-1.13.2-py3-none-any.whl
87
96
  ```
88
97
 
89
98
  No console script or background process is installed: import the library in your
@@ -305,6 +314,16 @@ school data to public reports.
305
314
 
306
315
  MIT licensed. See [LICENSE][license].
307
316
 
317
+ ## Trademarks and affiliation
318
+
319
+ This is an independent, private open-source project. It is not affiliated with,
320
+ endorsed by, sponsored by or otherwise connected to Librus or its owner, and it
321
+ is not an official Librus product. "Librus", "Librus Synergia" and related
322
+ names and logos are trademarks of their owner. They are used here only to
323
+ describe which service this software works with; the author claims no rights to
324
+ them. Use of the service through this software remains subject to the
325
+ service's own terms.
326
+
308
327
  [api]: https://github.com/krzysztofbury/librus-python-api/blob/main/API.md
309
328
  [upgrade]: https://github.com/krzysztofbury/librus-python-api/blob/main/contracts/account-context.md
310
329
  [verification]: https://github.com/krzysztofbury/librus-python-api/blob/main/VERIFICATION.md
@@ -73,6 +73,7 @@ faulthandler_timeout = 100
73
73
  timeout = 120
74
74
  markers = [
75
75
  "performance: opt-in hardware-sensitive resource measurements",
76
+ "to_delete(issue): marked by a test audit for replacement; see the issue",
76
77
  ]
77
78
 
78
79
  [tool.ruff]
@@ -80,7 +81,8 @@ target-version = "py313"
80
81
  line-length = 88
81
82
 
82
83
  [tool.ruff.lint]
83
- select = ["E", "F", "I", "UP", "B", "ASYNC"]
84
+ # Why: shortcuts and dead code go to issues, not comments (AGENTS.md, Comments).
85
+ select = ["E", "F", "I", "UP", "B", "ASYNC", "FIX", "ERA001"]
84
86
 
85
87
  [tool.mypy]
86
88
  python_version = "3.13"
@@ -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.12.0"
4
+ __version__ = "1.13.2"
5
5
 
6
6
  from librus_python_api.attachments import AttachmentStream, ModernAttachmentStream
7
7
  from librus_python_api.budget import RequestBudget
@@ -56,6 +56,7 @@ from librus_python_api.models import (
56
56
  GatewayAttendance,
57
57
  GatewayAttendanceRecord,
58
58
  GradeCorrection,
59
+ GradeDetail,
59
60
  GradeKind,
60
61
  GradeRecords,
61
62
  Grades,
@@ -267,6 +268,7 @@ __all__ = [
267
268
  "BehaviourPointEntry",
268
269
  "BehaviourPoints",
269
270
  "GradeCorrection",
271
+ "GradeDetail",
270
272
  "GradeKind",
271
273
  "GradeRecords",
272
274
  "Grades",
@@ -88,7 +88,6 @@ def _collection[M: BaseModel](data: object, key: str, maximum: int, wire: type[M
88
88
  def _unique(pairs: list[tuple[str, str]]) -> dict[str, str]:
89
89
  result: dict[str, str] = {}
90
90
  for identifier, value in pairs:
91
- # Conflicting rows are never resolved by choosing one of them.
92
91
  if identifier in result and result[identifier] != value:
93
92
  raise LibrusError(ErrorKind.PARSE)
94
93
  result[identifier] = value
@@ -434,6 +434,14 @@ ENDPOINTS: Mapping[str, Endpoint] = MappingProxyType(
434
434
  False,
435
435
  Evidence.INDEPENDENTLY_OBSERVED,
436
436
  ),
437
+ Endpoint(
438
+ "grade_detail",
439
+ "GET",
440
+ "/przegladaj_oceny/szczegoly/{id}",
441
+ SideEffect.NONE,
442
+ True,
443
+ Evidence.INDEPENDENTLY_OBSERVED,
444
+ ),
437
445
  # Gateway reads behind the grades page's new-schema descriptive
438
446
  # table. Routes and field names come from public client code and the
439
447
  # official page script; one authorized read parsed four records.
@@ -858,7 +866,6 @@ DESCRIPTIVE_IDENTIFIER = re.compile(r"[A-Za-z0-9_-]{1,128}")
858
866
  DESCRIPTIVE_IDENTIFIER_OPERATIONS = frozenset(
859
867
  {"descriptive_user_info", "descriptive_partial_grades"}
860
868
  )
861
- # The PartialGrades read is a POST whose only body is this fixed JSON object.
862
869
  DESCRIPTIVE_PARTIAL_GRADES_BODY = b"{}"
863
870
  DESCRIPTIVE_MAX_SUBJECTS = 1024
864
871
  DESCRIPTIVE_MAX_USERS = 8192
@@ -935,10 +942,14 @@ BEHAVIOUR_POINT_LABELS = frozenset(
935
942
  )
936
943
  # Recognition only: point-grade detail links are classified, never requested.
937
944
  POINT_GRADE_DETAIL_PATH_PREFIX = "/przegladaj_oceny_punktowe/szczegoly/"
938
- # Recognition only: an ordinary grade's own detail link gives its stable grade
939
- # ID (librus-mcp#88); the page is never requested. Formative links share this
940
- # prefix but have no digits-only rest, so they never yield a grade ID.
945
+ # Why: a grade's stable ID (librus-mcp#88); formative links never yield one.
941
946
  GRADE_DETAIL_PATH_PREFIX = "/przegladaj_oceny/szczegoly/"
947
+ GRADE_DETAIL_TABLE_CLASSES = frozenset({"decorated", "medium", "center"})
948
+ GRADE_DETAIL_MAX_FIELDS = 32
949
+ # Why: a detail comment is the full text the tooltip cuts at ~100 characters.
950
+ GRADE_DETAIL_MAX_VALUE_LENGTH = 16384
951
+ GRADE_DETAIL_REQUIRED_LABEL = "Ocena"
952
+ GRADE_DETAIL_COMMENT_LABEL = "Komentarz"
942
953
  FORMATIVE_HEADERS = (
943
954
  "przedmiot",
944
955
  "ocena kształtująca",
@@ -560,7 +560,6 @@ def describe_failure(error: BaseException) -> str | None:
560
560
  frame, line, elements, sequences, counts = site
561
561
  redactor = _Redactor()
562
562
  lines = [f"at {_site(frame, line)}"]
563
- # The elements nearest the failure first; a page summary last.
564
563
  for name, value in sorted(elements, key=lambda item: _is_page(item[1])):
565
564
  redactor.nodes = 0
566
565
  if _is_page(value):
@@ -0,0 +1,56 @@
1
+ """Bounded parser for one ordinary grade's own detail page (#225)."""
2
+
3
+ from librus_python_api import markup
4
+ from librus_python_api.config import (
5
+ GRADE_DETAIL_MAX_FIELDS,
6
+ GRADE_DETAIL_MAX_VALUE_LENGTH,
7
+ GRADE_DETAIL_REQUIRED_LABEL,
8
+ GRADE_DETAIL_TABLE_CLASSES,
9
+ )
10
+ from librus_python_api.exceptions import ErrorKind, LibrusError
11
+ from librus_python_api.parsers import parse_page
12
+
13
+
14
+ def parse_grade_detail(body: bytes) -> tuple[tuple[str, str], ...]:
15
+ """The grade's labelled fields in page order, values never shortened.
16
+
17
+ A value keeps its line breaks; an image-only value is empty. A label cell
18
+ is a TH, or a TD as in the correction row #40 recorded.
19
+ """
20
+ document = parse_page(body)
21
+ tables = [
22
+ table
23
+ for table in document.iter("table")
24
+ if GRADE_DETAIL_TABLE_CLASSES <= set(table.get("class", "").split())
25
+ ]
26
+ if len(tables) != 1:
27
+ raise LibrusError(ErrorKind.PARSE)
28
+ rows = [
29
+ row
30
+ for row in markup.rows(tables[0])
31
+ if not markup.in_header(row) and next(row.iterancestors("tfoot"), None) is None
32
+ ]
33
+ if len(rows) > GRADE_DETAIL_MAX_FIELDS:
34
+ raise LibrusError(ErrorKind.LIMIT)
35
+ fields: dict[str, str] = {}
36
+ for row in rows:
37
+ cells = markup.cells(row)
38
+ if (
39
+ len(cells) != 2
40
+ or cells[0].tag not in {"th", "td"}
41
+ or cells[1].tag != "td"
42
+ or any(
43
+ c.get("rowspan", "1") != "1" or c.get("colspan", "1") != "1"
44
+ for c in cells
45
+ )
46
+ ):
47
+ raise LibrusError(ErrorKind.PARSE)
48
+ label = markup.text(cells[0]).rstrip(":")
49
+ if not label or label in fields:
50
+ raise LibrusError(ErrorKind.PARSE)
51
+ fields[label] = markup.text(
52
+ cells[1], GRADE_DETAIL_MAX_VALUE_LENGTH, multiline=True
53
+ )
54
+ if GRADE_DETAIL_REQUIRED_LABEL not in fields:
55
+ raise LibrusError(ErrorKind.PARSE)
56
+ return tuple(fields.items())
@@ -767,7 +767,7 @@ def read_grade_records(document: html.HtmlElement) -> GradeRecords:
767
767
  else:
768
768
  for row in markup.rows(table):
769
769
  if markup.in_header(row):
770
- # The new-schema table's column labels, not a subject.
770
+ # Why: the header row has a subject row's shape ("Przedmiot").
771
771
  continue
772
772
  cells = markup.cells(row)
773
773
  if _descriptive_row(cells):
@@ -29,6 +29,7 @@ _RANGE = re.compile(rf"od {_DAY} do {_DAY}")
29
29
  # "lekcja" (one lesson) and "lekcje" were observed; "lekcji" is Polish for
30
30
  # five or more and is accepted with them.
31
31
  _ONE_DAY = re.compile(rf"{_DAY}, lekcj[aei]: ([0-9]{{1,2}}(?:, [0-9]{{1,2}})*)")
32
+ _BARE_DAY = re.compile(_DAY)
32
33
  _SENT = re.compile(rf"{_DAY} ([0-9]{{2}}:[0-9]{{2}}:[0-9]{{2}})")
33
34
  _STATUS = re.compile(r"(\S+)(?: \((.+)\))?")
34
35
 
@@ -103,6 +104,9 @@ def _period(text: str) -> tuple[date, date, tuple[int, ...]]:
103
104
  if start > end:
104
105
  raise _fail()
105
106
  return start, end, ()
107
+ if _BARE_DAY.fullmatch(text):
108
+ day = _day(text)
109
+ return day, day, ()
106
110
  match = _ONE_DAY.fullmatch(text)
107
111
  if not match:
108
112
  raise _fail()
@@ -150,7 +150,6 @@ def tooltip_fields(
150
150
  result[last] = f"{result[last]}\n{rendered}".strip()
151
151
  continue
152
152
  if separator and key in result and key in TOOLTIP_REPEATABLE_LABELS:
153
- # Each repeat keeps its value, in order, as one more line.
154
153
  result[key] = f"{result[key]}\n{value}"
155
154
  last = key
156
155
  continue
@@ -23,6 +23,7 @@ type OperationName = Literal[
23
23
  "grades",
24
24
  "attendance",
25
25
  "attendance_detail",
26
+ "grade_detail",
26
27
  "gateway_attendance",
27
28
  "subject_frequency",
28
29
  "timetable",
@@ -1064,6 +1065,10 @@ class FinalGrades:
1064
1065
  observation: Observation
1065
1066
 
1066
1067
 
1068
+ def _shortened(comment: str | None) -> bool:
1069
+ return comment is not None and comment.rstrip().endswith(("\u2026", "..."))
1070
+
1071
+
1067
1072
  @dataclass(frozen=True, slots=True)
1068
1073
  class NumericGrade:
1069
1074
  """A school grade symbol, not an invented numeric conversion.
@@ -1125,6 +1130,16 @@ class NumericGrade:
1125
1130
 
1126
1131
  return detail_id(self.href, GRADE_DETAIL_PATH_PREFIX)
1127
1132
 
1133
+ @property
1134
+ def comment_truncated(self) -> bool:
1135
+ """Whether `comment` is a shortened tooltip comment, ending in an ellipsis.
1136
+
1137
+ The list tooltip cuts long comments to about 100 characters;
1138
+ `grade_detail(grade_id)` gives the full text. Computed for the same
1139
+ identity reason as `formative_id`.
1140
+ """
1141
+ return _shortened(self.comment)
1142
+
1128
1143
 
1129
1144
  @dataclass(frozen=True, slots=True)
1130
1145
  class DescriptiveGrade:
@@ -1162,6 +1177,16 @@ class DescriptiveGrade:
1162
1177
 
1163
1178
  return detail_id(self.href, GRADE_DETAIL_PATH_PREFIX)
1164
1179
 
1180
+ @property
1181
+ def comment_truncated(self) -> bool:
1182
+ """Whether `comment` is a shortened tooltip comment, ending in an ellipsis.
1183
+
1184
+ The list tooltip cuts long comments to about 100 characters;
1185
+ `grade_detail(grade_id)` gives the full text. Computed for the same
1186
+ identity reason as `formative_id`.
1187
+ """
1188
+ return _shortened(self.comment)
1189
+
1165
1190
 
1166
1191
  @dataclass(frozen=True, slots=True)
1167
1192
  class SchoolAverage:
@@ -1287,6 +1312,26 @@ class GradeWindow:
1287
1312
  behaviour_points: tuple[BehaviourPoints, ...] = field(default=(), repr=False)
1288
1313
 
1289
1314
 
1315
+ @dataclass(frozen=True, slots=True)
1316
+ class GradeDetail:
1317
+ """One ordinary grade's own detail page: labelled fields in page order.
1318
+
1319
+ Read on demand only; `grades()` never requests it.
1320
+ """
1321
+
1322
+ identity: Identity
1323
+ grade_id: str = field(repr=False)
1324
+ fields: tuple[tuple[str, str], ...] = field(repr=False)
1325
+ observation: Observation
1326
+
1327
+ @property
1328
+ def comment(self) -> str | None:
1329
+ """The full `Komentarz` text with its line breaks; None when absent or empty."""
1330
+ from librus_python_api.config import GRADE_DETAIL_COMMENT_LABEL
1331
+
1332
+ return dict(self.fields).get(GRADE_DETAIL_COMMENT_LABEL) or None
1333
+
1334
+
1290
1335
  @dataclass(frozen=True, slots=True)
1291
1336
  class AttendanceRecord:
1292
1337
  symbol: str = field(repr=False)
@@ -2,8 +2,9 @@
2
2
  structural observation; every fixture is synthetic.
3
3
 
4
4
  One table holds every earlier school year: a year header row, a period row,
5
- grade rows (subject marks or full-year descriptive text), then exactly one
6
- behaviour section, one absences section and an empty footer, in that order.
5
+ grade rows (per year, three subject marks or one full-year descriptive text),
6
+ then exactly one behaviour section, one absences section and an empty footer,
7
+ in that order.
7
8
  A separate table lists achievements. Unknown layouts are unsupported;
8
9
  contradictions inside the known layout are parse errors. The student's name in
9
10
  the page header and the chart scripts are never read.
@@ -170,8 +171,8 @@ class _Body:
170
171
  self.text = text
171
172
  self.state = "grades"
172
173
  self.labels: set[str] = set()
173
- self.subjects: list[tuple[str, list[ArchiveMarks]]] = []
174
- self.descriptive: list[tuple[str, list[str]]] = []
174
+ self.subjects: list[tuple[str, dict[int, ArchiveMarks]]] = []
175
+ self.descriptive: list[tuple[str, dict[int, str]]] = []
175
176
  self.behaviour: list[tuple[str, str]] = []
176
177
  self.absences: dict[str, list[ArchiveCounts]] = {}
177
178
 
@@ -230,25 +231,33 @@ class _Body:
230
231
  label = self._label(cells)
231
232
  if not label:
232
233
  _fail(ErrorKind.UNSUPPORTED_CAPABILITY)
233
- if spans == [1] * (1 + 3 * self.count):
234
- values = self._values(cells[1:])
235
- marks = [
236
- ArchiveMarks(*values[3 * i : 3 * i + 3]) for i in range(self.count)
237
- ]
238
- self.subjects.append((label, marks))
239
- limit, size = ARCHIVE_MAX_SUBJECTS, len(self.subjects)
240
- elif spans == [1] + [3] * self.count:
241
- texts = self._values(
242
- cells[1:], multiline=True, limit=ARCHIVE_MAX_TEXT_LENGTH
243
- )
244
- self.descriptive.append((label, texts))
245
- limit, size = ARCHIVE_MAX_DESCRIPTIVE, len(self.descriptive)
246
- else:
234
+ marks: dict[int, ArchiveMarks] = {}
235
+ texts: dict[int, str] = {}
236
+ rest = list(zip(cells[1:], spans[1:], strict=True))
237
+ for year in range(self.count):
238
+ if rest and rest[0][1] == 3:
239
+ (cell, _), *rest = rest
240
+ texts[year] = self._values(
241
+ [cell], multiline=True, limit=ARCHIVE_MAX_TEXT_LENGTH
242
+ )[0]
243
+ elif [pair[1] for pair in rest[:3]] == [1, 1, 1]:
244
+ marks[year] = ArchiveMarks(*self._values([c for c, _ in rest[:3]]))
245
+ rest = rest[3:]
246
+ else:
247
+ _fail(ErrorKind.UNSUPPORTED_CAPABILITY)
248
+ if rest:
247
249
  _fail(ErrorKind.UNSUPPORTED_CAPABILITY)
248
250
  if label in self.labels:
249
251
  _fail(ErrorKind.PARSE)
250
252
  self.labels.add(label)
251
- if size > limit:
253
+ if marks:
254
+ self.subjects.append((label, marks))
255
+ if texts:
256
+ self.descriptive.append((label, texts))
257
+ if (
258
+ len(self.subjects) > ARCHIVE_MAX_SUBJECTS
259
+ or len(self.descriptive) > ARCHIVE_MAX_DESCRIPTIVE
260
+ ):
252
261
  _fail(ErrorKind.LIMIT)
253
262
 
254
263
  def _behaviour(
@@ -299,10 +308,14 @@ def _archive(table: html.HtmlElement, text: _Text) -> tuple[ArchiveYear, ...]:
299
308
  school_year=school_year,
300
309
  first_year=first_year,
301
310
  subjects=tuple(
302
- ArchiveSubject(label, marks[i]) for label, marks in body.subjects
311
+ ArchiveSubject(label, marks[i])
312
+ for label, marks in body.subjects
313
+ if i in marks
303
314
  ),
304
315
  descriptive=tuple(
305
- ArchiveDescriptive(label, texts[i]) for label, texts in body.descriptive
316
+ ArchiveDescriptive(label, texts[i])
317
+ for label, texts in body.descriptive
318
+ if i in texts
306
319
  ),
307
320
  behaviour_first_semester=body.behaviour[i][0],
308
321
  behaviour_second_semester_and_year_end=body.behaviour[i][1],