librus-python-api 1.10.1__tar.gz → 1.10.3__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.10.1 → librus_python_api-1.10.3}/API.md +8 -4
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/CHANGELOG.md +50 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/PKG-INFO +8 -4
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/README.md +7 -3
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/__init__.py +1 -1
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/completed_lessons.py +4 -1
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/config.py +13 -2
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/gateway_grades.py +22 -4
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/markup.py +6 -4
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/parsers.py +76 -4
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/service.py +8 -5
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/.gitignore +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/LICENSE +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/SECURITY.md +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/pyproject.toml +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/_notification_bootstrap.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/_notification_codec.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/_storage.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/_windows_filesystem.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/announcements.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/attachment_routes.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/attachments.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/attendance.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/attendance_frequency.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/budget.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/checkpoint.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/class_free_days.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/detail_fields.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/diagnostics.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/exceptions.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/files.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/formative_grades.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/grade_parsers.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/grade_records.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/homework_range.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/inspect_page.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/justifications.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/lifecycle.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/message_content.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/messages.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/models.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/modern_body.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/modern_mailbox.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/modern_messages.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/notification_models.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/notification_persistence.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/notification_workflow.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/notifications.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/parsing.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/persistence.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/py.typed +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/recipients.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/scheduler.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/school_reads.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/school_year_archive.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/sending.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/timetable.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/transport.py +0 -0
- {librus_python_api-1.10.1 → librus_python_api-1.10.3}/uv.lock +0 -0
|
@@ -102,7 +102,9 @@ one summary across four logins. Requests are counted at dispatch and never
|
|
|
102
102
|
refunded. Exhaustion raises `LimitError`; deadlines raise `OperationTimeoutError`.
|
|
103
103
|
|
|
104
104
|
- Fresh reads are the default. `max_age_seconds > 0` allows reuse from a
|
|
105
|
-
64-entry per-account result cache.
|
|
105
|
+
64-entry per-account result cache. Every read from Librus refreshes its
|
|
106
|
+
entry, and a full cache drops the entry refreshed longest ago. A new login
|
|
107
|
+
clears it.
|
|
106
108
|
- Identical in-flight reads on one account share one request. Calls with
|
|
107
109
|
explicit budgets share only when they pass the same budget object. Cancelling
|
|
108
110
|
one waiter leaves others running; cancelling the last waiter cancels and joins
|
|
@@ -332,7 +334,8 @@ rows, 256 achievements, 1024 characters per short field, 65536 per long text
|
|
|
332
334
|
cell and 262144 total rendered characters, plus the shared transport/tree bounds.
|
|
333
335
|
|
|
334
336
|
The observed `Brak danych` information notice returns empty `years` and
|
|
335
|
-
`achievements`.
|
|
337
|
+
`achievements`. The notice that the archive is temporarily unavailable while
|
|
338
|
+
Synergia fills it with the previous school year raises `MaintenanceError` (1.10.3). Missing tables without that explicit marker still raise `PARSE`;
|
|
336
339
|
an empty notice combined with data tables is rejected. Repeated school years
|
|
337
340
|
(including a class-change layout) are ambiguous and raise `PARSE`. Unknown
|
|
338
341
|
geometry/markup raises `UNSUPPORTED_CAPABILITY`; bounds raise `LIMIT`, never
|
|
@@ -383,7 +386,8 @@ the same way (from 1.8.4; before, only the `ALL` view did):
|
|
|
383
386
|
`Umiejętność` and the other tooltip lines in `metadata`, and no view makes a
|
|
384
387
|
gateway request. The detail rows must list the same grades, value and date,
|
|
385
388
|
in the same order; otherwise, or when a detail grade has `Treść oceny` text,
|
|
386
|
-
the read raises `UnsupportedCapabilityError`.
|
|
389
|
+
the read raises `UnsupportedCapabilityError`. A detail table with one
|
|
390
|
+
`Brak ocen` row and no period headings is a subject without grades (1.10.3).
|
|
387
391
|
- Anything else fails the read: blank cells without hooks, a cell with an
|
|
388
392
|
attribute or markup, mixed layouts in one table, a bare-text table that still
|
|
389
393
|
has empty `studentGradesDetailsRow` rows (`UnsupportedCapabilityError`), or rows
|
|
@@ -1291,7 +1295,7 @@ text. `error_for(kind)` builds one.
|
|
|
1291
1295
|
| `UnsupportedCapabilityError` | A recognized but unsupported layout or content |
|
|
1292
1296
|
| `ParseError` | The page or JSON does not match the expected structure |
|
|
1293
1297
|
| `StaleCursorError` | A previously valid continuation no longer matches the current sequence; restart explicitly |
|
|
1294
|
-
| `ThrottledError`, `MaintenanceError` | HTTP 429 or 503; the shared scheduler pauses |
|
|
1298
|
+
| `ThrottledError`, `MaintenanceError` | HTTP 429 or 503; the shared scheduler pauses. Since 1.10.3 `MaintenanceError` is also the archive's notice that it is being filled, with no pause |
|
|
1295
1299
|
| `ConnectionError`, `OperationTimeoutError` | Transport failure or budget deadline |
|
|
1296
1300
|
| `LimitError` | A request, byte, item or queue bound was reached |
|
|
1297
1301
|
| `ClosedError` | The service is closed |
|
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.10.3 (2026-11-20) - Pages read on Windows; grade details without periods
|
|
4
|
+
|
|
5
|
+
Thank you, @mpietson, for krzysztofbury/librus-mcp#121, with the libxml2 error
|
|
6
|
+
counts that located the failure, and @wiktorw, for #184 and its offline
|
|
7
|
+
reproduction.
|
|
8
|
+
|
|
9
|
+
- Windows: every page read failed with `PARSE`. lxml's Windows wheels bundle
|
|
10
|
+
libxml2 2.11.9, which reports repairs that libxml2 2.14 (in the Linux and
|
|
11
|
+
macOS wheels) makes silently, such as a repeated attribute, a stray quote in
|
|
12
|
+
a start tag, an unknown tag such as `nobr` or ` ` without its `;`. They
|
|
13
|
+
are now accepted, and a text reference without its `;` is decoded as 2.14
|
|
14
|
+
decodes it, so timetable teacher and room text no longer keeps a literal
|
|
15
|
+
` `. On four live logins, every `librus-mcp check-tools` result was the
|
|
16
|
+
same with both libxml2 versions. Only libxml2 older than 2.14 accepts these
|
|
17
|
+
repairs, so Linux and macOS behave as before. With 2.11, a duplicate ID, a
|
|
18
|
+
failed allocation, a message body that ends inside a start tag (`... <x`)
|
|
19
|
+
and a text with both a bare reference and an escaped one such as
|
|
20
|
+
`&para` still fail as `PARSE` (krzysztofbury/librus-mcp#121).
|
|
21
|
+
- Grades: a filled detail row whose table holds one `Brak ocen` row and no
|
|
22
|
+
period headings failed the whole read with `UnsupportedCapabilityError`. It
|
|
23
|
+
is now a subject with no grades in either period, when its semester cells
|
|
24
|
+
show no grades either; anything after that row still fails (#184).
|
|
25
|
+
- School-year archive: the notice that the archive is temporarily unavailable
|
|
26
|
+
while Synergia fills it with the previous school year's data (observed
|
|
27
|
+
2026-11-20 on every login) now raises `MaintenanceError` instead of
|
|
28
|
+
`ParseError`. Nothing pauses the shared scheduler.
|
|
29
|
+
- CI and release qualification run the full suite on Windows x64 and ARM64,
|
|
30
|
+
not only the disk tests. The loopback test servers also listen on ::1, which
|
|
31
|
+
Windows tries first for `localhost`. The maintainer capture scripts refuse
|
|
32
|
+
Windows, where their owner-only file modes protect nothing.
|
|
33
|
+
|
|
34
|
+
## 1.10.2 (2026-11-17) - Stricter dates and lesson cells; cache fixes
|
|
35
|
+
|
|
36
|
+
- Dates followed by a weekday label, such as `2026-11-15 (ndz.)` in grade and
|
|
37
|
+
point-grade tooltips, now fail as `PARSE` when the label names another day
|
|
38
|
+
of the week (`2026-11-15 (pon.)`), as homework dates already did. Both
|
|
39
|
+
Sunday labels, `ndz.` and `nd.`, are still accepted, and dates without a
|
|
40
|
+
label are unchanged (#178).
|
|
41
|
+
- Completed lessons: a subject/teacher cell with more than one comma (such as
|
|
42
|
+
`Biology, advanced, Teacher`) now fails the read as a parse error. It used to
|
|
43
|
+
keep the whole cell as the subject and drop the teacher (#177).
|
|
44
|
+
- Attendance frequency: a lesson or subject collection that fails to parse, is
|
|
45
|
+
denied or is too large is no longer cached as an empty map for an hour, which
|
|
46
|
+
made every later `subject_frequency` call look up each lesson on its own. The
|
|
47
|
+
next call reads the collection again; parsed collections keep their one-hour
|
|
48
|
+
lifetime (#176).
|
|
49
|
+
- The per-account result cache and the attendance metadata cache drop the
|
|
50
|
+
entry refreshed longest ago when full. They used to drop the entry stored
|
|
51
|
+
first, even if it had just been read again (#175).
|
|
52
|
+
|
|
3
53
|
## 1.10.1 (2026-11-15) - Descriptive grades shown as grade boxes
|
|
4
54
|
|
|
5
55
|
Thank you, @sanyok-ua, for the sanitized pages on #76 that showed this layout (#173).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: librus-python-api
|
|
3
|
-
Version: 1.10.
|
|
3
|
+
Version: 1.10.3
|
|
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,11 @@ private ACLs. Windows installations include `pywin32` and `tzdata` automatically
|
|
|
42
42
|
Network paths, reparse-point paths and unsafe storage permissions fail closed.
|
|
43
43
|
See [platform requirements](contracts/persistence.md#windows-disk-boundary-25).
|
|
44
44
|
|
|
45
|
-
**Status:** `1.10.
|
|
45
|
+
**Status:** `1.10.3` reads pages with the libxml2 that lxml's Windows wheels
|
|
46
|
+
bundle, reads a grade detail table without period headings and types the
|
|
47
|
+
archive's loading notice as maintenance. `1.10.2` rejects a date whose weekday
|
|
48
|
+
label names another day and a completed-lesson cell with more than one comma,
|
|
49
|
+
and fixes two cache bugs. `1.10.1` reads descriptive grades that the new-schema table
|
|
46
50
|
shows as grade boxes. `1.10.0` returns behaviour points as a typed value
|
|
47
51
|
(`GradeRecords.behaviour_points`), reads the e-Justifications list on parent
|
|
48
52
|
logins (`AccountClient.justifications()`) and checks the gateway grade
|
|
@@ -77,7 +81,7 @@ See [limitations](#supported-features-and-limitations) below.
|
|
|
77
81
|
Install the exact release from PyPI after its gated publication completes:
|
|
78
82
|
|
|
79
83
|
```sh
|
|
80
|
-
python -m pip install librus-python-api==1.10.
|
|
84
|
+
python -m pip install librus-python-api==1.10.3
|
|
81
85
|
```
|
|
82
86
|
|
|
83
87
|
Pin the exact version qualified by your application. Before publication, use a
|
|
@@ -93,7 +97,7 @@ python -m pip install .
|
|
|
93
97
|
To install a locally built wheel instead:
|
|
94
98
|
|
|
95
99
|
```sh
|
|
96
|
-
python -m pip install ./dist/librus_python_api-1.10.
|
|
100
|
+
python -m pip install ./dist/librus_python_api-1.10.3-py3-none-any.whl
|
|
97
101
|
```
|
|
98
102
|
|
|
99
103
|
No console script or background process is installed: import the library in your
|
|
@@ -16,7 +16,11 @@ 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.10.
|
|
19
|
+
**Status:** `1.10.3` reads pages with the libxml2 that lxml's Windows wheels
|
|
20
|
+
bundle, reads a grade detail table without period headings and types the
|
|
21
|
+
archive's loading notice as maintenance. `1.10.2` rejects a date whose weekday
|
|
22
|
+
label names another day and a completed-lesson cell with more than one comma,
|
|
23
|
+
and fixes two cache bugs. `1.10.1` reads descriptive grades that the new-schema table
|
|
20
24
|
shows as grade boxes. `1.10.0` returns behaviour points as a typed value
|
|
21
25
|
(`GradeRecords.behaviour_points`), reads the e-Justifications list on parent
|
|
22
26
|
logins (`AccountClient.justifications()`) and checks the gateway grade
|
|
@@ -51,7 +55,7 @@ See [limitations](#supported-features-and-limitations) below.
|
|
|
51
55
|
Install the exact release from PyPI after its gated publication completes:
|
|
52
56
|
|
|
53
57
|
```sh
|
|
54
|
-
python -m pip install librus-python-api==1.10.
|
|
58
|
+
python -m pip install librus-python-api==1.10.3
|
|
55
59
|
```
|
|
56
60
|
|
|
57
61
|
Pin the exact version qualified by your application. Before publication, use a
|
|
@@ -67,7 +71,7 @@ python -m pip install .
|
|
|
67
71
|
To install a locally built wheel instead:
|
|
68
72
|
|
|
69
73
|
```sh
|
|
70
|
-
python -m pip install ./dist/librus_python_api-1.10.
|
|
74
|
+
python -m pip install ./dist/librus_python_api-1.10.3-py3-none-any.whl
|
|
71
75
|
```
|
|
72
76
|
|
|
73
77
|
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.10.
|
|
4
|
+
__version__ = "1.10.3"
|
|
5
5
|
|
|
6
6
|
from librus_python_api.attachments import AttachmentStream, ModernAttachmentStream
|
|
7
7
|
from librus_python_api.budget import RequestBudget
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/completed_lessons.py
RENAMED
|
@@ -203,8 +203,11 @@ def _lesson(
|
|
|
203
203
|
raw_number, combined, topic, z_value, symbol = values
|
|
204
204
|
if raw_number not in {"", "-"} and re.fullmatch(r"[0-9]{1,2}", raw_number) is None:
|
|
205
205
|
raise LibrusError(ErrorKind.PARSE)
|
|
206
|
-
# Some schools render "<b>Subject</b>, <br>Teacher" or pad the comma.
|
|
206
|
+
# Some schools render "<b>Subject</b>, <br>Teacher" or pad the comma. More
|
|
207
|
+
# than one comma leaves the subject/teacher boundary ambiguous, so fail.
|
|
207
208
|
names = [name.strip() for name in combined.split(",")]
|
|
209
|
+
if len(names) > 2:
|
|
210
|
+
raise LibrusError(ErrorKind.PARSE)
|
|
208
211
|
subject, teacher = (names[0], names[1]) if len(names) == 2 else (combined, None)
|
|
209
212
|
if not subject or teacher == "":
|
|
210
213
|
raise LibrusError(ErrorKind.PARSE)
|
|
@@ -1052,8 +1052,12 @@ HOMEWORK_MARK_DONE_HANDLER = (
|
|
|
1052
1052
|
r"\s*showConfirmQuestion\(\s*[0-9]{1,64}\s*,\s*[0-9]{1,64}\s*\);?\s*"
|
|
1053
1053
|
)
|
|
1054
1054
|
WEEKDAY_LABELS = ("pon.", "wt.", "śr.", "czw.", "pt.", "sob.", "ndz.")
|
|
1055
|
-
#
|
|
1056
|
-
|
|
1055
|
+
# Accepted labels per weekday (Monday first) after a civil date. Grade
|
|
1056
|
+
# tooltips also use the short Sunday display label.
|
|
1057
|
+
CIVIL_DATE_WEEKDAY_LABELS: tuple[tuple[str, ...], ...] = (
|
|
1058
|
+
*((label,) for label in WEEKDAY_LABELS[:-1]),
|
|
1059
|
+
(WEEKDAY_LABELS[-1], "nd."),
|
|
1060
|
+
)
|
|
1057
1061
|
# Observed page-level notices shown instead of the requested content.
|
|
1058
1062
|
PAGE_NOTICES = MappingProxyType(
|
|
1059
1063
|
{
|
|
@@ -1065,6 +1069,13 @@ PAGE_NOTICES = MappingProxyType(
|
|
|
1065
1069
|
ErrorKind.VIEW_DISABLED
|
|
1066
1070
|
),
|
|
1067
1071
|
"Wybrano nieprawidłowy zakres daty.": ErrorKind.INVALID_INPUT,
|
|
1072
|
+
# Observed on the school-year archive (2026-11-20) while Synergia fills
|
|
1073
|
+
# it with the previous year; the page has no archive tables until then.
|
|
1074
|
+
(
|
|
1075
|
+
"Opcja chwilowo niedostępna. Aktualnie trwa proces zasilania archiwum "
|
|
1076
|
+
"danymi z poprzedniego roku szkolnego. Po zakończeniu procesu "
|
|
1077
|
+
"zasilania opcja zostanie ponownie udostępniona."
|
|
1078
|
+
): ErrorKind.MAINTENANCE,
|
|
1068
1079
|
}
|
|
1069
1080
|
)
|
|
1070
1081
|
MODULE_UNAVAILABLE_PATH = "/modul_niedostepny"
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/gateway_grades.py
RENAMED
|
@@ -356,8 +356,10 @@ def _detail_grades(cell: html.HtmlElement) -> dict[int, _Grades]:
|
|
|
356
356
|
|
|
357
357
|
The cell holds one table: `DESCRIPTIVE_DETAIL_COLUMNS` as its header, then
|
|
358
358
|
per period a heading row and either grade rows or one empty-marker row,
|
|
359
|
-
and an empty footer. A
|
|
360
|
-
|
|
359
|
+
and an empty footer. A subject without grades in either period may
|
|
360
|
+
instead have one empty-marker row and no period headings (#184). A grade
|
|
361
|
+
row with `Treść oceny` text fails: the grade boxes carry no such field, so
|
|
362
|
+
the text would be lost.
|
|
361
363
|
"""
|
|
362
364
|
unsupported = LibrusError(ErrorKind.UNSUPPORTED_CAPABILITY)
|
|
363
365
|
tables = [node for node in cell if isinstance(node.tag, str)]
|
|
@@ -371,6 +373,7 @@ def _detail_grades(cell: html.HtmlElement) -> dict[int, _Grades]:
|
|
|
371
373
|
result: dict[int, _Grades] = {}
|
|
372
374
|
empty: set[int] = set()
|
|
373
375
|
header = False
|
|
376
|
+
unscoped = False
|
|
374
377
|
period: int | None = None
|
|
375
378
|
for row in markup.rows(tables[0]):
|
|
376
379
|
cells = markup.cells(row)
|
|
@@ -382,12 +385,23 @@ def _detail_grades(cell: html.HtmlElement) -> dict[int, _Grades]:
|
|
|
382
385
|
elif next(row.iterancestors("tfoot"), None) is not None:
|
|
383
386
|
if any(texts) or any(len(item) for item in cells):
|
|
384
387
|
raise unsupported
|
|
388
|
+
elif unscoped:
|
|
389
|
+
# Nothing may follow the marker that stands for both periods.
|
|
390
|
+
raise unsupported
|
|
385
391
|
elif len(cells) == 1 and texts[0] in DESCRIPTIVE_PERIOD_LABELS:
|
|
386
392
|
period = DESCRIPTIVE_PERIOD_LABELS[texts[0]]
|
|
387
393
|
if period in result or len(cells[0]):
|
|
388
394
|
raise unsupported
|
|
389
395
|
result[period] = []
|
|
390
|
-
elif period is None
|
|
396
|
+
elif period is None:
|
|
397
|
+
if (
|
|
398
|
+
len(cells) != 1
|
|
399
|
+
or texts[0] not in GRADE_EMPTY_MARKERS - {""}
|
|
400
|
+
or len(cells[0])
|
|
401
|
+
):
|
|
402
|
+
raise unsupported
|
|
403
|
+
unscoped = True
|
|
404
|
+
elif period in empty:
|
|
391
405
|
raise unsupported
|
|
392
406
|
elif len(cells) == 1:
|
|
393
407
|
if result[period] or texts[0] not in GRADE_EMPTY_MARKERS - {""}:
|
|
@@ -405,7 +419,11 @@ def _detail_grades(cell: html.HtmlElement) -> dict[int, _Grades]:
|
|
|
405
419
|
result[period].append((texts[0], markup.civil_date(day)))
|
|
406
420
|
else:
|
|
407
421
|
raise unsupported
|
|
408
|
-
if not header
|
|
422
|
+
if not header:
|
|
423
|
+
raise unsupported
|
|
424
|
+
if unscoped:
|
|
425
|
+
return {1: [], 2: []}
|
|
426
|
+
if sorted(result) != [1, 2]:
|
|
409
427
|
raise unsupported
|
|
410
428
|
if any(not result[key] and key not in empty for key in result):
|
|
411
429
|
raise unsupported
|
|
@@ -164,14 +164,16 @@ def tooltip_line(chunk: str) -> str:
|
|
|
164
164
|
def civil_date(value: str | None) -> date:
|
|
165
165
|
"""An ISO date, optionally followed by its weekday label in parentheses."""
|
|
166
166
|
match = re.fullmatch(r"([0-9]{4}-[0-9]{2}-[0-9]{2})(?: \(([^()]+)\))?", value or "")
|
|
167
|
-
if match is None
|
|
168
|
-
match[2] is not None and match[2] not in CIVIL_DATE_WEEKDAY_LABELS
|
|
169
|
-
):
|
|
167
|
+
if match is None:
|
|
170
168
|
raise LibrusError(ErrorKind.PARSE)
|
|
171
169
|
try:
|
|
172
|
-
|
|
170
|
+
day = date.fromisoformat(match[1])
|
|
173
171
|
except ValueError:
|
|
174
172
|
pass
|
|
173
|
+
else:
|
|
174
|
+
# A label must name the date's own weekday, as for homework dates.
|
|
175
|
+
if match[2] is None or match[2] in CIVIL_DATE_WEEKDAY_LABELS[day.weekday()]:
|
|
176
|
+
return day
|
|
175
177
|
raise LibrusError(ErrorKind.PARSE)
|
|
176
178
|
|
|
177
179
|
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import json
|
|
4
4
|
import math
|
|
5
5
|
import re
|
|
6
|
+
from html import unescape
|
|
7
|
+
from html.entities import html5
|
|
6
8
|
from typing import Any
|
|
7
9
|
|
|
8
10
|
from lxml import etree, html
|
|
@@ -131,6 +133,67 @@ def parse_login(body: bytes) -> str:
|
|
|
131
133
|
return location
|
|
132
134
|
|
|
133
135
|
|
|
136
|
+
# Browser HTML commonly contains stray closing tags; every libxml2 reports them.
|
|
137
|
+
HTML_RECOVERIES = frozenset({"ERR_TAG_NAME_MISMATCH"})
|
|
138
|
+
# libxml2 2.14 parses HTML as HTML5 does and reports none of these; the 2.11.9
|
|
139
|
+
# that lxml's Windows wheels bundle (#121) reports each one where a browser
|
|
140
|
+
# repairs the markup. Accepted only below 2.14, so newer libxml2 is unchanged.
|
|
141
|
+
# Seen on live pages: the first four. In the suite's fixtures and message
|
|
142
|
+
# bodies under 2.11: the rest. A misplaced html, head or body tag, which 2.14
|
|
143
|
+
# rejects too, is accepted only there.
|
|
144
|
+
HTML_RECOVERIES_BEFORE_2_14 = HTML_RECOVERIES | frozenset(
|
|
145
|
+
{
|
|
146
|
+
"ERR_ATTRIBUTE_REDEFINED", # a repeated attribute; the first one is kept
|
|
147
|
+
"ERR_NAME_REQUIRED", # a stray character where a name belongs
|
|
148
|
+
"ERR_ENTITYREF_SEMICOL_MISSING", # " " without its ";"
|
|
149
|
+
"HTML_UNKNOWN_TAG", # an element HTML 4 does not list, such as nobr
|
|
150
|
+
"ERR_INVALID_CHAR", # a control character, dropped; 2.14 keeps it
|
|
151
|
+
"ERR_SPACE_REQUIRED", # "<?" without an XML processing instruction
|
|
152
|
+
"ERR_GT_REQUIRED", # a start tag the document ends inside
|
|
153
|
+
"ERR_COMMENT_ABRUPTLY_ENDED", # "<!-->"
|
|
154
|
+
"HTML_INCORRECTLY_OPENED_COMMENT", # "<!" that starts no comment
|
|
155
|
+
"HTML_STRUCURE_ERROR", # a misplaced DOCTYPE, html, head or body tag
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
_LEGACY_REFERENCES = frozenset(name for name in html5 if not name.endswith(";"))
|
|
159
|
+
# A named reference without its ";", which libxml2 2.11 keeps as text.
|
|
160
|
+
_BARE_REFERENCE = re.compile(r"&[A-Za-z][A-Za-z0-9]*+(?!;)")
|
|
161
|
+
# An escaped "&" before a name; parsed, it looks like a bare reference.
|
|
162
|
+
_ESCAPED_REFERENCE = re.compile(
|
|
163
|
+
r"&(?:amp;|#0*38;|#[xX]0*26;)([A-Za-z][A-Za-z0-9]*+)(?!;)"
|
|
164
|
+
)
|
|
165
|
+
_RAW_TEXT_ELEMENTS = frozenset({"script", "style"})
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _legacy(name: str) -> bool:
|
|
169
|
+
"""Whether HTML5 decodes "&" + name without ";": a legacy name prefixes it."""
|
|
170
|
+
return any(name[:end] in _LEGACY_REFERENCES for end in range(len(name), 1, -1))
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def _decode_bare_references(source: str, document: html.HtmlElement) -> None:
|
|
174
|
+
"""Decode text the way libxml2 2.14 and browsers do, where 2.11 did not.
|
|
175
|
+
|
|
176
|
+
Synergia templates write " " without ";" (#121: every timetable entry).
|
|
177
|
+
HTML5 decodes such a reference in text when a legacy name starts it, as
|
|
178
|
+
`html.unescape` does; libxml2 2.11 leaves it as text. Once parsed, an
|
|
179
|
+
escaped "&para" looks the same as a bare "¶", so a document with
|
|
180
|
+
both fails instead of guessing; no live Synergia page had one. Only text
|
|
181
|
+
and tails change: the observed attribute values parse alike.
|
|
182
|
+
"""
|
|
183
|
+
if any(_legacy(match.group(1)) for match in _ESCAPED_REFERENCE.finditer(source)):
|
|
184
|
+
raise LibrusError(ErrorKind.PARSE)
|
|
185
|
+
|
|
186
|
+
def decode(value: str | None) -> str | None:
|
|
187
|
+
if not value or "&" not in value:
|
|
188
|
+
return value
|
|
189
|
+
return _BARE_REFERENCE.sub(lambda match: unescape(match.group()), value)
|
|
190
|
+
|
|
191
|
+
for node in document.iter():
|
|
192
|
+
if isinstance(node.tag, str) and node.tag not in _RAW_TEXT_ELEMENTS:
|
|
193
|
+
node.text = decode(node.text)
|
|
194
|
+
node.tail = decode(node.tail)
|
|
195
|
+
|
|
196
|
+
|
|
134
197
|
def parse_html_document(
|
|
135
198
|
body: bytes, *, repeatable_id: str | None = None
|
|
136
199
|
) -> html.HtmlElement:
|
|
@@ -145,11 +208,16 @@ def parse_html_document(
|
|
|
145
208
|
)
|
|
146
209
|
except (UnicodeError, etree.LxmlError, ValueError):
|
|
147
210
|
failed = True
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
211
|
+
# Accept only the repairs a browser makes too; semantic tables, spans, IDs
|
|
212
|
+
# and bounds still validate independently. Do not blanket-ignore arbitrary
|
|
213
|
+
# parser errors, such as an exhausted allocation.
|
|
214
|
+
recoveries = (
|
|
215
|
+
HTML_RECOVERIES
|
|
216
|
+
if etree.LIBXML_VERSION >= (2, 14)
|
|
217
|
+
else HTML_RECOVERIES_BEFORE_2_14
|
|
218
|
+
)
|
|
151
219
|
if failed or any(
|
|
152
|
-
error.type_name
|
|
220
|
+
error.type_name not in recoveries
|
|
153
221
|
and not (
|
|
154
222
|
repeatable_id is not None
|
|
155
223
|
and error.type_name == "DTD_ID_REDEFINED"
|
|
@@ -159,6 +227,10 @@ def parse_html_document(
|
|
|
159
227
|
):
|
|
160
228
|
raise LibrusError(ErrorKind.PARSE)
|
|
161
229
|
assert document is not None
|
|
230
|
+
if etree.LIBXML_VERSION < (2, 14) and any(
|
|
231
|
+
error.type_name == "ERR_ENTITYREF_SEMICOL_MISSING" for error in parser.error_log
|
|
232
|
+
):
|
|
233
|
+
_decode_bare_references(text, document)
|
|
162
234
|
count = 0
|
|
163
235
|
pending = [(document, 0)]
|
|
164
236
|
while pending:
|
|
@@ -2201,6 +2201,9 @@ class AccountClient:
|
|
|
2201
2201
|
error.kind,
|
|
2202
2202
|
)
|
|
2203
2203
|
raise
|
|
2204
|
+
# Reinsert so iteration order follows refresh time: eviction then drops
|
|
2205
|
+
# the least recently refreshed entry, not the one just read again.
|
|
2206
|
+
self._cache.pop(key, None)
|
|
2204
2207
|
self._cache[key] = (time.monotonic(), result)
|
|
2205
2208
|
if len(self._cache) > ACCOUNT_RESULT_CACHE_SIZE:
|
|
2206
2209
|
del self._cache[next(iter(self._cache))]
|
|
@@ -2589,6 +2592,7 @@ class AccountClient:
|
|
|
2589
2592
|
reference=identifier,
|
|
2590
2593
|
content_type=JSON,
|
|
2591
2594
|
)
|
|
2595
|
+
self._metadata.pop(key, None) # refresh order, as in _cached
|
|
2592
2596
|
self._metadata[key] = time.monotonic(), value
|
|
2593
2597
|
if len(self._metadata) > ATTENDANCE_METADATA_CACHE_SIZE:
|
|
2594
2598
|
del self._metadata[next(iter(self._metadata))]
|
|
@@ -2612,15 +2616,14 @@ class AccountClient:
|
|
|
2612
2616
|
)
|
|
2613
2617
|
except LibrusError as error:
|
|
2614
2618
|
# An unavailable or unexpected collection degrades to the original
|
|
2615
|
-
# per-reference lookups
|
|
2616
|
-
#
|
|
2619
|
+
# per-reference lookups for this call only; the next call reads the
|
|
2620
|
+
# collection again. Deadlines, budgets, cancellation and session
|
|
2621
|
+
# failures still propagate. Only parsed maps are cached.
|
|
2617
2622
|
if error.kind not in _METADATA_MAP_FALLBACK:
|
|
2618
2623
|
raise
|
|
2619
2624
|
if error.kind is ErrorKind.LIMIT:
|
|
2620
2625
|
budget.check() # An exhausted caller budget is not a large collection.
|
|
2621
|
-
|
|
2622
|
-
return MappingProxyType({})
|
|
2623
|
-
value = MappingProxyType({})
|
|
2626
|
+
return MappingProxyType({})
|
|
2624
2627
|
self._metadata_maps[endpoint] = time.monotonic(), value
|
|
2625
2628
|
return value
|
|
2626
2629
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/_notification_codec.py
RENAMED
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/_windows_filesystem.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/announcements.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/attachment_routes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/attendance_frequency.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/class_free_days.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/detail_fields.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/formative_grades.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/grade_parsers.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/grade_records.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/homework_range.py
RENAMED
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/justifications.py
RENAMED
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/message_content.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/modern_mailbox.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/modern_messages.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/notification_models.py
RENAMED
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/notification_workflow.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.1 → librus_python_api-1.10.3}/src/librus_python_api/notifications.py
RENAMED
|
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.10.1 → librus_python_api-1.10.3}/src/librus_python_api/school_year_archive.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|