librus-python-api 1.11.2__py3-none-any.whl → 1.11.3__py3-none-any.whl

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.
@@ -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.11.2"
4
+ __version__ = "1.11.3"
5
5
 
6
6
  from librus_python_api.attachments import AttachmentStream, ModernAttachmentStream
7
7
  from librus_python_api.budget import RequestBudget
@@ -48,20 +48,24 @@ def _summary_field(cell: html.HtmlElement, *, points: bool = False) -> str | Non
48
48
 
49
49
  def _header(
50
50
  row: html.HtmlElement, *, points: bool = False
51
- ) -> tuple[dict[str, int], int]:
51
+ ) -> tuple[dict[str, int], int, frozenset[int]]:
52
+ """Summary field columns, the width, and the current-grade columns."""
52
53
  fields: dict[str, int] = {}
54
+ current: set[int] = set()
53
55
  position = GRADE_BODY_PREFIX_COLUMNS
54
56
  for cell in markup.cells(row):
55
57
  span = markup.colspan(cell)
56
58
  if position + span > GRADE_MAX_COLUMNS:
57
59
  raise LibrusError(ErrorKind.LIMIT)
60
+ if markup.text(cell) == GRADE_CURRENT_HEADER:
61
+ current.update(range(position, position + span))
58
62
  field = _summary_field(cell, points=points)
59
63
  if field is not None:
60
64
  if field in fields:
61
65
  raise LibrusError(ErrorKind.PARSE)
62
66
  fields[field] = position
63
67
  position += span
64
- return fields, position
68
+ return fields, position, frozenset(current)
65
69
 
66
70
 
67
71
  def is_point_table(table: html.HtmlElement) -> bool:
@@ -85,8 +89,11 @@ def _current_header(table: html.HtmlElement) -> bool:
85
89
  )
86
90
 
87
91
 
88
- def point_layout(table: html.HtmlElement) -> tuple[dict[str, int], int]:
89
- """Summary fields and width from the point table's current-grade header row.
92
+ def point_layout(
93
+ table: html.HtmlElement,
94
+ ) -> tuple[dict[str, int], int, frozenset[int]]:
95
+ """Summary fields, width and current-grade columns from the point table's
96
+ current-grade header row.
90
97
 
91
98
  Point tables are not required to have an annual column, so the row with
92
99
  the two current-grade headers defines the body alignment instead.
@@ -102,10 +109,11 @@ def point_layout(table: html.HtmlElement) -> tuple[dict[str, int], int]:
102
109
  return _header(headers[0], points=True)
103
110
 
104
111
 
105
- def _candidates(
106
- document: html.HtmlElement,
107
- ) -> list[tuple[html.HtmlElement, dict[str, int], int]]:
108
- candidates: list[tuple[html.HtmlElement, dict[str, int], int]] = []
112
+ _Layout = tuple[html.HtmlElement, dict[str, int], int, frozenset[int]]
113
+
114
+
115
+ def _candidates(document: html.HtmlElement) -> list[_Layout]:
116
+ candidates: list[_Layout] = []
109
117
  for table in document.iter("table"):
110
118
  if not {"decorated", "stretch"} <= set(table.get("class", "").split()):
111
119
  continue
