librus-python-api 1.12.1__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.1 → librus_python_api-1.13.2}/.gitignore +3 -2
  2. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/API.md +34 -2
  3. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/CHANGELOG.md +45 -0
  4. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/PKG-INFO +6 -4
  5. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/README.md +5 -3
  6. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/__init__.py +3 -1
  7. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/config.py +15 -3
  8. librus_python_api-1.13.2/src/librus_python_api/grade_detail.py +56 -0
  9. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/justifications.py +4 -0
  10. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/models.py +45 -0
  11. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/service.py +33 -0
  12. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/uv.lock +162 -144
  13. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/LICENSE +0 -0
  14. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/SECURITY.md +0 -0
  15. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/pyproject.toml +0 -0
  16. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/_notification_bootstrap.py +0 -0
  17. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/_notification_codec.py +0 -0
  18. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/_storage.py +0 -0
  19. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/_windows_filesystem.py +0 -0
  20. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/announcements.py +0 -0
  21. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/attachment_routes.py +0 -0
  22. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/attachments.py +0 -0
  23. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/attendance.py +0 -0
  24. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/attendance_frequency.py +0 -0
  25. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/budget.py +0 -0
  26. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/checkpoint.py +0 -0
  27. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/class_free_days.py +0 -0
  28. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/completed_lessons.py +0 -0
  29. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/detail_fields.py +0 -0
  30. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/diagnostics.py +0 -0
  31. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/exceptions.py +0 -0
  32. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/files.py +0 -0
  33. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/formative_grades.py +0 -0
  34. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/gateway_grades.py +0 -0
  35. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/grade_parsers.py +0 -0
  36. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/grade_records.py +0 -0
  37. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/homework_range.py +0 -0
  38. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/inspect_page.py +0 -0
  39. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/lifecycle.py +0 -0
  40. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/markup.py +0 -0
  41. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/message_content.py +0 -0
  42. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/messages.py +0 -0
  43. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/modern_body.py +0 -0
  44. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/modern_mailbox.py +0 -0
  45. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/modern_messages.py +0 -0
  46. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/notification_models.py +0 -0
  47. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/notification_persistence.py +0 -0
  48. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/notification_workflow.py +0 -0
  49. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/notifications.py +0 -0
  50. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/parsers.py +0 -0
  51. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/parsing.py +0 -0
  52. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/persistence.py +0 -0
  53. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/py.typed +0 -0
  54. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/recipients.py +0 -0
  55. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/scheduler.py +0 -0
  56. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/school_reads.py +0 -0
  57. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/school_year_archive.py +0 -0
  58. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/sending.py +0 -0
  59. {librus_python_api-1.12.1 → librus_python_api-1.13.2}/src/librus_python_api/timetable.py +0 -0
  60. {librus_python_api-1.12.1 → 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
@@ -474,7 +506,7 @@ empty collection returns `items=()`. See [contract](contracts/class-free-days.md
474
506
  `justifications(*, budget=None, max_age_seconds=0.0)` returns frozen
475
507
  `Justifications` with `identity`, `window_start`, `window_end`, `items` and
476
508
  `observation`. Each `Justification` has civil `start`/`end`, `lessons` (lesson
477
- 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`,
478
510
  `teachers`, naive local `sent_at`, `status` (`JustificationStatus.SENT`,
479
511
  `JUSTIFIED` or `REJECTED`), `decided_by` (the decider's name as text, or
480
512
  `None`) and `has_attachment`. One GET of the list in the window the page shows
@@ -1,5 +1,50 @@
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
+
3
48
  ## 1.12.1 (2026-11-30) - School-year archive rows mixing marks and text
4
49
 
5
50
  - School-year archive: a grade row may hold three marks for one year and a
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: librus-python-api
3
- Version: 1.12.1
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
@@ -48,7 +48,9 @@ private ACLs. Windows installations include `pywin32` and `tzdata` automatically
48
48
  Network paths, reparse-point paths and unsafe storage permissions fail closed.
49
49
  See [platform requirements](contracts/persistence.md#windows-disk-boundary-25).
50
50
 
51
- **Status:** `1.12.1` reads school-year archive rows that hold marks for one
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
52
54
  year and text for another. `1.12.0` resolves a school's own attendance types, counts
53
55
  attendance whose lesson or subject cannot be resolved apart instead of failing
54
56
  the subject frequency read, keeps grade comment lines that hold a colon as
@@ -100,7 +102,7 @@ See [limitations](#supported-features-and-limitations) below.
100
102
  Install the exact release from PyPI after its gated publication completes:
101
103
 
102
104
  ```sh
103
- python -m pip install librus-python-api==1.12.1
105
+ python -m pip install librus-python-api==1.13.2
104
106
  ```
105
107
 
106
108
  Pin the exact version qualified by your application. Before publication, use a
@@ -116,7 +118,7 @@ python -m pip install .
116
118
  To install a locally built wheel instead:
117
119
 
118
120
  ```sh
119
- python -m pip install ./dist/librus_python_api-1.12.1-py3-none-any.whl
121
+ python -m pip install ./dist/librus_python_api-1.13.2-py3-none-any.whl
120
122
  ```
121
123
 
122
124
  No console script or background process is installed: import the library in your
@@ -22,7 +22,9 @@ private ACLs. Windows installations include `pywin32` and `tzdata` automatically
22
22
  Network paths, reparse-point paths and unsafe storage permissions fail closed.
23
23
  See [platform requirements](contracts/persistence.md#windows-disk-boundary-25).
24
24
 
25
- **Status:** `1.12.1` reads school-year archive rows that hold marks for one
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
26
28
  year and text for another. `1.12.0` resolves a school's own attendance types, counts
27
29
  attendance whose lesson or subject cannot be resolved apart instead of failing
28
30
  the subject frequency read, keeps grade comment lines that hold a colon as
@@ -74,7 +76,7 @@ See [limitations](#supported-features-and-limitations) below.
74
76
  Install the exact release from PyPI after its gated publication completes:
75
77
 
76
78
  ```sh
77
- python -m pip install librus-python-api==1.12.1
79
+ python -m pip install librus-python-api==1.13.2
78
80
  ```
79
81
 
80
82
  Pin the exact version qualified by your application. Before publication, use a
@@ -90,7 +92,7 @@ python -m pip install .
90
92
  To install a locally built wheel instead:
91
93
 
92
94
  ```sh
93
- python -m pip install ./dist/librus_python_api-1.12.1-py3-none-any.whl
95
+ python -m pip install ./dist/librus_python_api-1.13.2-py3-none-any.whl
94
96
  ```
95
97
 
96
98
  No console script or background process is installed: import the library in your
@@ -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.1"
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",
@@ -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.
@@ -934,10 +942,14 @@ BEHAVIOUR_POINT_LABELS = frozenset(
934
942
  )
935
943
  # Recognition only: point-grade detail links are classified, never requested.
936
944
  POINT_GRADE_DETAIL_PATH_PREFIX = "/przegladaj_oceny_punktowe/szczegoly/"
937
- # Recognition only: an ordinary grade's own detail link gives its stable grade
938
- # ID (librus-mcp#88); the page is never requested. Formative links share this
939
- # 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.
940
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"
941
953
  FORMATIVE_HEADERS = (
942
954
  "przedmiot",
943
955
  "ocena kształtująca",
@@ -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())
@@ -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()
@@ -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)
@@ -91,6 +91,7 @@ from librus_python_api.gateway_grades import (
91
91
  parse_token_info,
92
92
  parse_user_info,
93
93
  )
94
+ from librus_python_api.grade_detail import parse_grade_detail
94
95
  from librus_python_api.grade_parsers import parse_final_grades
95
96
  from librus_python_api.homework_range import HomeworkAccumulator
96
97
  from librus_python_api.justifications import parse_justifications
@@ -116,6 +117,7 @@ from librus_python_api.models import (
116
117
  FinalGrades,
117
118
  GatewayAttendance,
118
119
  GatewayAttendanceRecord,
120
+ GradeDetail,
119
121
  GradeRecords,
120
122
  Grades,
121
123
  GradeView,
@@ -1433,6 +1435,37 @@ class AccountClient:
1433
1435
  ),
1434
1436
  )
1435
1437
 
1438
+ async def grade_detail(
1439
+ self,
1440
+ grade_id: str,
1441
+ *,
1442
+ budget: RequestBudget | None = None,
1443
+ max_age_seconds: float = 0.0,
1444
+ ) -> GradeDetail:
1445
+ """Read one ordinary grade's own detail page by its numeric `grade_id`.
1446
+
1447
+ Its `Komentarz` is the full comment that the grades list tooltip cuts
1448
+ to about 100 characters (`comment_truncated`). One GET per call; the
1449
+ grades read never requests it.
1450
+ """
1451
+ if type(grade_id) is not str or not NUMERIC_ID.fullmatch(grade_id):
1452
+ raise LibrusError(ErrorKind.INVALID_INPUT)
1453
+
1454
+ async def fetch(budget: RequestBudget, _: bool) -> GradeDetail:
1455
+ fields = await self._page(
1456
+ "grade_detail", budget, parse_grade_detail, reference=grade_id
1457
+ )
1458
+ return GradeDetail(
1459
+ self._session_identity(),
1460
+ grade_id,
1461
+ fields,
1462
+ self._observation("grade_detail"),
1463
+ )
1464
+
1465
+ return await self._read(
1466
+ ("grade_detail", grade_id), fetch, budget, max_age_seconds
1467
+ )
1468
+
1436
1469
  async def class_free_days(
1437
1470
  self,
1438
1471
  *,