librus-python-api 1.10.2__tar.gz → 1.11.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.10.2 → librus_python_api-1.11.0}/API.md +7 -3
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/CHANGELOG.md +47 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/PKG-INFO +9 -6
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/README.md +8 -5
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/__init__.py +1 -1
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/config.py +7 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/exceptions.py +10 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/gateway_grades.py +22 -4
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/parsers.py +76 -4
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/.gitignore +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/LICENSE +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/SECURITY.md +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/pyproject.toml +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/_notification_bootstrap.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/_notification_codec.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/_storage.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/_windows_filesystem.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/announcements.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/attachment_routes.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/attachments.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/attendance.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/attendance_frequency.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/budget.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/checkpoint.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/class_free_days.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/completed_lessons.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/detail_fields.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/diagnostics.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/files.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/formative_grades.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/grade_parsers.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/grade_records.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/homework_range.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/inspect_page.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/justifications.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/lifecycle.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/markup.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/message_content.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/messages.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/models.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/modern_body.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/modern_mailbox.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/modern_messages.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/notification_models.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/notification_persistence.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/notification_workflow.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/notifications.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/parsing.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/persistence.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/py.typed +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/recipients.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/scheduler.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/school_reads.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/school_year_archive.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/sending.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/service.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/timetable.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/transport.py +0 -0
- {librus_python_api-1.10.2 → librus_python_api-1.11.0}/uv.lock +0 -0
|
@@ -334,7 +334,9 @@ rows, 256 achievements, 1024 characters per short field, 65536 per long text
|
|
|
334
334
|
cell and 262144 total rendered characters, plus the shared transport/tree bounds.
|
|
335
335
|
|
|
336
336
|
The observed `Brak danych` information notice returns empty `years` and
|
|
337
|
-
`achievements`.
|
|
337
|
+
`achievements`. The notice that the archive is temporarily unavailable while
|
|
338
|
+
Synergia fills it with the previous school year raises `TemporarilyUnavailableError`
|
|
339
|
+
(1.11.0; `MaintenanceError` in 1.10.3). Missing tables without that explicit marker still raise `PARSE`;
|
|
338
340
|
an empty notice combined with data tables is rejected. Repeated school years
|
|
339
341
|
(including a class-change layout) are ambiguous and raise `PARSE`. Unknown
|
|
340
342
|
geometry/markup raises `UNSUPPORTED_CAPABILITY`; bounds raise `LIMIT`, never
|
|
@@ -385,7 +387,8 @@ the same way (from 1.8.4; before, only the `ALL` view did):
|
|
|
385
387
|
`Umiejętność` and the other tooltip lines in `metadata`, and no view makes a
|
|
386
388
|
gateway request. The detail rows must list the same grades, value and date,
|
|
387
389
|
in the same order; otherwise, or when a detail grade has `Treść oceny` text,
|
|
388
|
-
the read raises `UnsupportedCapabilityError`.
|
|
390
|
+
the read raises `UnsupportedCapabilityError`. A detail table with one
|
|
391
|
+
`Brak ocen` row and no period headings is a subject without grades (1.10.3).
|
|
389
392
|
- Anything else fails the read: blank cells without hooks, a cell with an
|
|
390
393
|
attribute or markup, mixed layouts in one table, a bare-text table that still
|
|
391
394
|
has empty `studentGradesDetailsRow` rows (`UnsupportedCapabilityError`), or rows
|
|
@@ -1290,10 +1293,11 @@ text. `error_for(kind)` builds one.
|
|
|
1290
1293
|
| `AccessDeniedError` | Denied, or an unexpected redirect or identity |
|
|
1291
1294
|
| `ViewDisabledError` | The school administrator disabled this view |
|
|
1292
1295
|
| `ModuleUnavailableError` | The school's Synergia variant does not include this module; exact same-origin unavailable redirect or fixed page notice, without follow/retry ([contract](contracts/module-unavailable.md)) |
|
|
1296
|
+
| `TemporarilyUnavailableError` | Synergia shows a fixed notice that this view is unavailable for now, such as the school-year archive while it is filled with the previous year (1.11.0); other views still work, nothing pauses, retry later |
|
|
1293
1297
|
| `UnsupportedCapabilityError` | A recognized but unsupported layout or content |
|
|
1294
1298
|
| `ParseError` | The page or JSON does not match the expected structure |
|
|
1295
1299
|
| `StaleCursorError` | A previously valid continuation no longer matches the current sequence; restart explicitly |
|
|
1296
|
-
| `ThrottledError`, `MaintenanceError` | HTTP 429 or 503; the shared scheduler pauses |
|
|
1300
|
+
| `ThrottledError`, `MaintenanceError` | HTTP 429 or 503; the shared scheduler pauses. In 1.10.3 only, `MaintenanceError` was also the archive's loading notice, now `TemporarilyUnavailableError` |
|
|
1297
1301
|
| `ConnectionError`, `OperationTimeoutError` | Transport failure or budget deadline |
|
|
1298
1302
|
| `LimitError` | A request, byte, item or queue bound was reached |
|
|
1299
1303
|
| `ClosedError` | The service is closed |
|
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.11.0 (2026-11-21) - A view unavailable for now has its own error
|
|
4
|
+
|
|
5
|
+
- New `ErrorKind.TEMPORARILY_UNAVAILABLE` and `TemporarilyUnavailableError`:
|
|
6
|
+
Synergia shows a fixed notice that this one view is unavailable for now,
|
|
7
|
+
while other views still work. Retry later; nothing pauses the shared
|
|
8
|
+
scheduler. The school-year archive's notice that it is being filled with
|
|
9
|
+
the previous school year's data raises it. In 1.10.3 that notice raised
|
|
10
|
+
`MaintenanceError`, which otherwise means HTTP 503 with the whole service
|
|
11
|
+
paused, so consumers and both live checkers took the archive notice for an
|
|
12
|
+
outage. Code that caught `MaintenanceError` for the archive should catch
|
|
13
|
+
`TemporarilyUnavailableError` instead. A consumer that publishes
|
|
14
|
+
`ErrorKind` in a schema, such as `SendResult.reason`, gains the value
|
|
15
|
+
`temporarily_unavailable`.
|
|
16
|
+
- Live check: a temporarily unavailable view no longer ends the login's run;
|
|
17
|
+
the step is still reported as a problem because the view was not read.
|
|
18
|
+
|
|
19
|
+
## 1.10.3 (2026-11-20) - Pages read on Windows; grade details without periods
|
|
20
|
+
|
|
21
|
+
Thank you, @mpietson, for krzysztofbury/librus-mcp#121, with the libxml2 error
|
|
22
|
+
counts that located the failure, and @wiktorw, for #184 and its offline
|
|
23
|
+
reproduction.
|
|
24
|
+
|
|
25
|
+
- Windows: every page read failed with `PARSE`. lxml's Windows wheels bundle
|
|
26
|
+
libxml2 2.11.9, which reports repairs that libxml2 2.14 (in the Linux and
|
|
27
|
+
macOS wheels) makes silently, such as a repeated attribute, a stray quote in
|
|
28
|
+
a start tag, an unknown tag such as `nobr` or ` ` without its `;`. They
|
|
29
|
+
are now accepted, and a text reference without its `;` is decoded as 2.14
|
|
30
|
+
decodes it, so timetable teacher and room text no longer keeps a literal
|
|
31
|
+
` `. On four live logins, every `librus-mcp check-tools` result was the
|
|
32
|
+
same with both libxml2 versions. Only libxml2 older than 2.14 accepts these
|
|
33
|
+
repairs, so Linux and macOS behave as before. With 2.11, a duplicate ID, a
|
|
34
|
+
failed allocation, a message body that ends inside a start tag (`... <x`)
|
|
35
|
+
and a text with both a bare reference and an escaped one such as
|
|
36
|
+
`&para` still fail as `PARSE` (krzysztofbury/librus-mcp#121).
|
|
37
|
+
- Grades: a filled detail row whose table holds one `Brak ocen` row and no
|
|
38
|
+
period headings failed the whole read with `UnsupportedCapabilityError`. It
|
|
39
|
+
is now a subject with no grades in either period, when its semester cells
|
|
40
|
+
show no grades either; anything after that row still fails (#184).
|
|
41
|
+
- School-year archive: the notice that the archive is temporarily unavailable
|
|
42
|
+
while Synergia fills it with the previous school year's data (observed
|
|
43
|
+
2026-11-20 on every login) now raises `MaintenanceError` instead of
|
|
44
|
+
`ParseError`. Nothing pauses the shared scheduler.
|
|
45
|
+
- CI and release qualification run the full suite on Windows x64 and ARM64,
|
|
46
|
+
not only the disk tests. The loopback test servers also listen on ::1, which
|
|
47
|
+
Windows tries first for `localhost`. The maintainer capture scripts refuse
|
|
48
|
+
Windows, where their owner-only file modes protect nothing.
|
|
49
|
+
|
|
3
50
|
## 1.10.2 (2026-11-17) - Stricter dates and lesson cells; cache fixes
|
|
4
51
|
|
|
5
52
|
- Dates followed by a weekday label, such as `2026-11-15 (ndz.)` in grade and
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: librus-python-api
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.11.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,9 +42,12 @@ 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.
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
**Status:** `1.11.0` raises `TemporarilyUnavailableError` for the archive's
|
|
46
|
+
loading notice, a view that is unavailable for now while the rest of Synergia
|
|
47
|
+
works. `1.10.3` reads pages with the libxml2 that lxml's Windows wheels
|
|
48
|
+
bundle and reads a grade detail table without period headings. `1.10.2` rejects a date whose weekday
|
|
49
|
+
label names another day and a completed-lesson cell with more than one comma,
|
|
50
|
+
and fixes two cache bugs. `1.10.1` reads descriptive grades that the new-schema table
|
|
48
51
|
shows as grade boxes. `1.10.0` returns behaviour points as a typed value
|
|
49
52
|
(`GradeRecords.behaviour_points`), reads the e-Justifications list on parent
|
|
50
53
|
logins (`AccountClient.justifications()`) and checks the gateway grade
|
|
@@ -79,7 +82,7 @@ See [limitations](#supported-features-and-limitations) below.
|
|
|
79
82
|
Install the exact release from PyPI after its gated publication completes:
|
|
80
83
|
|
|
81
84
|
```sh
|
|
82
|
-
python -m pip install librus-python-api==1.
|
|
85
|
+
python -m pip install librus-python-api==1.11.0
|
|
83
86
|
```
|
|
84
87
|
|
|
85
88
|
Pin the exact version qualified by your application. Before publication, use a
|
|
@@ -95,7 +98,7 @@ python -m pip install .
|
|
|
95
98
|
To install a locally built wheel instead:
|
|
96
99
|
|
|
97
100
|
```sh
|
|
98
|
-
python -m pip install ./dist/librus_python_api-1.
|
|
101
|
+
python -m pip install ./dist/librus_python_api-1.11.0-py3-none-any.whl
|
|
99
102
|
```
|
|
100
103
|
|
|
101
104
|
No console script or background process is installed: import the library in your
|
|
@@ -16,9 +16,12 @@ 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.
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
**Status:** `1.11.0` raises `TemporarilyUnavailableError` for the archive's
|
|
20
|
+
loading notice, a view that is unavailable for now while the rest of Synergia
|
|
21
|
+
works. `1.10.3` reads pages with the libxml2 that lxml's Windows wheels
|
|
22
|
+
bundle and reads a grade detail table without period headings. `1.10.2` rejects a date whose weekday
|
|
23
|
+
label names another day and a completed-lesson cell with more than one comma,
|
|
24
|
+
and fixes two cache bugs. `1.10.1` reads descriptive grades that the new-schema table
|
|
22
25
|
shows as grade boxes. `1.10.0` returns behaviour points as a typed value
|
|
23
26
|
(`GradeRecords.behaviour_points`), reads the e-Justifications list on parent
|
|
24
27
|
logins (`AccountClient.justifications()`) and checks the gateway grade
|
|
@@ -53,7 +56,7 @@ See [limitations](#supported-features-and-limitations) below.
|
|
|
53
56
|
Install the exact release from PyPI after its gated publication completes:
|
|
54
57
|
|
|
55
58
|
```sh
|
|
56
|
-
python -m pip install librus-python-api==1.
|
|
59
|
+
python -m pip install librus-python-api==1.11.0
|
|
57
60
|
```
|
|
58
61
|
|
|
59
62
|
Pin the exact version qualified by your application. Before publication, use a
|
|
@@ -69,7 +72,7 @@ python -m pip install .
|
|
|
69
72
|
To install a locally built wheel instead:
|
|
70
73
|
|
|
71
74
|
```sh
|
|
72
|
-
python -m pip install ./dist/librus_python_api-1.
|
|
75
|
+
python -m pip install ./dist/librus_python_api-1.11.0-py3-none-any.whl
|
|
73
76
|
```
|
|
74
77
|
|
|
75
78
|
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.11.0"
|
|
5
5
|
|
|
6
6
|
from librus_python_api.attachments import AttachmentStream, ModernAttachmentStream
|
|
7
7
|
from librus_python_api.budget import RequestBudget
|
|
@@ -1069,6 +1069,13 @@ PAGE_NOTICES = MappingProxyType(
|
|
|
1069
1069
|
ErrorKind.VIEW_DISABLED
|
|
1070
1070
|
),
|
|
1071
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.TEMPORARILY_UNAVAILABLE,
|
|
1072
1079
|
}
|
|
1073
1080
|
)
|
|
1074
1081
|
MODULE_UNAVAILABLE_PATH = "/modul_niedostepny"
|
|
@@ -21,6 +21,7 @@ __all__ = [
|
|
|
21
21
|
"SessionExpiredError",
|
|
22
22
|
"StorageError",
|
|
23
23
|
"StaleCursorError",
|
|
24
|
+
"TemporarilyUnavailableError",
|
|
24
25
|
"ThrottledError",
|
|
25
26
|
"UnknownDeliveryError",
|
|
26
27
|
"UnsupportedCapabilityError",
|
|
@@ -40,6 +41,7 @@ class ErrorKind(StrEnum):
|
|
|
40
41
|
UNSUPPORTED_CAPABILITY = "unsupported_capability"
|
|
41
42
|
VIEW_DISABLED = "view_disabled"
|
|
42
43
|
MODULE_UNAVAILABLE = "module_unavailable"
|
|
44
|
+
TEMPORARILY_UNAVAILABLE = "temporarily_unavailable"
|
|
43
45
|
THROTTLED = "throttled"
|
|
44
46
|
MAINTENANCE = "maintenance"
|
|
45
47
|
CONNECTION = "connection"
|
|
@@ -119,6 +121,13 @@ class ModuleUnavailableError(LibrusError):
|
|
|
119
121
|
"""The school's Synergia product variant does not include this module."""
|
|
120
122
|
|
|
121
123
|
|
|
124
|
+
class TemporarilyUnavailableError(LibrusError):
|
|
125
|
+
"""Synergia says this view is unavailable for now; other views still work.
|
|
126
|
+
|
|
127
|
+
Retry later. Unlike MaintenanceError, nothing pauses the shared scheduler.
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
|
|
122
131
|
class ThrottledError(LibrusError):
|
|
123
132
|
pass
|
|
124
133
|
|
|
@@ -176,6 +185,7 @@ _ERROR_TYPES: dict[ErrorKind, type[LibrusError]] = {
|
|
|
176
185
|
ErrorKind.UNSUPPORTED_CAPABILITY: UnsupportedCapabilityError,
|
|
177
186
|
ErrorKind.VIEW_DISABLED: ViewDisabledError,
|
|
178
187
|
ErrorKind.MODULE_UNAVAILABLE: ModuleUnavailableError,
|
|
188
|
+
ErrorKind.TEMPORARILY_UNAVAILABLE: TemporarilyUnavailableError,
|
|
179
189
|
ErrorKind.THROTTLED: ThrottledError,
|
|
180
190
|
ErrorKind.MAINTENANCE: MaintenanceError,
|
|
181
191
|
ErrorKind.CONNECTION: ConnectionError,
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/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
|
|
@@ -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:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/_notification_codec.py
RENAMED
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/_windows_filesystem.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/announcements.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/attachment_routes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/attendance_frequency.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/class_free_days.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/completed_lessons.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/detail_fields.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/formative_grades.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/grade_parsers.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/grade_records.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/homework_range.py
RENAMED
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/justifications.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.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.10.2 → librus_python_api-1.11.0}/src/librus_python_api/modern_mailbox.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/modern_messages.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/notification_models.py
RENAMED
|
File without changes
|
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/src/librus_python_api/notification_workflow.py
RENAMED
|
File without changes
|
{librus_python_api-1.10.2 → librus_python_api-1.11.0}/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.2 → librus_python_api-1.11.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
|
|
File without changes
|