(index_html: Path, pages_by_html: dict[Path, Page])
| 588 | |
| 589 | |
| 590 | def _item_order(index_html: Path, pages_by_html: dict[Path, Page]) -> dict[Path, int]: |
| 591 | soup = BeautifulSoup(index_html.read_text(encoding="utf-8"), "html.parser") |
| 592 | positions: dict[Path, int] = {} |
| 593 | position = 1 |
| 594 | for link in soup.select("#main-content dl.item-table dt a[href]"): |
| 595 | href = link.get("href", "") |
| 596 | if not isinstance(href, str): |
| 597 | continue |
| 598 | target_path = (index_html.resolve().parent / urldefrag(href)[0]).resolve() |
| 599 | if target_path not in pages_by_html: |
| 600 | continue |
| 601 | positions.setdefault(target_path, position) |
| 602 | position += 1 |
| 603 | return positions |
| 604 | |
| 605 | |
| 606 | def _positions(pages_by_html: dict[Path, Page], doc_root: Path) -> dict[Path, int]: |
no test coverage detected