librus-python-api 1.8.3__tar.gz → 1.9.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.
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/API.md +70 -9
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/CHANGELOG.md +67 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/PKG-INFO +10 -4
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/README.md +9 -3
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/__init__.py +3 -1
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/config.py +21 -3
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/diagnostics.py +2 -1
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/grade_records.py +112 -7
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/inspect_page.py +2 -1
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/markup.py +42 -6
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/models.py +44 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/notification_workflow.py +2 -1
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/service.py +35 -32
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/.gitignore +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/LICENSE +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/SECURITY.md +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/pyproject.toml +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/_notification_bootstrap.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/_notification_codec.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/_storage.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/_windows_filesystem.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/announcements.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/attachment_routes.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/attachments.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/attendance.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/attendance_frequency.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/budget.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/checkpoint.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/class_free_days.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/completed_lessons.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/detail_fields.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/exceptions.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/files.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/formative_grades.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/gateway_grades.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/grade_parsers.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/homework_range.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/lifecycle.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/message_content.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/messages.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/modern_body.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/modern_mailbox.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/modern_messages.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/notification_models.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/notification_persistence.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/notifications.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/parsers.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/parsing.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/persistence.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/py.typed +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/recipients.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/scheduler.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/school_reads.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/school_year_archive.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/sending.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/timetable.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/transport.py +0 -0
- {librus_python_api-1.8.3 → librus_python_api-1.9.0}/uv.lock +0 -0
|
@@ -223,11 +223,49 @@ 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).
|
|
226
228
|
- `grades_window(start=None, end=None, view=GradeView.ALL)` filters the selected
|
|
227
229
|
collection to inclusive civil dates. Either boundary may be omitted; two
|
|
228
230
|
supplied dates may be at most 370 days apart. `GradeWindow.view` records the
|
|
229
231
|
selection. It reuses only that view's cache; averages and undated summaries
|
|
230
|
-
remain outside the window.
|
|
232
|
+
remain outside the window. `GradeWindow.corrections` keeps every correction
|
|
233
|
+
with at least one of its grades in the window, whole.
|
|
234
|
+
|
|
235
|
+
### Grade IDs and corrections (1.9.0)
|
|
236
|
+
|
|
237
|
+
Requested in krzysztofbury/librus-mcp#88.
|
|
238
|
+
|
|
239
|
+
- `NumericGrade.grade_id` and `DescriptiveGrade.grade_id` hold the grade's own
|
|
240
|
+
Librus ID from its detail link (`/przegladaj_oceny/szczegoly/<digits>`). It
|
|
241
|
+
stays the same across reads and views, so it tells apart two grades with the
|
|
242
|
+
same value, category and day. It is `None` for formative, point and
|
|
243
|
+
behaviour links and for entries without a link; at most one of `grade_id`,
|
|
244
|
+
`formative_id` and `point_grade_id` is set. Like those, it is a computed
|
|
245
|
+
property, not a field, so stored notification identities do not change.
|
|
246
|
+
The detail link is recognised, never requested.
|
|
247
|
+
- `GradeRecords.corrections` holds one `GradeCorrection(subject, semester,
|
|
248
|
+
grade_ids)` per correction bracket. In the all view Librus shows a corrected
|
|
249
|
+
grade and its correction together as `[1 5]`; `grade_ids` lists them in page
|
|
250
|
+
order, at least two: the first is the corrected original and each later
|
|
251
|
+
grade corrects the ones before it, so the last is the latest correction.
|
|
252
|
+
The grades themselves stay ordinary records in `numeric` (or `descriptive`).
|
|
253
|
+
- `corrections` holds what the page brackets, in any view. Only the all view
|
|
254
|
+
was seen to bracket corrections: the week view showed a correction without
|
|
255
|
+
its bracket, often without its original (2026-11-08), so its `corrections`
|
|
256
|
+
came back `()`, and last-login is expected to behave the same. An empty
|
|
257
|
+
`corrections` in those views therefore does not mean nothing was
|
|
258
|
+
corrected. The correction's tooltip still has its `Poprawa oceny` line (the
|
|
259
|
+
original's value and category, no ID), which never creates a link.
|
|
260
|
+
- The bracket is the only source of a link. A bracket in a layout not seen
|
|
261
|
+
live (unbalanced, nested, around a single grade, with attributes, not
|
|
262
|
+
directly in the grade cell, or around an entry without an ordinary grade
|
|
263
|
+
link, such as a point or formative entry) raises `ParseError` instead of
|
|
264
|
+
returning the grades without it. In the point table, where no bracket was
|
|
265
|
+
seen, only a period grade's bracket repeated from the ordinary table is
|
|
266
|
+
accepted. Comments inside a bracket are ignored. Failure diagnostics and
|
|
267
|
+
`inspect_page grades` (its `corrections` count) show the brackets.
|
|
268
|
+
See [correction brackets](contracts/grades.md#grade-ids-and-correction-brackets-190-librus-mcp88).
|
|
231
269
|
|
|
232
270
|
### School-year archive (1.3.0)
|
|
233
271
|
|
|
@@ -287,12 +325,31 @@ such as `(0-100)`, not a grade symbol. The table's "Wyn." period results are
|
|
|
287
325
|
into `averages`), and a point table with titled summary columns adds its
|
|
288
326
|
subjects to `final_grades()`. See [point grades](contracts/grades.md#point-grades-170).
|
|
289
327
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
328
|
+
Behaviour grade symbols (1.8.3): an entry in the behaviour row with a grade
|
|
329
|
+
symbol such as `wz`, linking to a behaviour detail, is a `NumericGrade` in
|
|
330
|
+
`numeric`. As for point grades, `category` is the tooltip's unlabelled first
|
|
331
|
+
line (such as `wzorowe`), `day` is `Data wystawienia`, `teacher` stays `None`
|
|
332
|
+
and `Dodał` is kept only in `metadata`. See [grades](contracts/grades.md).
|
|
333
|
+
|
|
334
|
+
Schools on the new descriptive grading schema show a subject table
|
|
335
|
+
(`newSchemaGradesByStudentTable`) in one of two layouts. Every view checks it
|
|
336
|
+
the same way (from 1.8.4; before, only the `ALL` view did):
|
|
337
|
+
|
|
338
|
+
- Empty semester cells (`gradesCell` hooks) that the page script fills from
|
|
339
|
+
the gateway. In the `ALL` view `grades()` reads those grades from the
|
|
340
|
+
gateway, as described below. `WEEK` and `LAST_LOGIN` contain none of them.
|
|
341
|
+
- Semester cells holding bare text, such as `5` or `Brak ocen` (1.8.3). The
|
|
342
|
+
text becomes undated `descriptive_summaries` (`Brak ocen` is empty) and no
|
|
343
|
+
view makes a gateway request. Undated summaries are not notified.
|
|
344
|
+
- Anything else fails the read: blank cells without hooks, a cell with an
|
|
345
|
+
attribute or markup, both layouts in one table, a bare-text table that still
|
|
346
|
+
has `studentGradesDetailsRow` rows (`UnsupportedCapabilityError`), or rows
|
|
347
|
+
of more than one student (`ParseError`).
|
|
348
|
+
|
|
349
|
+
Gateway descriptive grades (1.8.0): with the empty layout, the `ALL` view
|
|
350
|
+
reads the grades from the gateway with the login's session and the call's
|
|
351
|
+
budget: three more requests, five when there are grades. They are
|
|
352
|
+
`DescriptiveGrade`s in `descriptive` (kind `CURRENT`, no
|
|
296
353
|
`href`), with the page's subject name, the scale value or else the content as
|
|
297
354
|
`raw`, the civil date, semester 1 or 2, the teacher's name when listed, the
|
|
298
355
|
comment and metadata pairs for the present fields only (`Obszar`, `Treść`,
|
|
@@ -804,7 +861,11 @@ async with NotificationStore(Path("/absolute/private/notification-state")) as st
|
|
|
804
861
|
announcements use the ordinary collection. No menu counts, message content,
|
|
805
862
|
detail calls, modern fallback or arbitrary historical catch-up is performed.
|
|
806
863
|
- New `AGENDA` consumption requires explicit `allow_consume_events=True` each
|
|
807
|
-
time.
|
|
864
|
+
time. Without it, and with no stored raw batch to replay, `poll()` and
|
|
865
|
+
`consume_schedule_events()` raise `ConsentRequiredError` before any request
|
|
866
|
+
(from 1.8.4; before, a plain `InvalidInputError`). Other invalid inputs,
|
|
867
|
+
such as repeated categories, stay `InvalidInputError`.
|
|
868
|
+
Complete encoded raw bytes and original metadata commit before parsing.
|
|
808
869
|
Existing raw checkpoints replay locally before another consume. Malformed raw
|
|
809
870
|
data remains stored and blocks another consume, even with fresh consent.
|
|
810
871
|
- `NotificationBatch(receipt, context, first_run, categories, items,
|
|
@@ -1162,7 +1223,7 @@ text. `error_for(kind)` builds one.
|
|
|
1162
1223
|
| Error | Meaning |
|
|
1163
1224
|
| --- | --- |
|
|
1164
1225
|
| `InvalidInputError` | Rejected before any request, or upstream rejected the selection |
|
|
1165
|
-
| `ConsentRequiredError` | A subclass of `InvalidInputError` (1.8.1): a call with an effect the user must agree to, such as opening a received message, was made without that consent; nothing was requested |
|
|
1226
|
+
| `ConsentRequiredError` | A subclass of `InvalidInputError` (1.8.1): a call with an effect the user must agree to, such as opening a received message, was made without that consent; nothing was requested. Since 1.8.4 also consuming new calendar events without `allow_consume_events=True` |
|
|
1166
1227
|
| `CredentialsRejectedError` | Login and password refused |
|
|
1167
1228
|
| `AccountActionRequiredError` | CAPTCHA, 2FA or another interactive step is required |
|
|
1168
1229
|
| `SessionExpiredError` | Proven expiry that could not be recovered |
|
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.0 (2026-11-08) - Grade IDs and correction links
|
|
4
|
+
|
|
5
|
+
Thank you, @nawa, for raising krzysztofbury/librus-mcp#88 with a clear
|
|
6
|
+
description of the markup and the use case. Existing signatures are
|
|
7
|
+
unchanged; the additions are listed below.
|
|
8
|
+
|
|
9
|
+
- Grades: `NumericGrade.grade_id` and `DescriptiveGrade.grade_id` give each
|
|
10
|
+
ordinary grade its stable Librus ID from its detail link. They are computed
|
|
11
|
+
properties, like `formative_id`, so stored notification identities do not
|
|
12
|
+
change. The new `config.GRADE_DETAIL_PATH_PREFIX` is recognised, never
|
|
13
|
+
requested.
|
|
14
|
+
- Grades: `GradeRecords.corrections` and `GradeWindow.corrections` link a
|
|
15
|
+
corrected grade to its corrections. Each `GradeCorrection(subject,
|
|
16
|
+
semester, grade_ids)` lists, original first, the grades the all view shows
|
|
17
|
+
in one correction bracket (seen live on 2026-11-08 on a student and a parent
|
|
18
|
+
login, structure only). The week view showed no brackets, so its
|
|
19
|
+
`corrections` came back empty: there it means "not shown", not "not
|
|
20
|
+
corrected". Chains of more than two grades are accepted.
|
|
21
|
+
- `inspect_page grades` reports the number of `corrections`.
|
|
22
|
+
- Grades: a bracket in a layout not seen live (unbalanced, nested, around a
|
|
23
|
+
single grade, with attributes, outside the grade cell, or around a point,
|
|
24
|
+
formative or unlinked entry) now raises `ParseError`. Before, the brackets
|
|
25
|
+
were ignored and such a page parsed.
|
|
26
|
+
- Grades: failure diagnostics show correction brackets as `'['` and `']'`
|
|
27
|
+
instead of masked text.
|
|
28
|
+
- Docs: 1.8.4 described a week-view grade with two `Poprawa oceny` lines as
|
|
29
|
+
correcting two grades. A structure-only comparison with the all view shows
|
|
30
|
+
both lines name the same original, the first ending in a comma, so the
|
|
31
|
+
repeated line is not a record of several corrected grades. Parsing is
|
|
32
|
+
unchanged; `contracts/grades.md` and the config comment are corrected.
|
|
33
|
+
|
|
34
|
+
## 1.8.4 (2026-11-08) - Multi-line formative tooltips, grade checks in every view, calendar consent
|
|
35
|
+
|
|
36
|
+
Signatures are unchanged.
|
|
37
|
+
|
|
38
|
+
- Grades: the week and last-login views run the same new-schema descriptive
|
|
39
|
+
table checks as the all view (#123). They used to return summaries or
|
|
40
|
+
nothing for a table the all view rejects: blank or classed semester cells,
|
|
41
|
+
a filled table with gateway detail rows, mixed layouts or rows of more than
|
|
42
|
+
one student. Notification polls read the last-login view, so such a page
|
|
43
|
+
now fails the poll instead of passing silently. Only the all view with
|
|
44
|
+
empty `gradesCell` hooks reads the gateway, as before.
|
|
45
|
+
- Grades: a formative entry in the grade grid whose tooltip carries a
|
|
46
|
+
multi-line assessment text after `Ocena` no longer fails every grade read of
|
|
47
|
+
the login with `ParseError`. Found on two of the owner's logins by the live
|
|
48
|
+
check for this release (2026-11-08); 1.8.3 fails the same way. Unlabelled
|
|
49
|
+
lines continue `Ocena`, or a teacher-written field, with newlines. Tooltips
|
|
50
|
+
that already parsed keep the same metadata, so notification identities do
|
|
51
|
+
not change; the same lines in an ordinary grade's tooltip still fail.
|
|
52
|
+
- Grades: a grade that corrects two earlier grades no longer fails the week
|
|
53
|
+
view with `ParseError`. Its tooltip lists one `Poprawa oceny` line per
|
|
54
|
+
corrected grade (seen live on 2026-11-08 in the week view of two owner
|
|
55
|
+
logins); the values are kept in order in one metadata pair, joined by a
|
|
56
|
+
newline. Other repeated labels still fail.
|
|
57
|
+
- Notifications (krzysztofbury/librus-mcp#91): polling `AGENDA` without
|
|
58
|
+
`allow_consume_events=True` when no stored raw batch can be replayed, and
|
|
59
|
+
`consume_schedule_events()` with
|
|
60
|
+
`allow_consume_events=False`, raise `ConsentRequiredError` instead of a
|
|
61
|
+
plain invalid input, so a caller can ask the user. Nothing is requested
|
|
62
|
+
either way. `except InvalidInputError` still catches it; code comparing
|
|
63
|
+
`kind` with `INVALID_INPUT` sees the new kind. Repeated categories and a
|
|
64
|
+
non-boolean flag stay `InvalidInputError`.
|
|
65
|
+
- Docs: `API.md`, the `grades()` docstring and `contracts/grades.md` describe
|
|
66
|
+
both new-schema table layouts, which views read the gateway, and behaviour
|
|
67
|
+
grade symbols (#124).
|
|
68
|
+
- The weekly live check also reads the week and last-login grade views.
|
|
69
|
+
|
|
3
70
|
## 1.8.3 (2026-11-06) - Reported grade, attendance and announcement layouts
|
|
4
71
|
|
|
5
72
|
Thank you, @wiktorw and @Witoso, for the reports and the careful synthetic
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: librus-python-api
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.9.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,7 +42,13 @@ 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.
|
|
45
|
+
**Status:** `1.9.0` gives every ordinary grade its stable Librus ID (`grade_id`)
|
|
46
|
+
and links a corrected grade to its corrections, as the all view brackets them
|
|
47
|
+
(`GradeRecords.corrections`, [grade corrections](API.md#grade-ids-and-corrections-190)).
|
|
48
|
+
`1.8.4` reads multi-line formative assessment text and repeated
|
|
49
|
+
correction lines in grade tooltips, checks the new-schema grade table in every grade view and reports
|
|
50
|
+
missing calendar-consumption consent as `ConsentRequiredError`.
|
|
51
|
+
`1.8.3` reads behaviour grade symbols, filled descriptive
|
|
46
52
|
grade tables, the "Aktualnie brak ogłoszeń" page and absences excused
|
|
47
53
|
through e-Usprawiedliwienia. `1.8.2` keeps the modern mailbox session across a cancelled read
|
|
48
54
|
or a reached limit and sends its own version in the `User-Agent`. `1.8.1` recovers a session Synergia no longer knows (it answers
|
|
@@ -66,7 +72,7 @@ See [limitations](#supported-features-and-limitations) below.
|
|
|
66
72
|
Install the exact release from PyPI after its gated publication completes:
|
|
67
73
|
|
|
68
74
|
```sh
|
|
69
|
-
python -m pip install librus-python-api==1.
|
|
75
|
+
python -m pip install librus-python-api==1.9.0
|
|
70
76
|
```
|
|
71
77
|
|
|
72
78
|
Pin the exact version qualified by your application. Before publication, use a
|
|
@@ -82,7 +88,7 @@ python -m pip install .
|
|
|
82
88
|
To install a locally built wheel instead:
|
|
83
89
|
|
|
84
90
|
```sh
|
|
85
|
-
python -m pip install ./dist/librus_python_api-1.
|
|
91
|
+
python -m pip install ./dist/librus_python_api-1.9.0-py3-none-any.whl
|
|
86
92
|
```
|
|
87
93
|
|
|
88
94
|
No console script or background process is installed: import the library in your
|
|
@@ -16,7 +16,13 @@ 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.
|
|
19
|
+
**Status:** `1.9.0` gives every ordinary grade its stable Librus ID (`grade_id`)
|
|
20
|
+
and links a corrected grade to its corrections, as the all view brackets them
|
|
21
|
+
(`GradeRecords.corrections`, [grade corrections](API.md#grade-ids-and-corrections-190)).
|
|
22
|
+
`1.8.4` reads multi-line formative assessment text and repeated
|
|
23
|
+
correction lines in grade tooltips, checks the new-schema grade table in every grade view and reports
|
|
24
|
+
missing calendar-consumption consent as `ConsentRequiredError`.
|
|
25
|
+
`1.8.3` reads behaviour grade symbols, filled descriptive
|
|
20
26
|
grade tables, the "Aktualnie brak ogłoszeń" page and absences excused
|
|
21
27
|
through e-Usprawiedliwienia. `1.8.2` keeps the modern mailbox session across a cancelled read
|
|
22
28
|
or a reached limit and sends its own version in the `User-Agent`. `1.8.1` recovers a session Synergia no longer knows (it answers
|
|
@@ -40,7 +46,7 @@ See [limitations](#supported-features-and-limitations) below.
|
|
|
40
46
|
Install the exact release from PyPI after its gated publication completes:
|
|
41
47
|
|
|
42
48
|
```sh
|
|
43
|
-
python -m pip install librus-python-api==1.
|
|
49
|
+
python -m pip install librus-python-api==1.9.0
|
|
44
50
|
```
|
|
45
51
|
|
|
46
52
|
Pin the exact version qualified by your application. Before publication, use a
|
|
@@ -56,7 +62,7 @@ python -m pip install .
|
|
|
56
62
|
To install a locally built wheel instead:
|
|
57
63
|
|
|
58
64
|
```sh
|
|
59
|
-
python -m pip install ./dist/librus_python_api-1.
|
|
65
|
+
python -m pip install ./dist/librus_python_api-1.9.0-py3-none-any.whl
|
|
60
66
|
```
|
|
61
67
|
|
|
62
68
|
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.
|
|
4
|
+
__version__ = "1.9.0"
|
|
5
5
|
|
|
6
6
|
from librus_python_api.attachments import AttachmentStream, ModernAttachmentStream
|
|
7
7
|
from librus_python_api.budget import RequestBudget
|
|
@@ -53,6 +53,7 @@ from librus_python_api.models import (
|
|
|
53
53
|
FrequencyMeasure,
|
|
54
54
|
GatewayAttendance,
|
|
55
55
|
GatewayAttendanceRecord,
|
|
56
|
+
GradeCorrection,
|
|
56
57
|
GradeKind,
|
|
57
58
|
GradeRecords,
|
|
58
59
|
Grades,
|
|
@@ -258,6 +259,7 @@ __all__ = [
|
|
|
258
259
|
"DescriptiveGradeSummary",
|
|
259
260
|
"FinalGrades",
|
|
260
261
|
"FormativeGrade",
|
|
262
|
+
"GradeCorrection",
|
|
261
263
|
"GradeKind",
|
|
262
264
|
"GradeRecords",
|
|
263
265
|
"Grades",
|
|
@@ -721,8 +721,14 @@ GRADE_MAX_VALUE_LENGTH = 1024
|
|
|
721
721
|
GRADE_MERGED_SUBJECTS = frozenset({"Zachowanie"})
|
|
722
722
|
GRADE_INLINE_DETAIL_LABEL = "Ocena"
|
|
723
723
|
# Tooltip fields whose free text may continue on unlabelled lines. A teacher's
|
|
724
|
-
# multi-line grade comment was observed on 2026-10-27.
|
|
724
|
+
# multi-line grade comment was observed on 2026-10-27. A formative mirror's
|
|
725
|
+
# assessment text after `Ocena` also spans lines (2026-11-08, markup.py).
|
|
725
726
|
TOOLTIP_MULTILINE_LABELS = frozenset({"Komentarz"})
|
|
727
|
+
# Labels a tooltip may repeat. In the week view a correction listed
|
|
728
|
+
# `Poprawa oceny` twice, both naming the same original grade, the first ending
|
|
729
|
+
# in a comma; the all view showed it once (2026-11-08). The tooltip is no
|
|
730
|
+
# record of which grades were corrected: correction brackets are.
|
|
731
|
+
TOOLTIP_REPEATABLE_LABELS = frozenset({"Poprawa oceny"})
|
|
726
732
|
# Tooltip labels observed on grade, attendance and point pages. Diagnostics
|
|
727
733
|
# show only these by name; any other label is masked as teacher-entered text.
|
|
728
734
|
TOOLTIP_LABELS = frozenset(
|
|
@@ -744,6 +750,7 @@ TOOLTIP_LABELS = frozenset(
|
|
|
744
750
|
"Nauczyciel",
|
|
745
751
|
"Obowiązek wyk. zadania",
|
|
746
752
|
"Ocena",
|
|
753
|
+
"Poprawa oceny",
|
|
747
754
|
"Rodzaj",
|
|
748
755
|
"Suma punktów",
|
|
749
756
|
"Temat zajęć",
|
|
@@ -764,6 +771,12 @@ GRADE_VIEW_FIELDS = MappingProxyType(
|
|
|
764
771
|
)
|
|
765
772
|
GRADE_CURRENT_HEADER = "Oceny bieżące"
|
|
766
773
|
GRADE_EMPTY_MARKERS = frozenset({"", "-", "Brak ocen"})
|
|
774
|
+
# The all view wraps a corrected grade and its correction in a bare <span>
|
|
775
|
+
# directly in the grade cell: its text is "[", its children are the grade
|
|
776
|
+
# boxes in page order (original first) and the last box's tail is "]" (owner
|
|
777
|
+
# logins, structure-only, 2026-11-08). The week view showed no brackets, even
|
|
778
|
+
# with the original in the same cell. Groups of more than two are accepted.
|
|
779
|
+
GRADE_CORRECTION_BRACKETS = ("[", "]")
|
|
767
780
|
GRADE_AVERAGE_HEADERS = MappingProxyType(
|
|
768
781
|
{"Średnia ocen": 1, "Średnia ocen z drugiego okresu": 2, "Średnia roczna": 0}
|
|
769
782
|
)
|
|
@@ -783,8 +796,9 @@ GRADE_PERIOD_HEADERS = MappingProxyType(
|
|
|
783
796
|
"Ocena roczna": 0,
|
|
784
797
|
}
|
|
785
798
|
)
|
|
786
|
-
# New-schema descriptive grading: the page renders this table with empty
|
|
787
|
-
# semester cells
|
|
799
|
+
# New-schema descriptive grading: the page renders this table either with empty
|
|
800
|
+
# `gradesCell` semester cells, which its script fills from the gateway routes
|
|
801
|
+
# above, or with bare semester text, which needs no gateway read.
|
|
788
802
|
DESCRIPTIVE_TABLE_CLASS = "newSchemaGradesByStudentTable"
|
|
789
803
|
DESCRIPTIVE_ROW_CLASS = "studentRow"
|
|
790
804
|
DESCRIPTIVE_DETAILS_ROW_CLASS = "studentGradesDetailsRow"
|
|
@@ -865,6 +879,10 @@ BEHAVIOUR_POINTS_DETAIL_PATH_PREFIX = "/przegladaj_oceny/zachowanie_szczegoly/"
|
|
|
865
879
|
BEHAVIOUR_GRADE_LABELS = frozenset({"Data wystawienia", "Dodał", "Komentarz"})
|
|
866
880
|
# Recognition only: point-grade detail links are classified, never requested.
|
|
867
881
|
POINT_GRADE_DETAIL_PATH_PREFIX = "/przegladaj_oceny_punktowe/szczegoly/"
|
|
882
|
+
# Recognition only: an ordinary grade's own detail link gives its stable grade
|
|
883
|
+
# ID (librus-mcp#88); the page is never requested. Formative links share this
|
|
884
|
+
# prefix but have no digits-only rest, so they never yield a grade ID.
|
|
885
|
+
GRADE_DETAIL_PATH_PREFIX = "/przegladaj_oceny/szczegoly/"
|
|
868
886
|
FORMATIVE_HEADERS = (
|
|
869
887
|
"przedmiot",
|
|
870
888
|
"ocena kształtująca",
|
|
@@ -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,
|
|
@@ -13,8 +13,10 @@ from librus_python_api.config import (
|
|
|
13
13
|
FORMATIVE_DETAIL_PATH_PREFIX,
|
|
14
14
|
GRADE_AVERAGE_HEADERS,
|
|
15
15
|
GRADE_BODY_PREFIX_COLUMNS,
|
|
16
|
+
GRADE_CORRECTION_BRACKETS,
|
|
16
17
|
GRADE_CURRENT_HEADER,
|
|
17
18
|
GRADE_EMPTY_MARKERS,
|
|
19
|
+
GRADE_INLINE_DETAIL_LABEL,
|
|
18
20
|
GRADE_MAX_METADATA_LENGTH,
|
|
19
21
|
GRADE_MAX_RECORDS,
|
|
20
22
|
GRADE_MAX_SUBJECTS,
|
|
@@ -28,6 +30,7 @@ from librus_python_api.config import (
|
|
|
28
30
|
GRADE_PUBLICATION_PERIOD_LABELS,
|
|
29
31
|
GRADE_PUBLICATION_TEACHER_LABEL,
|
|
30
32
|
TOOLTIP_LABELS,
|
|
33
|
+
TOOLTIP_MULTILINE_LABELS,
|
|
31
34
|
)
|
|
32
35
|
from librus_python_api.exceptions import ErrorKind, LibrusError
|
|
33
36
|
from librus_python_api.formative_grades import is_formative_table, read_formative_table
|
|
@@ -45,6 +48,7 @@ from librus_python_api.models import (
|
|
|
45
48
|
DescriptiveGrade,
|
|
46
49
|
DescriptiveGradeSummary,
|
|
47
50
|
FormativeGrade,
|
|
51
|
+
GradeCorrection,
|
|
48
52
|
GradeKind,
|
|
49
53
|
GradeRecords,
|
|
50
54
|
GradeSummaryValue,
|
|
@@ -99,7 +103,16 @@ def _numeric(
|
|
|
99
103
|
semester: Literal[0, 1, 2],
|
|
100
104
|
kind: GradeKind = GradeKind.CURRENT,
|
|
101
105
|
) -> NumericGrade:
|
|
102
|
-
|
|
106
|
+
if markup.detail_id(element.get("href"), FORMATIVE_DETAIL_PATH_PREFIX) is None:
|
|
107
|
+
metadata = markup.tooltip_fields(element)
|
|
108
|
+
else:
|
|
109
|
+
# A formative mirror's assessment text after `Ocena` is free text that
|
|
110
|
+
# may span lines and hold colons (observed live 2026-11-08).
|
|
111
|
+
metadata = markup.tooltip_fields(
|
|
112
|
+
element,
|
|
113
|
+
multiline=TOOLTIP_MULTILINE_LABELS | {GRADE_INLINE_DETAIL_LABEL},
|
|
114
|
+
unknown_multiline=True,
|
|
115
|
+
)
|
|
103
116
|
counts = metadata.get("Licz do średniej")
|
|
104
117
|
if counts is not None and counts.casefold() not in ("tak", "nie"):
|
|
105
118
|
raise LibrusError(ErrorKind.PARSE)
|
|
@@ -205,6 +218,8 @@ class _Collection:
|
|
|
205
218
|
)
|
|
206
219
|
averages: list[SchoolAverage] = field(default_factory=list, repr=False)
|
|
207
220
|
point_results: list[SchoolAverage] = field(default_factory=list, repr=False)
|
|
221
|
+
corrections: list[GradeCorrection] = field(default_factory=list, repr=False)
|
|
222
|
+
corrected: set[str] = field(default_factory=set, repr=False)
|
|
208
223
|
subjects: set[tuple[bool, str]] = field(default_factory=set, repr=False)
|
|
209
224
|
point_subjects: set[str] = field(default_factory=set, repr=False)
|
|
210
225
|
consumed: set[html.HtmlElement] = field(default_factory=set, repr=False)
|
|
@@ -243,11 +258,89 @@ class _Collection:
|
|
|
243
258
|
|
|
244
259
|
|
|
245
260
|
def _boxes(cell: html.HtmlElement) -> list[html.HtmlElement]:
|
|
246
|
-
return [
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
261
|
+
return [node for node in cell.iter("span") if _is_box(node)]
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _is_box(node: html.HtmlElement) -> bool:
|
|
265
|
+
return isinstance(node.tag, str) and "grade-box" in node.get("class", "").split()
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def _brackets(
|
|
269
|
+
cell: html.HtmlElement, boxes: list[html.HtmlElement]
|
|
270
|
+
) -> list[list[html.HtmlElement]]:
|
|
271
|
+
"""The correction brackets of a grade cell, each its grade boxes in order.
|
|
272
|
+
|
|
273
|
+
A bracket is a bare <span> directly in the cell whose text is "[", whose
|
|
274
|
+
element children are two or more grade boxes, and whose last child's tail
|
|
275
|
+
is "]" (config.GRADE_CORRECTION_BRACKETS); comments are ignored. Any other
|
|
276
|
+
bracket text outside grade boxes, such as an unbalanced or nested bracket,
|
|
277
|
+
fails the read instead of dropping a correction link.
|
|
278
|
+
"""
|
|
279
|
+
opening, closing = GRADE_CORRECTION_BRACKETS
|
|
280
|
+
inside = set(boxes)
|
|
281
|
+
outside = [cell.text or ""]
|
|
282
|
+
pending = list(cell)
|
|
283
|
+
while pending:
|
|
284
|
+
node = pending.pop()
|
|
285
|
+
outside.append(node.tail or "")
|
|
286
|
+
if node not in inside and isinstance(node.tag, str):
|
|
287
|
+
outside.append(node.text or "")
|
|
288
|
+
pending.extend(node)
|
|
289
|
+
marks = sum(text.count(opening) + text.count(closing) for text in outside)
|
|
290
|
+
if not marks:
|
|
291
|
+
return []
|
|
292
|
+
groups = []
|
|
293
|
+
for wrapper in cell:
|
|
294
|
+
if wrapper.tag != "span" or wrapper.attrib:
|
|
295
|
+
continue
|
|
296
|
+
if (wrapper.text or "").strip() != opening:
|
|
297
|
+
continue
|
|
298
|
+
children = list(wrapper)
|
|
299
|
+
members = [child for child in children if isinstance(child.tag, str)]
|
|
300
|
+
if (
|
|
301
|
+
len(members) < 2
|
|
302
|
+
or not all(member in inside for member in members)
|
|
303
|
+
or any((child.tail or "").strip() for child in children[:-1])
|
|
304
|
+
or (children[-1].tail or "").strip() != closing
|
|
305
|
+
):
|
|
306
|
+
raise LibrusError(ErrorKind.PARSE)
|
|
307
|
+
groups.append(members)
|
|
308
|
+
if marks != 2 * len(groups):
|
|
309
|
+
raise LibrusError(ErrorKind.PARSE)
|
|
310
|
+
return groups
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
def _read_corrections(
|
|
314
|
+
groups: list[list[html.HtmlElement]],
|
|
315
|
+
ids: dict[html.HtmlElement, str | None],
|
|
316
|
+
subject: str,
|
|
317
|
+
period: Literal[0, 1, 2],
|
|
318
|
+
collection: _Collection,
|
|
319
|
+
*,
|
|
320
|
+
points: bool,
|
|
321
|
+
) -> None:
|
|
322
|
+
for boxes in groups:
|
|
323
|
+
members = [ids.get(box) for box in boxes]
|
|
324
|
+
if any(member is None for member in members):
|
|
325
|
+
# Only ordinary grades with their own detail link were observed.
|
|
326
|
+
raise LibrusError(ErrorKind.PARSE)
|
|
327
|
+
correction = GradeCorrection(
|
|
328
|
+
subject, period, tuple(cast(str, member) for member in members)
|
|
329
|
+
)
|
|
330
|
+
if points:
|
|
331
|
+
# Brackets were not observed in the point table. Only a period
|
|
332
|
+
# grade it shows again, already read from the ordinary table, is
|
|
333
|
+
# accepted, as one link like its record.
|
|
334
|
+
if correction not in collection.corrections:
|
|
335
|
+
raise LibrusError(ErrorKind.PARSE)
|
|
336
|
+
continue
|
|
337
|
+
grade_ids = correction.grade_ids
|
|
338
|
+
if len(set(grade_ids)) != len(grade_ids) or not collection.corrected.isdisjoint(
|
|
339
|
+
grade_ids
|
|
340
|
+
):
|
|
341
|
+
raise LibrusError(ErrorKind.PARSE)
|
|
342
|
+
collection.corrected.update(grade_ids)
|
|
343
|
+
collection.corrections.append(correction)
|
|
251
344
|
|
|
252
345
|
|
|
253
346
|
def _behaviour_points(cell: html.HtmlElement, collection: _Collection) -> bool:
|
|
@@ -303,8 +396,11 @@ def _entries(
|
|
|
303
396
|
kind: GradeKind = GradeKind.CURRENT,
|
|
304
397
|
descriptive: bool = False,
|
|
305
398
|
require_empty_marker: bool = True,
|
|
399
|
+
points: bool = False,
|
|
306
400
|
) -> None:
|
|
307
401
|
boxes = _boxes(cell)
|
|
402
|
+
groups = _brackets(cell, boxes) if boxes else []
|
|
403
|
+
ids: dict[html.HtmlElement, str | None] = {}
|
|
308
404
|
if (
|
|
309
405
|
not boxes
|
|
310
406
|
and require_empty_marker
|
|
@@ -365,14 +461,17 @@ def _entries(
|
|
|
365
461
|
href,
|
|
366
462
|
)
|
|
367
463
|
)
|
|
464
|
+
ids[box] = collection.descriptive[-1].grade_id
|
|
368
465
|
else:
|
|
369
466
|
collection.numeric.append(record)
|
|
467
|
+
ids[box] = record.grade_id
|
|
370
468
|
else:
|
|
371
469
|
collection.descriptive.append(
|
|
372
470
|
_descriptive(box, descriptions[0], subject, period, kind)
|
|
373
471
|
)
|
|
374
472
|
collection.consumed.add(box)
|
|
375
473
|
collection.check_size()
|
|
474
|
+
_read_corrections(groups, ids, subject, period, collection, points=points)
|
|
376
475
|
|
|
377
476
|
|
|
378
477
|
def _descriptive_row(cells: list[html.HtmlElement]) -> bool:
|
|
@@ -475,7 +574,11 @@ def _read_numeric_table(
|
|
|
475
574
|
):
|
|
476
575
|
start = len(collection.numeric)
|
|
477
576
|
_entries(
|
|
478
|
-
columns[index],
|
|
577
|
+
columns[index],
|
|
578
|
+
subject,
|
|
579
|
+
cast(Literal[1, 2], period),
|
|
580
|
+
collection,
|
|
581
|
+
points=points,
|
|
479
582
|
)
|
|
480
583
|
# A point entry without its detail link would pass as a
|
|
481
584
|
# grade symbol; an unseen link layout fails instead. The
|
|
@@ -498,6 +601,7 @@ def _read_numeric_table(
|
|
|
498
601
|
collection,
|
|
499
602
|
kind=kind,
|
|
500
603
|
require_empty_marker=False,
|
|
604
|
+
points=points,
|
|
501
605
|
)
|
|
502
606
|
collection.numeric[start:] = [
|
|
503
607
|
record for record in collection.numeric[start:] if record not in prior
|
|
@@ -663,4 +767,5 @@ def read_grade_records(document: html.HtmlElement) -> GradeRecords:
|
|
|
663
767
|
tuple(collection.descriptive_summaries),
|
|
664
768
|
formative,
|
|
665
769
|
tuple(collection.point_results),
|
|
770
|
+
tuple(collection.corrections),
|
|
666
771
|
)
|
|
@@ -31,7 +31,7 @@ NOTICE = (
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
def _grades(body: bytes) -> dict[str, int]:
|
|
34
|
-
#
|
|
34
|
+
# Every grade view also checks the new-schema table, as `grades()` does.
|
|
35
35
|
records, table = parse_grade_page(body)
|
|
36
36
|
return {
|
|
37
37
|
"numeric": sum(1 for g in records.numeric if g.point_grade_id is None),
|
|
@@ -42,6 +42,7 @@ def _grades(body: bytes) -> dict[str, int]:
|
|
|
42
42
|
"averages": len(records.averages),
|
|
43
43
|
"point_results": len(records.point_results),
|
|
44
44
|
"formative": len(records.formative),
|
|
45
|
+
"corrections": len(records.corrections),
|
|
45
46
|
"descriptive_table": int(table is not None),
|
|
46
47
|
"descriptive_table_filled": int(table is not None and table.filled),
|
|
47
48
|
}
|
|
@@ -13,7 +13,9 @@ from librus_python_api.config import (
|
|
|
13
13
|
GRADE_MAX_COLUMNS,
|
|
14
14
|
GRADE_MAX_METADATA_FIELDS,
|
|
15
15
|
GRADE_MAX_METADATA_LENGTH,
|
|
16
|
+
TOOLTIP_LABELS,
|
|
16
17
|
TOOLTIP_MULTILINE_LABELS,
|
|
18
|
+
TOOLTIP_REPEATABLE_LABELS,
|
|
17
19
|
UPSTREAM_ORIGINS,
|
|
18
20
|
)
|
|
19
21
|
from librus_python_api.exceptions import ErrorKind, LibrusError
|
|
@@ -82,14 +84,27 @@ def colspan(cell: html.HtmlElement) -> int:
|
|
|
82
84
|
|
|
83
85
|
|
|
84
86
|
def tooltip_fields(
|
|
85
|
-
element: html.HtmlElement,
|
|
87
|
+
element: html.HtmlElement,
|
|
88
|
+
heading: list[str] | None = None,
|
|
89
|
+
*,
|
|
90
|
+
multiline: frozenset[str] | None = None,
|
|
91
|
+
unknown_multiline: bool = False,
|
|
86
92
|
) -> dict[str, str]:
|
|
87
93
|
"""Parse a 'Label: value<br>' title attribute into unique labelled fields.
|
|
88
94
|
|
|
89
95
|
A free-text field may span lines; an unlabelled line after it continues
|
|
90
96
|
its value. Any other unlabelled line is an unknown layout. With `heading`,
|
|
91
97
|
the first line is taken whole, colon included, and appended to it.
|
|
98
|
+
`multiline` names the free-text labels (default `Komentarz`); with
|
|
99
|
+
`unknown_multiline`, a field whose label is not a known one (teacher text
|
|
100
|
+
holding a colon) is free text too, and inside such free text a line
|
|
101
|
+
starting with a known label is text unless the tooltip's closing run of
|
|
102
|
+
known-label lines begins there. Otherwise a known label such as `Data`
|
|
103
|
+
never continues. A repeatable label (`Poprawa oceny`) adds its value as
|
|
104
|
+
one more line of the same field.
|
|
92
105
|
"""
|
|
106
|
+
if multiline is None:
|
|
107
|
+
multiline = TOOLTIP_MULTILINE_LABELS
|
|
93
108
|
title = element.get("title", "")
|
|
94
109
|
if len(title) > GRADE_MAX_METADATA_LENGTH:
|
|
95
110
|
raise LibrusError(ErrorKind.LIMIT)
|
|
@@ -98,18 +113,34 @@ def tooltip_fields(
|
|
|
98
113
|
chunks = re.split(r"<br\s*/?>|\n", title, flags=re.I)
|
|
99
114
|
if len(chunks) > GRADE_MAX_METADATA_FIELDS:
|
|
100
115
|
raise LibrusError(ErrorKind.LIMIT)
|
|
101
|
-
for chunk in chunks
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
116
|
+
lines = [tooltip_line(chunk) for chunk in chunks if chunk.strip()]
|
|
117
|
+
# Start of the closing run of known-label lines, such as Kategoria, Data.
|
|
118
|
+
closing = len(lines)
|
|
119
|
+
while closing and _known_label(lines[closing - 1]):
|
|
120
|
+
closing -= 1
|
|
121
|
+
for index, rendered in enumerate(lines):
|
|
105
122
|
if heading is not None and not heading:
|
|
106
123
|
heading.append(rendered)
|
|
107
124
|
continue
|
|
108
125
|
key, separator, value = rendered.partition(":")
|
|
109
126
|
key, value = key.strip(), value.strip()
|
|
110
|
-
if
|
|
127
|
+
if (
|
|
128
|
+
last is not None
|
|
129
|
+
and (
|
|
130
|
+
last in multiline or (unknown_multiline and last not in TOOLTIP_LABELS)
|
|
131
|
+
)
|
|
132
|
+
and (
|
|
133
|
+
not separator
|
|
134
|
+
or (unknown_multiline and index < closing and key in TOOLTIP_LABELS)
|
|
135
|
+
)
|
|
136
|
+
):
|
|
111
137
|
result[last] = f"{result[last]}\n{rendered}".strip()
|
|
112
138
|
continue
|
|
139
|
+
if separator and key in result and key in TOOLTIP_REPEATABLE_LABELS:
|
|
140
|
+
# Each repeat keeps its value, in order, as one more line.
|
|
141
|
+
result[key] = f"{result[key]}\n{value}"
|
|
142
|
+
last = key
|
|
143
|
+
continue
|
|
113
144
|
if not separator or not key or key in result:
|
|
114
145
|
raise LibrusError(ErrorKind.PARSE)
|
|
115
146
|
result[key] = value
|
|
@@ -117,6 +148,11 @@ def tooltip_fields(
|
|
|
117
148
|
return result
|
|
118
149
|
|
|
119
150
|
|
|
151
|
+
def _known_label(line: str) -> bool:
|
|
152
|
+
key, separator, _ = line.partition(":")
|
|
153
|
+
return bool(separator) and key.strip() in TOOLTIP_LABELS
|
|
154
|
+
|
|
155
|
+
|
|
120
156
|
def tooltip_line(chunk: str) -> str:
|
|
121
157
|
"""One tooltip line's text, whitespace normalized."""
|
|
122
158
|
# Tooltips are HTML inside an attribute; parse markup only where present.
|
|
@@ -1070,6 +1070,20 @@ class NumericGrade:
|
|
|
1070
1070
|
|
|
1071
1071
|
return detail_id(self.href, POINT_GRADE_DETAIL_PATH_PREFIX)
|
|
1072
1072
|
|
|
1073
|
+
@property
|
|
1074
|
+
def grade_id(self) -> str | None:
|
|
1075
|
+
"""The grade's own Librus ID when `href` is an ordinary grade detail link.
|
|
1076
|
+
|
|
1077
|
+
Stable across reads and views, so it identifies one grade even when
|
|
1078
|
+
two share value, category and day. None for formative, point and
|
|
1079
|
+
behaviour links, and for entries without a link. Computed for the same
|
|
1080
|
+
identity reason as `formative_id`.
|
|
1081
|
+
"""
|
|
1082
|
+
from librus_python_api.config import GRADE_DETAIL_PATH_PREFIX
|
|
1083
|
+
from librus_python_api.markup import detail_id
|
|
1084
|
+
|
|
1085
|
+
return detail_id(self.href, GRADE_DETAIL_PATH_PREFIX)
|
|
1086
|
+
|
|
1073
1087
|
|
|
1074
1088
|
@dataclass(frozen=True, slots=True)
|
|
1075
1089
|
class DescriptiveGrade:
|
|
@@ -1096,6 +1110,17 @@ class DescriptiveGrade:
|
|
|
1096
1110
|
|
|
1097
1111
|
return detail_id(self.href, FORMATIVE_DETAIL_PATH_PREFIX)
|
|
1098
1112
|
|
|
1113
|
+
@property
|
|
1114
|
+
def grade_id(self) -> str | None:
|
|
1115
|
+
"""The grade's own Librus ID when `href` is an ordinary grade detail link.
|
|
1116
|
+
|
|
1117
|
+
Computed, like `NumericGrade.grade_id`, so identities stay unchanged.
|
|
1118
|
+
"""
|
|
1119
|
+
from librus_python_api.config import GRADE_DETAIL_PATH_PREFIX
|
|
1120
|
+
from librus_python_api.markup import detail_id
|
|
1121
|
+
|
|
1122
|
+
return detail_id(self.href, GRADE_DETAIL_PATH_PREFIX)
|
|
1123
|
+
|
|
1099
1124
|
|
|
1100
1125
|
@dataclass(frozen=True, slots=True)
|
|
1101
1126
|
class SchoolAverage:
|
|
@@ -1131,6 +1156,21 @@ class FormativeGrade:
|
|
|
1131
1156
|
detail_id: str = field(repr=False)
|
|
1132
1157
|
|
|
1133
1158
|
|
|
1159
|
+
@dataclass(frozen=True, slots=True)
|
|
1160
|
+
class GradeCorrection:
|
|
1161
|
+
"""Grades the all view shows in one correction bracket, in page order.
|
|
1162
|
+
|
|
1163
|
+
`grade_ids` holds at least two `grade_id`s: the first is the corrected
|
|
1164
|
+
original and each later grade corrects the ones before it, so the last is
|
|
1165
|
+
the latest correction. Read from the bracket markup alone, never inferred
|
|
1166
|
+
from `Poprawa oceny` tooltip lines, which name no grade ID.
|
|
1167
|
+
"""
|
|
1168
|
+
|
|
1169
|
+
subject: str = field(repr=False)
|
|
1170
|
+
semester: Literal[0, 1, 2]
|
|
1171
|
+
grade_ids: tuple[str, ...] = field(repr=False)
|
|
1172
|
+
|
|
1173
|
+
|
|
1134
1174
|
@dataclass(frozen=True, slots=True)
|
|
1135
1175
|
class GradeRecords:
|
|
1136
1176
|
numeric: tuple[NumericGrade, ...] = field(repr=False)
|
|
@@ -1143,6 +1183,8 @@ class GradeRecords:
|
|
|
1143
1183
|
# A point table's period results, on its score scale; never merged into
|
|
1144
1184
|
# `averages`, whose values are the ordinary grade-scale means.
|
|
1145
1185
|
point_results: tuple[SchoolAverage, ...] = field(default=(), repr=False)
|
|
1186
|
+
# The page's correction brackets; only the all view was seen to show them.
|
|
1187
|
+
corrections: tuple[GradeCorrection, ...] = field(default=(), repr=False)
|
|
1146
1188
|
|
|
1147
1189
|
|
|
1148
1190
|
@dataclass(frozen=True, slots=True)
|
|
@@ -1163,6 +1205,8 @@ class GradeWindow:
|
|
|
1163
1205
|
observation: Observation
|
|
1164
1206
|
view: GradeView = GradeView.ALL
|
|
1165
1207
|
formative: tuple[FormativeGrade, ...] = field(default=(), repr=False)
|
|
1208
|
+
# Each correction with at least one of its grades in the window, whole.
|
|
1209
|
+
corrections: tuple[GradeCorrection, ...] = field(default=(), repr=False)
|
|
1166
1210
|
|
|
1167
1211
|
|
|
1168
1212
|
@dataclass(frozen=True, slots=True)
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/notification_workflow.py
RENAMED
|
@@ -130,7 +130,8 @@ class NotificationWorkflow:
|
|
|
130
130
|
if uncertain:
|
|
131
131
|
raise LibrusError(ErrorKind.CHECKPOINT)
|
|
132
132
|
if not consume:
|
|
133
|
-
|
|
133
|
+
# Nothing is read before the caller agrees to consume new events.
|
|
134
|
+
raise LibrusError(ErrorKind.CONSENT_REQUIRED)
|
|
134
135
|
state = await store._io(lambda: store._read_state(context.identifier))
|
|
135
136
|
ordinary = await self._ordinary(categories, window, budget)
|
|
136
137
|
# Validate whole ordinary results and state capacity before consuming.
|
|
@@ -89,7 +89,6 @@ from librus_python_api.gateway_grades import (
|
|
|
89
89
|
parse_user_info,
|
|
90
90
|
)
|
|
91
91
|
from librus_python_api.grade_parsers import parse_final_grades
|
|
92
|
-
from librus_python_api.grade_records import parse_grade_records
|
|
93
92
|
from librus_python_api.homework_range import HomeworkAccumulator
|
|
94
93
|
from librus_python_api.lifecycle import join_owned
|
|
95
94
|
from librus_python_api.message_content import parse_message_content, validate_reference
|
|
@@ -1084,11 +1083,11 @@ class AccountClient:
|
|
|
1084
1083
|
Callback success acknowledges consumer-owned durable storage. Callback
|
|
1085
1084
|
failure/timeout means acknowledgement unknown, never automatic replay.
|
|
1086
1085
|
"""
|
|
1087
|
-
if (
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1086
|
+
if type(allow_consume_events) is not bool:
|
|
1087
|
+
raise LibrusError(ErrorKind.INVALID_INPUT)
|
|
1088
|
+
if not allow_consume_events:
|
|
1089
|
+
raise LibrusError(ErrorKind.CONSENT_REQUIRED)
|
|
1090
|
+
if self._consuming_schedule:
|
|
1092
1091
|
raise LibrusError(ErrorKind.INVALID_INPUT)
|
|
1093
1092
|
validate_checkpoint(checkpoint, checkpoint_timeout_seconds)
|
|
1094
1093
|
self._consuming_schedule = True
|
|
@@ -1324,24 +1323,28 @@ class AccountClient:
|
|
|
1324
1323
|
"""Select a grade view with one view-changing POST.
|
|
1325
1324
|
|
|
1326
1325
|
Changes the selected grade filter, not school records. A cache hit makes
|
|
1327
|
-
no POST. Missing inline weight/count data remains unknown.
|
|
1328
|
-
|
|
1326
|
+
no POST. Missing inline weight/count data remains unknown.
|
|
1327
|
+
|
|
1328
|
+
Every view checks a new-schema descriptive table the same way. Its
|
|
1329
|
+
semester cells either are empty script hooks or hold bare text, which
|
|
1330
|
+
becomes undated summaries with no extra request; any other layout
|
|
1331
|
+
fails the read. Only the all view with empty hooks adds that table's
|
|
1329
1332
|
grades from the gateway: three more reads, five when there are grades.
|
|
1330
|
-
|
|
1333
|
+
|
|
1334
|
+
`records.corrections` links a corrected grade to its corrections by
|
|
1335
|
+
`grade_id`, read from the page's correction brackets. Only the all view
|
|
1336
|
+
was seen to show them; in the week view it came back empty, which does
|
|
1337
|
+
not mean nothing was corrected. A bracket in a layout not seen live
|
|
1338
|
+
fails the read instead of dropping the link.
|
|
1331
1339
|
"""
|
|
1332
1340
|
form = grade_view_form(view)
|
|
1333
1341
|
|
|
1334
1342
|
async def fetch(budget: RequestBudget, _: bool) -> Grades:
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
records, table = await self._page(
|
|
1341
|
-
"grades", budget, parse_grade_page, form=form
|
|
1342
|
-
)
|
|
1343
|
-
if table is not None and not table.filled:
|
|
1344
|
-
records = await self._gateway_descriptive(records, table, budget)
|
|
1343
|
+
records, table = await self._page(
|
|
1344
|
+
"grades", budget, parse_grade_page, form=form
|
|
1345
|
+
)
|
|
1346
|
+
if view is GradeView.ALL and table is not None and not table.filled:
|
|
1347
|
+
records = await self._gateway_descriptive(records, table, budget)
|
|
1345
1348
|
return Grades(
|
|
1346
1349
|
self._session_identity(), records, self._observation("grades"), view
|
|
1347
1350
|
)
|
|
@@ -1366,26 +1369,26 @@ class AccountClient:
|
|
|
1366
1369
|
result = await self.grades(
|
|
1367
1370
|
view=view, budget=budget, max_age_seconds=max_age_seconds
|
|
1368
1371
|
)
|
|
1372
|
+
|
|
1373
|
+
def within(day: date) -> bool:
|
|
1374
|
+
return (start is None or start <= day) and (end is None or day <= end)
|
|
1375
|
+
|
|
1376
|
+
numeric = tuple(g for g in result.records.numeric if within(g.day))
|
|
1377
|
+
descriptive = tuple(g for g in result.records.descriptive if within(g.day))
|
|
1378
|
+
visible = {g.grade_id for g in numeric} | {g.grade_id for g in descriptive}
|
|
1369
1379
|
return GradeWindow(
|
|
1370
1380
|
result.identity,
|
|
1371
1381
|
start,
|
|
1372
1382
|
end,
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
for g in result.records.numeric
|
|
1376
|
-
if (start is None or start <= g.day) and (end is None or g.day <= end)
|
|
1377
|
-
),
|
|
1378
|
-
tuple(
|
|
1379
|
-
g
|
|
1380
|
-
for g in result.records.descriptive
|
|
1381
|
-
if (start is None or start <= g.day) and (end is None or g.day <= end)
|
|
1382
|
-
),
|
|
1383
|
+
numeric,
|
|
1384
|
+
descriptive,
|
|
1383
1385
|
result.observation,
|
|
1384
1386
|
result.view,
|
|
1387
|
+
tuple(g for g in result.records.formative if within(g.day)),
|
|
1385
1388
|
tuple(
|
|
1386
|
-
|
|
1387
|
-
for
|
|
1388
|
-
if
|
|
1389
|
+
group
|
|
1390
|
+
for group in result.records.corrections
|
|
1391
|
+
if not visible.isdisjoint(group.grade_ids)
|
|
1389
1392
|
),
|
|
1390
1393
|
)
|
|
1391
1394
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/_notification_bootstrap.py
RENAMED
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/_notification_codec.py
RENAMED
|
File without changes
|
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/_windows_filesystem.py
RENAMED
|
File without changes
|
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/attachment_routes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/attendance_frequency.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/class_free_days.py
RENAMED
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/completed_lessons.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/formative_grades.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/message_content.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/modern_messages.py
RENAMED
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/notification_models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.8.3 → librus_python_api-1.9.0}/src/librus_python_api/school_year_archive.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|