librus-python-api 1.11.1__py3-none-any.whl → 1.11.2__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.1"
4
+ __version__ = "1.11.2"
5
5
 
6
6
  from librus_python_api.attachments import AttachmentStream, ModernAttachmentStream
7
7
  from librus_python_api.budget import RequestBudget
@@ -730,6 +730,9 @@ GRADE_MAX_COLUMNS = 64
730
730
  GRADE_MAX_SUBJECTS = 128
731
731
  GRADE_MAX_VALUE_LENGTH = 1024
732
732
  GRADE_MERGED_SUBJECTS = frozenset({"Zachowanie"})
733
+ # Cell spans of the behaviour row reported in #189 (2026-11-21): the last cell
734
+ # covers the annual average, the annual grade and one column the header lacks.
735
+ GRADE_BEHAVIOUR_OVERFLOW_SPANS = (1, 1, 2, 1, 2, 1, 3)
733
736
  GRADE_INLINE_DETAIL_LABEL = "Ocena"
734
737
  # Tooltip fields whose free text may continue on unlabelled lines. A teacher's
735
738
  # multi-line grade comment was observed on 2026-10-27. A formative mirror's
@@ -41,6 +41,10 @@ _INPUT_TYPES = frozenset(
41
41
  # Element IDs whose presence tells a Synergia page from a login or error page.
42
42
  _PAGE_MARKERS = ("graphic-menu", "user-section")
43
43
  _REPORT_BYTES = 32 * 1024
44
+ _LOCATOR_BYTES = 512
45
+ # Integer locals that hold a table's layout, never a value read from the page:
46
+ # a row's expected width, a cell's span, a column position.
47
+ _SHAPE_COUNTS = frozenset({"width", "span", "position"})
44
48
  # Markup observed on Synergia pages. Other class tokens, tags and attribute
45
49
  # names are shown only as lengths, since they could carry data.
46
50
  _CLASSES = frozenset(
@@ -494,55 +498,109 @@ def _is_page(element: html.HtmlElement) -> bool:
494
498
  return element.getparent() is None and element.tag == "html"
495
499
 
496
500
 
501
+ _Elements = list[tuple[str, html.HtmlElement]]
502
+ _Sequences = list[tuple[str, list[html.HtmlElement] | tuple[html.HtmlElement, ...]]]
503
+
504
+
505
+ def _failure_site(
506
+ error: BaseException,
507
+ ) -> tuple[FrameType, int, _Elements, _Sequences, list[tuple[str, int]]] | None:
508
+ """The innermost library frame holding HTML elements, with those elements,
509
+ element sequences and the layout counts named in `_SHAPE_COUNTS`."""
510
+ for frame, line in reversed(_frames(error, (_PACKAGE,))):
511
+ local_items = list(frame.f_locals.items())
512
+ elements = [
513
+ (name, value)
514
+ for name, value in local_items
515
+ if isinstance(value, html.HtmlElement)
516
+ ][:_ELEMENT_LOCALS]
517
+ sequences = [
518
+ (name, value)
519
+ for name, value in local_items
520
+ if isinstance(value, (list, tuple))
521
+ and value
522
+ and all(isinstance(item, html.HtmlElement) for item in value)
523
+ ][:_ELEMENT_LOCALS]
524
+ if not elements and not sequences:
525
+ continue
526
+ counts = [
527
+ (name, value)
528
+ for name, value in local_items
529
+ if name in _SHAPE_COUNTS and type(value) is int
530
+ ]
531
+ return frame, line, elements, sequences, counts
532
+ return None
533
+
534
+
497
535
  def describe_failure(error: BaseException) -> str | None:
498
536
  """The page structure around a failure, for a bug report.
499
537
 
500
538
  Shows the HTML elements held by the innermost library frame that holds
501
539
  any: tags, safe class tokens, known tooltip labels, known link families
502
- and lengths. A whole page is summarized last (see _page_summary). Text
503
- and attribute values are masked unless they equal a parser constant.
540
+ and lengths, then the layout counts it compared (such as `width`). A
541
+ whole page is summarized last (see _page_summary). Text and attribute
542
+ values are masked unless they equal a parser constant.
504
543
  Returns None when there is nothing to show; never raises.
505
544
  """
506
545
  try:
546
+ site = _failure_site(error)
547
+ if site is None:
548
+ return None
549
+ frame, line, elements, sequences, counts = site
507
550
  redactor = _Redactor()
508
- for frame, line in reversed(_frames(error, (_PACKAGE,))):
509
- local_items = list(frame.f_locals.items())
510
- elements = [
511
- (name, value)
512
- for name, value in local_items
513
- if isinstance(value, html.HtmlElement)
514
- ][:_ELEMENT_LOCALS]
515
- sequences = [
516
- (name, value)
517
- for name, value in local_items
518
- if isinstance(value, (list, tuple))
519
- and value
520
- and all(isinstance(item, html.HtmlElement) for item in value)
521
- ][:_ELEMENT_LOCALS]
522
- if not elements and not sequences:
551
+ lines = [f"at {_site(frame, line)}"]
552
+ # The elements nearest the failure first; a page summary last.
553
+ for name, value in sorted(elements, key=lambda item: _is_page(item[1])):
554
+ redactor.nodes = 0
555
+ if _is_page(value):
556
+ summary = "\n".join(_page_summary(value, redactor))
557
+ if len(summary) > _ELEMENT_BYTES:
558
+ summary = summary[:_ELEMENT_BYTES] + "...(truncated)"
559
+ lines += [f"{name}: page", summary]
523
560
  continue
524
- lines = [f"at {_site(frame, line)}"]
525
- # The elements nearest the failure first; a page summary last.
526
- for name, value in sorted(elements, key=lambda item: _is_page(item[1])):
527
- redactor.nodes = 0
528
- if _is_page(value):
529
- summary = "\n".join(_page_summary(value, redactor))
530
- if len(summary) > _ELEMENT_BYTES:
531
- summary = summary[:_ELEMENT_BYTES] + "...(truncated)"
532
- lines += [f"{name}: page", summary]
533
- continue
534
- lines.append(f"{name}: {_path(value, redactor)}")
535
- rendered = redactor.element(value)
536
- if len(rendered) > _ELEMENT_BYTES:
537
- rendered = rendered[:_ELEMENT_BYTES] + "...(truncated)"
538
- lines.append(" " + rendered)
539
- for name, items in sequences:
540
- tags = ",".join(str(item.tag) for item in items[:20])
541
- lines.append(f"{name}: {len(items)} elements: {tags}")
542
- report = "\n".join(lines)
543
- if len(report) > _REPORT_BYTES:
544
- report = report[:_REPORT_BYTES] + "...(truncated)"
545
- return report
561
+ lines.append(f"{name}: {_path(value, redactor)}")
562
+ rendered = redactor.element(value)
563
+ if len(rendered) > _ELEMENT_BYTES:
564
+ rendered = rendered[:_ELEMENT_BYTES] + "...(truncated)"
565
+ lines.append(" " + rendered)
566
+ for name, items in sequences:
567
+ tags = ",".join(str(item.tag) for item in items[:20])
568
+ lines.append(f"{name}: {len(items)} elements: {tags}")
569
+ for name, count in counts:
570
+ lines.append(f"{name}: {count}")
571
+ report = "\n".join(lines)
572
+ if len(report) > _REPORT_BYTES:
573
+ report = report[:_REPORT_BYTES] + "...(truncated)"
574
+ return report
575
+ except Exception:
546
576
  return None
577
+
578
+
579
+ def failure_locator(error: BaseException) -> str | None:
580
+ """One line saying where in the page a failure happened, for an error result.
581
+
582
+ The masked path of the element nearest the failure (as in
583
+ `describe_failure`), then the sizes it was checked against, for example
584
+ `table.stretch.decorated[1] > tbody[1] > tr.bolded.line0[2] > td.center[7];
585
+ cells 7, columns 11, width 10`. Structure and counts only, never page text
586
+ or values. Returns None when no page element is involved; never raises.
587
+ """
588
+ try:
589
+ site = _failure_site(error)
590
+ if site is None:
591
+ return None
592
+ _, _, elements, sequences, counts = site
593
+ redactor = _Redactor()
594
+ parts = [
595
+ _path(value, redactor) for _, value in elements if not _is_page(value)
596
+ ][:1]
597
+ sizes = [f"{name} {len(items)}" for name, items in sequences]
598
+ sizes += [f"{name} {value}" for name, value in counts]
599
+ if sizes:
600
+ parts.append(", ".join(sizes))
601
+ if not parts:
602
+ return None
603
+ locator = "; ".join(parts)
604
+ return locator[:_LOCATOR_BYTES]
547
605
  except Exception:
548
606
  return None
@@ -7,6 +7,7 @@ from lxml import html
7
7
 
8
8
  from librus_python_api import markup
9
9
  from librus_python_api.config import (
10
+ GRADE_BEHAVIOUR_OVERFLOW_SPANS,
10
11
  GRADE_BODY_PREFIX_COLUMNS,
11
12
  GRADE_CURRENT_HEADER,
12
13
  GRADE_EMPTY_MARKERS,
@@ -163,6 +164,16 @@ def _subject_columns(
163
164
  if len(columns) + span > GRADE_MAX_COLUMNS:
164
165
  raise LibrusError(ErrorKind.LIMIT)
165
166
  columns.extend([cell] * span)
167
+ # One school's behaviour row ends with a cell spanning one column past the
168
+ # header (2026-11-21, #189). Only that exact layout drops the extra column;
169
+ # any other span order could shift summary values into the wrong fields.
170
+ if (
171
+ subject in GRADE_MERGED_SUBJECTS
172
+ and tuple(markup.colspan(cell) for cell in cells)
173
+ == GRADE_BEHAVIOUR_OVERFLOW_SPANS
174
+ and len(columns) == width + 1
175
+ ):
176
+ del columns[width:]
166
177
  if len(columns) != width:
167
178
  raise LibrusError(ErrorKind.PARSE)
168
179
  return subject, columns
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: librus-python-api
3
- Version: 1.11.1
3
+ Version: 1.11.2
4
4
  Summary: Independent bounded async Librus Synergia client
5
5
  Project-URL: Repository, https://github.com/krzysztofbury/librus-python-api
6
6
  Project-URL: Issues, https://github.com/krzysztofbury/librus-python-api/issues
@@ -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.1` fixes a Windows store shared by several processes
45
+ **Status:** `1.11.2` reads a behaviour row whose last cell spans past the
46
+ grade table and names the failing cell in diagnostics. `1.11.1` fixes a Windows store shared by several processes
46
47
  reporting `StorageError`, also after a dispatched send. `1.11.0` raises `TemporarilyUnavailableError` for the archive's
47
48
  loading notice, a view that is unavailable for now while the rest of Synergia
48
49
  works. `1.10.3` reads pages with the libxml2 that lxml's Windows wheels
@@ -83,7 +84,7 @@ See [limitations](#supported-features-and-limitations) below.
83
84
  Install the exact release from PyPI after its gated publication completes:
84
85
 
85
86
  ```sh
86
- python -m pip install librus-python-api==1.11.1
87
+ python -m pip install librus-python-api==1.11.2
87
88
  ```
88
89
 
89
90
  Pin the exact version qualified by your application. Before publication, use a
@@ -99,7 +100,7 @@ python -m pip install .
99
100
  To install a locally built wheel instead:
100
101
 
101
102
  ```sh
102
- python -m pip install ./dist/librus_python_api-1.11.1-py3-none-any.whl
103
+ python -m pip install ./dist/librus_python_api-1.11.2-py3-none-any.whl
103
104
  ```
104
105
 
105
106
  No console script or background process is installed: import the library in your
@@ -1,4 +1,4 @@
1
- librus_python_api/__init__.py,sha256=_t7dxvoL0owm9YJG782lYb0fb8GCjiSSNMcUbL0eJTE,6846
1
+ librus_python_api/__init__.py,sha256=UAlW1l-YERDVjjXg7sbU6rBMOiJNuyJF_FMEDUS2BPo,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
@@ -12,14 +12,14 @@ librus_python_api/budget.py,sha256=8fvqT7eIxyVX2P2OBG27XsYHk_HbtSS4lzuecYpHtgs,2
12
12
  librus_python_api/checkpoint.py,sha256=QBmG9GtpyaGRaFq-FXuGA3yR1BjuMFN9V3RTvvi_FNQ,1930
13
13
  librus_python_api/class_free_days.py,sha256=IwoCgr-9ZgEYYQ6717s4cDpyFzbosHMzESMabXJLGqA,2422
14
14
  librus_python_api/completed_lessons.py,sha256=X3NygnzEVaNM53mIf8wiIWF8GHvGCI4bmI0YROdXXLs,10875
15
- librus_python_api/config.py,sha256=USVurJoNxjSnLZqDpmejnZcXepvPK8iWN00R9Gf9gbU,66589
15
+ librus_python_api/config.py,sha256=Tt58oVszUHHEg_7ChULh0jk74l0pGzxJdGMoiMd0lO4,66802
16
16
  librus_python_api/detail_fields.py,sha256=vDDi5sV-e30-42SF0hwAUoldiZ5wvYtb1UlLt03lBHw,1708
17
- librus_python_api/diagnostics.py,sha256=SFQ3Wq6JEFOEHjRKe0-8zcCeJ8c8Eq8lIkVk2_a8IKU,19126
17
+ librus_python_api/diagnostics.py,sha256=ovNKsCQHA4Be7OWWO5XkUKjYvcQfe1wWq_360-3Z9ns,21263
18
18
  librus_python_api/exceptions.py,sha256=t8F15ZimGdvBgNpHX3URpBIckabMHM4Q8fsWmtWqOzk,5907
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=ROfffkCP8yj5Q708TZdpp0PDTyVmoh6X7m0y2fyJcwg,11202
22
+ librus_python_api/grade_parsers.py,sha256=Zv7cg31L518IA5g7c6YtdR453F4VrIA19WQontqkGQ4,11697
23
23
  librus_python_api/grade_records.py,sha256=Kt9zwqZNQMsIovNj2Qu9Y6oRGEqRXw-1T1X2PpkNbeY,31650
24
24
  librus_python_api/homework_range.py,sha256=erYfvS6PhHU5XhnR6LkiLNy677hGVflY3UAuHOs-YUw,1663
25
25
  librus_python_api/inspect_page.py,sha256=uSFJRcEd5m36kqqP6kf2uowB4x2RGNqyfnmaakVzL94,5938
@@ -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.1.dist-info/METADATA,sha256=J-yZIQsPgb-a1Qz-NuM2TLH5T2rP7geD5VeuWGuP5eM,15678
52
- librus_python_api-1.11.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
53
- librus_python_api-1.11.1.dist-info/licenses/LICENSE,sha256=IuerLb3cnZCsaB23znydjjvKqP-LmSJd3syKa9NGUts,1071
54
- librus_python_api-1.11.1.dist-info/RECORD,,
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,,