@@ -118,14 +126,12 @@ def _candidates(
118
126
  # an annual summary title defines the body alignment contract.
119
127
  if not any(_summary_field(cell) == "annual" for cell in markup.cells(row)):
120
128
  continue
121
- fields, width = _header(row)
122
- candidates.append((table, fields, width))
129
+ fields, width, current = _header(row)
130
+ candidates.append((table, fields, width, current))
123
131
  return candidates
124
132
 
125
133
 
126
- def _locate(
127
- document: html.HtmlElement,
128
- ) -> tuple[html.HtmlElement, dict[str, int], int]:
134
+ def _locate(document: html.HtmlElement) -> _Layout:
129
135
  candidates = _candidates(document)
130
136
  if len(candidates) != 1:
131
137
  raise LibrusError(ErrorKind.PARSE)
@@ -183,12 +189,29 @@ def _summary(
183
189
  cells: list[html.HtmlElement],
184
190
  fields: dict[str, int],
185
191
  width: int,
192
+ current: frozenset[int] | None = None,
186
193
  ) -> SubjectGradeSummary:
194
+ """One subject's summary values.
195
+
196
+ `current` holds the header's current-grade columns. Pass it whenever the
197
+ values are returned; `grades()` reads only the subject and passes none.
198
+ """
187
199
  subject, columns = _subject_columns(cells, width)
188
200
  selected = [columns[index] for index in fields.values()]
189
201
  if len({id(cell) for cell in selected}) != len(selected):
190
202
  # A single merged value cannot mean two different summary fields.
191
203
  raise LibrusError(ErrorKind.PARSE)
204
+ # A merged cell over a current-grade column holds the behaviour points,
205
+ # not a summary value (#192). Unless the header names both periods'
206
+ # current-grade columns, as every grade table does, a merged value cannot
207
+ # be checked at all.
208
+ for cell in selected:
209
+ if (
210
+ current is not None
211
+ and markup.colspan(cell) > 1
212
+ and (len(current) != 2 or any(columns[index] is cell for index in current))
213
+ ):
214
+ raise LibrusError(ErrorKind.PARSE)
192
215
  values = {
193
216
  name: GradeSummaryValue(Availability.AVAILABLE, markup.text(columns[index]))
194
217
  for name, index in fields.items()
@@ -270,21 +293,21 @@ def parse_final_grades(body: bytes) -> tuple[SubjectGradeSummary, ...]:
270
293
  if len(sources) > 1 or not (sources or point_tables):
271
294
  raise LibrusError(ErrorKind.PARSE)
272
295
  if point_tables:
273
- located = {id(table) for table, _, _ in sources}
296
+ located = {id(table) for table, _, _, _ in sources}
274
297
  if any(
275
298
  _current_header(table) and id(table) not in located
276
299
  for table in document.iter("table")
277
300
  if table not in point_tables
278
301
  ):
279
302
  raise LibrusError(ErrorKind.PARSE)
280
- fields, width = point_layout(point_tables[0])
303
+ fields, width, current = point_layout(point_tables[0])
281
304
  if fields:
282
- sources.append((point_tables[0], fields, width))
305
+ sources.append((point_tables[0], fields, width, current))
283
306
  items: dict[str, SubjectGradeSummary] = {}
284
- for table, fields, width in sources:
307
+ for table, fields, width, current in sources:
285
308
  family_subjects: set[str] = set()
286
309
  for cells in _subject_rows(table, width, points=table in point_tables):
287
- item = _summary(cells, fields, width)
310
+ item = _summary(cells, fields, width, current)
288
311
  if item.subject in family_subjects:
289
312
  raise LibrusError(ErrorKind.PARSE)
290
313
  family_subjects.add(item.subject)
@@ -587,9 +587,9 @@ def _read_numeric_table(
587
587
  # Preserve the established full-row and summary alignment validation. A
588
588
  # point table aligns on its current-grade header row and may lack summaries.
589
589
  if points:
590
- fields, width = point_layout(table)
590
+ fields, width, _ = point_layout(table)
591
591
  else:
592
- _, fields, width = _locate(table)
592
+ _, fields, width, _ = _locate(table)
593
593
  current, means = _layout(table, points=points)
594
594
  periods = _period_columns(table, points=points)
595
595
  averages = collection.point_results if points else collection.averages
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: librus-python-api
3
- Version: 1.11.2
3
+ Version: 1.11.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,8 @@ 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.11.2` reads a behaviour row whose last cell spans past the
45
+ **Status:** `1.11.3` never returns behaviour points as a final grade when the
46
+ behaviour row's cells are merged differently. `1.11.2` reads a behaviour row whose last cell spans past the
46
47
  grade table and names the failing cell in diagnostics. `1.11.1` fixes a Windows store shared by several processes
47
48
  reporting `StorageError`, also after a dispatched send. `1.11.0` raises `TemporarilyUnavailableError` for the archive's
48
49
  loading notice, a view that is unavailable for now while the rest of Synergia
@@ -84,7 +85,7 @@ See [limitations](#supported-features-and-limitations) below.
84
85
  Install the exact release from PyPI after its gated publication completes:
85
86
 
86
87
  ```sh
87
- python -m pip install librus-python-api==1.11.2
88
+ python -m pip install librus-python-api==1.11.3
88
89
  ```
89
90
 
90
91
  Pin the exact version qualified by your application. Before publication, use a
@@ -100,7 +101,7 @@ python -m pip install .
100
101
  To install a locally built wheel instead:
101
102
 
102
103
  ```sh
103
- python -m pip install ./dist/librus_python_api-1.11.2-py3-none-any.whl
104
+ python -m pip install ./dist/librus_python_api-1.11.3-py3-none-any.whl
104
105
  ```
105
106
 
106
107
  No console script or background process is installed: import the library in your
@@ -1,4 +1,4 @@
1
- librus_python_api/__init__.py,sha256=UAlW1l-YERDVjjXg7sbU6rBMOiJNuyJF_FMEDUS2BPo,6846
1
+ librus_python_api/__init__.py,sha256=TwVTKBiCFxV8gPDAe0Fj3vvS_mS0ZBlRfs_I_3HuhKc,6846
2
2
  librus_python_api/_notification_bootstrap.py,sha256=18nzH0doXBNaZXCz-_ckIvRrlHTWV5Mm1t5m2-5eYGI,4669
3
3
  librus_python_api/_notification_codec.py,sha256=hU6G3zGJ5fR8wfPC6fV2OqBKs-7XpT9eRnKO3FGsTzY,13451
4
4
  librus_python_api/_storage.py,sha256=M_6ZAzN4zs7laOdKJBRH1I2rvy3pgqYgC_MZtsd2xtM,15893
@@ -19,8 +19,8 @@ librus_python_api/exceptions.py,sha256=t8F15ZimGdvBgNpHX3URpBIckabMHM4Q8fsWmtWqO
19
19
  librus_python_api/files.py,sha256=pQBsIJyfTOZDz83ZB-5fcd-nPMcxR1HJ155h4zTHmsA,9223
20
20
  librus_python_api/formative_grades.py,sha256=VykwtGvViZVOJMwPH3Re1RTDCHMr1_m9_xHjZyaXDIQ,6452
21
21
  librus_python_api/gateway_grades.py,sha256=ILqWkkaRq120wG--h7GfFy4qFAQcuaa6LpzJOcCA2FU,22921
22
- librus_python_api/grade_parsers.py,sha256=Zv7cg31L518IA5g7c6YtdR453F4VrIA19WQontqkGQ4,11697
23
- librus_python_api/grade_records.py,sha256=Kt9zwqZNQMsIovNj2Qu9Y6oRGEqRXw-1T1X2PpkNbeY,31650
22
+ librus_python_api/grade_parsers.py,sha256=P7s9yOzY6gYoWJUbo_ZKjE2xZlkHyDXakbQLJOQ5a9U,12759
23
+ librus_python_api/grade_records.py,sha256=vx56fzZF4aX6Fq8Bev6Ya_c9ZtXd55K0PBhUW2RM0mc,31656
24
24
  librus_python_api/homework_range.py,sha256=erYfvS6PhHU5XhnR6LkiLNy677hGVflY3UAuHOs-YUw,1663
25
25
  librus_python_api/inspect_page.py,sha256=uSFJRcEd5m36kqqP6kf2uowB4x2RGNqyfnmaakVzL94,5938
26
26
  librus_python_api/justifications.py,sha256=ZzfeZR5TvYyArQ5Oqi6VM5JmBKS2lZok4UR7hc3dI4o,7799
@@ -48,7 +48,7 @@ librus_python_api/sending.py,sha256=Nvvk2r-6D6Us53a2fH5GW9PcA6bWEfuOvy6c3M5QVcE,
48
48
  librus_python_api/service.py,sha256=0RQZW_jPwh8VJNphJ0NUcdeYR2VpZ30MQKns_12BsxU,105678
49
49
  librus_python_api/timetable.py,sha256=tX1QK9fQABxzfLaHHqTe8e6rAgdOkCoTOfAHdPwNmLE,9836
50
50
  librus_python_api/transport.py,sha256=yF-DnFy4xGYS_RWQ9161b9WJXOlYF8cFRgdjXmVVUIk,34988
51
- librus_python_api-1.11.2.dist-info/METADATA,sha256=jAdK5CLAeZCkcbODKjOQsJyJnfSMglGf9pExAlNK6CY,15795
52
- librus_python_api-1.11.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
53
- librus_python_api-1.11.2.dist-info/licenses/LICENSE,sha256=IuerLb3cnZCsaB23znydjjvKqP-LmSJd3syKa9NGUts,1071
54
- librus_python_api-1.11.2.dist-info/RECORD,,
51
+ librus_python_api-1.11.3.dist-info/METADATA,sha256=dPCJL5OoHQx4jZ2ppvqfqbHgp5g_bn1ms5yuQm4mXqc,15907
52
+ librus_python_api-1.11.3.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
53
+ librus_python_api-1.11.3.dist-info/licenses/LICENSE,sha256=IuerLb3cnZCsaB23znydjjvKqP-LmSJd3syKa9NGUts,1071
54
+ librus_python_api-1.11.3.dist-info/RECORD,,