primarysource 0.1.0__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.
- primarysource/__init__.py +5 -0
- primarysource/bbf/__init__.py +56 -0
- primarysource/bbf/_xml.py +63 -0
- primarysource/bbf/catalogue.json +777 -0
- primarysource/bbf/catalogue.py +137 -0
- primarysource/bbf/cli.py +79 -0
- primarysource/bbf/datamodel.py +281 -0
- primarysource/bbf/importer.py +151 -0
- primarysource/bbf/library.py +380 -0
- primarysource/bbf/server.py +72 -0
- primarysource/budget.py +63 -0
- primarysource/c2sp/__init__.py +53 -0
- primarysource/c2sp/_fetch.py +5 -0
- primarysource/c2sp/catalogue.json +231 -0
- primarysource/c2sp/catalogue.py +95 -0
- primarysource/c2sp/cli.py +62 -0
- primarysource/c2sp/importer.py +90 -0
- primarysource/c2sp/library.py +309 -0
- primarysource/c2sp/markdown.py +31 -0
- primarysource/c2sp/server.py +68 -0
- primarysource/cavp/__init__.py +42 -0
- primarysource/cavp/cli.py +84 -0
- primarysource/cavp/data/vectors.toml +47 -0
- primarysource/cavp/importer.py +156 -0
- primarysource/cavp/model.py +279 -0
- primarysource/cavp/parse.py +269 -0
- primarysource/cavp/paths.py +17 -0
- primarysource/cavp/server.py +67 -0
- primarysource/cavp/tools.py +169 -0
- primarysource/cli.py +107 -0
- primarysource/cursor.py +82 -0
- primarysource/cve/__init__.py +5 -0
- primarysource/cve/__main__.py +6 -0
- primarysource/cve/cli.py +144 -0
- primarysource/cve/collection.py +20 -0
- primarysource/cve/config.py +58 -0
- primarysource/cve/errors.py +16 -0
- primarysource/cve/kernel.py +232 -0
- primarysource/cve/mcp.py +139 -0
- primarysource/cve/parse.py +318 -0
- primarysource/cve/py.typed +0 -0
- primarysource/cve/service.py +760 -0
- primarysource/cve/store.py +214 -0
- primarysource/cve/sync.py +438 -0
- primarysource/cve/views.py +304 -0
- primarysource/debpolicy/__init__.py +16 -0
- primarysource/debpolicy/catalogue.py +263 -0
- primarysource/debpolicy/cli.py +12 -0
- primarysource/debpolicy/server.py +11 -0
- primarysource/draft/__init__.py +11 -0
- primarysource/draft/catalogue.py +117 -0
- primarysource/draft/cli.py +149 -0
- primarysource/draft/collection.py +21 -0
- primarysource/draft/datatracker.py +158 -0
- primarysource/draft/importer.py +163 -0
- primarysource/draft/licence.py +89 -0
- primarysource/draft/names.py +64 -0
- primarysource/draft/net.py +133 -0
- primarysource/draft/segment.py +192 -0
- primarysource/draft/server.py +91 -0
- primarysource/draft/status.py +146 -0
- primarysource/draft/store.py +199 -0
- primarysource/draft/tracked.json +104 -0
- primarysource/draft/views.py +430 -0
- primarysource/draft/xmlmeta.py +74 -0
- primarysource/ecma/__init__.py +52 -0
- primarysource/ecma/_pdf.py +143 -0
- primarysource/ecma/catalogue.json +22 -0
- primarysource/ecma/catalogue.py +100 -0
- primarysource/ecma/cli.py +67 -0
- primarysource/ecma/identify.py +25 -0
- primarysource/ecma/importer.py +108 -0
- primarysource/ecma/library.py +240 -0
- primarysource/ecma/server.py +67 -0
- primarysource/errors.py +29 -0
- primarysource/fetch.py +360 -0
- primarysource/fsutil.py +150 -0
- primarysource/gitdocs/__init__.py +15 -0
- primarysource/gitdocs/catalogue.py +116 -0
- primarysource/gitdocs/cli.py +12 -0
- primarysource/gitdocs/server.py +8 -0
- primarysource/home.py +65 -0
- primarysource/iana/__init__.py +32 -0
- primarysource/iana/catalogue.json +244 -0
- primarysource/iana/catalogue.py +69 -0
- primarysource/iana/cli.py +69 -0
- primarysource/iana/importer.py +157 -0
- primarysource/iana/model.py +325 -0
- primarysource/iana/reader.py +315 -0
- primarysource/iana/server.py +67 -0
- primarysource/iana/store.py +83 -0
- primarysource/iana/xmlsafe.py +47 -0
- primarysource/identify.py +186 -0
- primarysource/ieee/__init__.py +58 -0
- primarysource/ieee/_html.py +49 -0
- primarysource/ieee/catalogue.json +74 -0
- primarysource/ieee/catalogue.py +123 -0
- primarysource/ieee/cli.py +79 -0
- primarysource/ieee/identify.py +24 -0
- primarysource/ieee/ieee802.py +47 -0
- primarysource/ieee/importer.py +305 -0
- primarysource/ieee/posix.py +233 -0
- primarysource/ieee/server.py +79 -0
- primarysource/index.py +446 -0
- primarysource/iso/__init__.py +51 -0
- primarysource/iso/cli.py +98 -0
- primarysource/iso/designation.py +95 -0
- primarysource/iso/identify.py +100 -0
- primarysource/iso/importer.py +224 -0
- primarysource/iso/library.py +249 -0
- primarysource/iso/server.py +69 -0
- primarysource/itu/__init__.py +41 -0
- primarysource/itu/__main__.py +8 -0
- primarysource/itu/asn1mod.py +478 -0
- primarysource/itu/catalog.py +472 -0
- primarysource/itu/cli.py +445 -0
- primarysource/itu/collection.py +20 -0
- primarysource/itu/corpus.py +118 -0
- primarysource/itu/errata.py +16 -0
- primarysource/itu/formal.py +565 -0
- primarysource/itu/identify.py +26 -0
- primarysource/itu/index.py +490 -0
- primarysource/itu/mcp.py +474 -0
- primarysource/itu/py.typed +0 -0
- primarysource/itu/sources.py +600 -0
- primarysource/itu/text.py +609 -0
- primarysource/kconfig/__init__.py +16 -0
- primarysource/kconfig/catalogue.py +98 -0
- primarysource/kconfig/cli.py +12 -0
- primarysource/kconfig/server.py +8 -0
- primarysource/model.py +63 -0
- primarysource/nist/__init__.py +5 -0
- primarysource/nist/collection.py +46 -0
- primarysource/nist/data/acquired-nist.json +1657 -0
- primarysource/nist/data/nist-catalog.json +12090 -0
- primarysource/nist/data/sources.toml +1996 -0
- primarysource/nist/identify.py +41 -0
- primarysource/nist/ingest/__init__.py +1 -0
- primarysource/nist/ingest/acquire_nist.py +128 -0
- primarysource/nist/ingest/controls.py +82 -0
- primarysource/nist/ingest/discover_nist.py +218 -0
- primarysource/nist/ingest/extract.py +48 -0
- primarysource/nist/ingest/fetch.py +211 -0
- primarysource/nist/ingest/index.py +14 -0
- primarysource/nist/ingest/oscal.py +480 -0
- primarysource/nist/ingest/prose_layouts.py +236 -0
- primarysource/nist/ingest/sources.py +94 -0
- primarysource/nist/ingest/status.py +255 -0
- primarysource/nist/models.py +7 -0
- primarysource/nist/paths.py +33 -0
- primarysource/nist/server/__init__.py +3 -0
- primarysource/nist/server/corpus.py +38 -0
- primarysource/nist/server/mcp.py +19 -0
- primarysource/nist/server/tools.py +35 -0
- primarysource/nist/spec.py +38 -0
- primarysource/pdfcorpus/__init__.py +16 -0
- primarysource/pdfcorpus/corpus.py +159 -0
- primarysource/pdfcorpus/fts.py +175 -0
- primarysource/pdfcorpus/index.py +70 -0
- primarysource/pdfcorpus/models.py +30 -0
- primarysource/pdfcorpus/server.py +96 -0
- primarysource/pdfcorpus/spec.py +37 -0
- primarysource/pdfcorpus/split.py +391 -0
- primarysource/pdfcorpus/tools.py +244 -0
- primarysource/pep/__init__.py +15 -0
- primarysource/pep/catalogue.py +191 -0
- primarysource/pep/cli.py +12 -0
- primarysource/pep/server.py +8 -0
- primarysource/pkgdocs/__init__.py +19 -0
- primarysource/pkgdocs/fetch.py +356 -0
- primarysource/pkgdocs/index.py +89 -0
- primarysource/pkgdocs/model.py +76 -0
- primarysource/pkgdocs/readers/__init__.py +1 -0
- primarysource/pkgdocs/readers/_common.py +134 -0
- primarysource/pkgdocs/readers/asciidoc.py +160 -0
- primarysource/pkgdocs/readers/latex.py +315 -0
- primarysource/pkgdocs/readers/markdown.py +173 -0
- primarysource/pkgdocs/readers/pod.py +132 -0
- primarysource/pkgdocs/readers/rst.py +239 -0
- primarysource/pkgdocs/readers/scdoc.py +108 -0
- primarysource/pkgdocs/runtime.py +552 -0
- primarysource/pkgdocs/serving.py +158 -0
- primarysource/pkgdocs/store.py +167 -0
- primarysource/pms/__init__.py +16 -0
- primarysource/pms/catalogue.py +88 -0
- primarysource/pms/cli.py +12 -0
- primarysource/pms/server.py +8 -0
- primarysource/py.typed +0 -0
- primarysource/readers/__init__.py +10 -0
- primarysource/readers/bookmarks.py +192 -0
- primarysource/readers/html.py +1312 -0
- primarysource/readers/markdown.py +189 -0
- primarysource/readers/pdf.py +187 -0
- primarysource/readers/xml.py +230 -0
- primarysource/refs.py +87 -0
- primarysource/registry.py +161 -0
- primarysource/render.py +49 -0
- primarysource/rfc/__init__.py +3 -0
- primarysource/rfc/__main__.py +6 -0
- primarysource/rfc/cite.py +204 -0
- primarysource/rfc/cli.py +903 -0
- primarysource/rfc/collection.py +19 -0
- primarysource/rfc/config.py +138 -0
- primarysource/rfc/errata.py +203 -0
- primarysource/rfc/fsutil.py +82 -0
- primarysource/rfc/graph.py +213 -0
- primarysource/rfc/index/__init__.py +1 -0
- primarysource/rfc/index/chunker.py +281 -0
- primarysource/rfc/index/embed.py +166 -0
- primarysource/rfc/index/hybrid.py +305 -0
- primarysource/rfc/index/lexical.py +223 -0
- primarysource/rfc/index/rfcxml.py +673 -0
- primarysource/rfc/index/search.py +508 -0
- primarysource/rfc/index/txtseg.py +585 -0
- primarysource/rfc/library.py +294 -0
- primarysource/rfc/mcp/__init__.py +1 -0
- primarysource/rfc/mcp/server.py +381 -0
- primarysource/rfc/packs/__init__.py +1 -0
- primarysource/rfc/packs/builder.py +228 -0
- primarysource/rfc/packs/collections/all-current-txt.json +10 -0
- primarysource/rfc/packs/collections/essentials.json +19 -0
- primarysource/rfc/packs/collections/fyi-current.json +10 -0
- primarysource/rfc/packs/collections/standards-current.json +10 -0
- primarysource/rfc/packs/collections/year-2025.json +10 -0
- primarysource/rfc/packs/collections/year-2026.json +10 -0
- primarysource/rfc/packs/collections.py +163 -0
- primarysource/rfc/packs/docsetexport.py +163 -0
- primarysource/rfc/packs/epub.py +159 -0
- primarysource/rfc/packs/export.py +306 -0
- primarysource/rfc/packs/htmlexport.py +82 -0
- primarysource/rfc/packs/serve.py +143 -0
- primarysource/rfc/packs/zimexport.py +171 -0
- primarysource/rfc/query.py +466 -0
- primarysource/rfc/subjects.py +457 -0
- primarysource/rfc/sync/__init__.py +1 -0
- primarysource/rfc/sync/downloader.py +132 -0
- primarysource/rfc/sync/manifest.py +162 -0
- primarysource/rfc/sync/scanner.py +49 -0
- primarysource/rfc/sync/state.py +464 -0
- primarysource/rfc/views.py +1067 -0
- primarysource/rpmdocs/__init__.py +15 -0
- primarysource/rpmdocs/catalogue.py +117 -0
- primarysource/rpmdocs/cli.py +12 -0
- primarysource/rpmdocs/server.py +8 -0
- primarysource/scaffold.py +223 -0
- primarysource/serve.py +75 -0
- primarysource/settings.py +152 -0
- primarysource/usb/__init__.py +5 -0
- primarysource/usb/collection.py +37 -0
- primarysource/usb/data/acquired.json +2025 -0
- primarysource/usb/data/sources-usb.toml +852 -0
- primarysource/usb/data/sources.toml +10 -0
- primarysource/usb/data/usb-catalog.json +1663 -0
- primarysource/usb/data/usb-classification.json +1986 -0
- primarysource/usb/data/usb-corpus-build.json +608 -0
- primarysource/usb/data/usb-pdf-choice.json +839 -0
- primarysource/usb/data/usb-split-measure.json +1803 -0
- primarysource/usb/ingest/__init__.py +1 -0
- primarysource/usb/ingest/acquire.py +130 -0
- primarysource/usb/ingest/discover_usb.py +88 -0
- primarysource/usb/ingest/extract.py +48 -0
- primarysource/usb/ingest/fetch.py +197 -0
- primarysource/usb/ingest/index.py +14 -0
- primarysource/usb/ingest/sources.py +85 -0
- primarysource/usb/models.py +7 -0
- primarysource/usb/paths.py +33 -0
- primarysource/usb/server/__init__.py +3 -0
- primarysource/usb/server/corpus.py +38 -0
- primarysource/usb/server/mcp.py +19 -0
- primarysource/usb/server/tools.py +35 -0
- primarysource/usb/spec.py +20 -0
- primarysource/usbids/__init__.py +56 -0
- primarysource/usbids/cli.py +65 -0
- primarysource/usbids/importer.py +272 -0
- primarysource/usbids/parse.py +283 -0
- primarysource/usbids/server.py +55 -0
- primarysource/usbids/store.py +80 -0
- primarysource/usbids/tools.py +174 -0
- primarysource/zim/__init__.py +5 -0
- primarysource/zim/__main__.py +8 -0
- primarysource/zim/_libzim.py +37 -0
- primarysource/zim/catalog.py +594 -0
- primarysource/zim/cli.py +555 -0
- primarysource/zim/collection.py +41 -0
- primarysource/zim/errors.py +100 -0
- primarysource/zim/groups.py +30 -0
- primarysource/zim/library.py +668 -0
- primarysource/zim/manage.py +636 -0
- primarysource/zim/markdown.py +1247 -0
- primarysource/zim/mcp.py +201 -0
- primarysource/zim/purl.py +130 -0
- primarysource/zim/py.typed +0 -0
- primarysource/zim/refs.py +90 -0
- primarysource/zim/service.py +1182 -0
- primarysource/zim/snapshot.py +197 -0
- primarysource/zim/sync.py +269 -0
- primarysource/zim/views.py +230 -0
- primarysource-0.1.0.dist-info/METADATA +118 -0
- primarysource-0.1.0.dist-info/RECORD +303 -0
- primarysource-0.1.0.dist-info/WHEEL +4 -0
- primarysource-0.1.0.dist-info/entry_points.txt +2 -0
- primarysource-0.1.0.dist-info/licenses/LICENSE +203 -0
- primarysource-0.1.0.dist-info/licenses/NOTICE +51 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""One exception type for every state with a known remedy: a `LibError` (PLAN.md §5.10).
|
|
2
|
+
|
|
3
|
+
A tool that answers "no results" when the real state is "no ZIM files are installed" is the bug this portfolio
|
|
4
|
+
keeps rediscovering, so each such state raises `ZimloreError` carrying the fix. It has the core's three fields:
|
|
5
|
+
|
|
6
|
+
- `hint`: what a model with only tools should call next (`zim_available`, `zim_outline ref=...`), or prose that
|
|
7
|
+
names no command;
|
|
8
|
+
- `action`: the command a human must run (`primarysource zim catalog --refresh`), only where only a human can act.
|
|
9
|
+
|
|
10
|
+
zimlore's two audiences (`hint` for the CLI, `tool_hint` for MCP) survive in how an error is *built*: a call site
|
|
11
|
+
still passes a CLI-worded `hint` (a command line) and, where a model can act on its own, `tool_hint=` (the tool to
|
|
12
|
+
call), `user_action=` (what to ask the user) and `user_command=` (the command to give them). The constructor
|
|
13
|
+
sorts them into `hint` and `action`; `cli_text` is the CLI's reading, which puts the command first.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from primarysource.errors import LibError
|
|
19
|
+
|
|
20
|
+
_COMMAND = "primarysource zim"
|
|
21
|
+
CLI_ONLY = ("snapshot_hint",)
|
|
22
|
+
"""Extra keys worded as CLI commands, which a model with only tools cannot run."""
|
|
23
|
+
SORTED_OUT = ("tool_hint", "user_action", "user_command")
|
|
24
|
+
"""Extra keys the constructor turns into `hint` and `action`."""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _name(item: object) -> str:
|
|
28
|
+
return str(item["name"]) if isinstance(item, dict) and "name" in item else str(item)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _listed(extra: dict[str, object]) -> list[str]:
|
|
32
|
+
"""`did_you_mean`, `candidates` and `installed` as hint text: the error text has no other place for them."""
|
|
33
|
+
found = []
|
|
34
|
+
for key in ("did_you_mean", "candidates", "installed"):
|
|
35
|
+
value = extra.get(key)
|
|
36
|
+
if isinstance(value, list) and value:
|
|
37
|
+
found.append(f"{key.replace('_', ' ')}: {', '.join(_name(item) for item in value)}")
|
|
38
|
+
obtainable = extra.get("obtainable")
|
|
39
|
+
if isinstance(obtainable, list) and obtainable:
|
|
40
|
+
names = ", ".join(_name(item) for item in obtainable)
|
|
41
|
+
found.append(
|
|
42
|
+
f"not installed, but in the catalogue snapshot: {names} (zim_available gives the install command)"
|
|
43
|
+
)
|
|
44
|
+
return found
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ZimloreError(LibError):
|
|
48
|
+
def __init__(self, message: str, hint: str = "", **extra: object) -> None:
|
|
49
|
+
super().__init__(message)
|
|
50
|
+
self.cli_hint = hint
|
|
51
|
+
self.extra = extra
|
|
52
|
+
self.settle()
|
|
53
|
+
|
|
54
|
+
def settle(self) -> None:
|
|
55
|
+
"""(Re)build `hint` and `action` from the CLI hint and the extras; call it after changing `extra`."""
|
|
56
|
+
extra = self.extra
|
|
57
|
+
tool = str(extra.get("tool_hint") or "")
|
|
58
|
+
user = str(extra.get("user_action") or "")
|
|
59
|
+
command = str(extra.get("user_command") or "")
|
|
60
|
+
if self.cli_hint and _COMMAND in self.cli_hint:
|
|
61
|
+
cli_command, prose = self.cli_hint, ""
|
|
62
|
+
else:
|
|
63
|
+
cli_command, prose = "", self.cli_hint
|
|
64
|
+
# A command the model can replace with a tool is not an action; one it cannot (`catalog --refresh` touches
|
|
65
|
+
# the network, `get` downloads) is the human's.
|
|
66
|
+
self.action = command or ("" if tool else cli_command)
|
|
67
|
+
self.hint = "; ".join(part for part in (user, tool, prose, *_listed(extra)) if part)
|
|
68
|
+
|
|
69
|
+
def cli_text(self) -> str:
|
|
70
|
+
"""The CLI's reading: the command to run, then what a model would call, without the lines it cannot use."""
|
|
71
|
+
lines = [f"error: {self.message}"]
|
|
72
|
+
fix = self.cli_hint or self.hint
|
|
73
|
+
if fix:
|
|
74
|
+
lines.append(f"hint: {fix}")
|
|
75
|
+
if self.action and self.action != self.cli_hint:
|
|
76
|
+
lines.append(f"action: {self.action}")
|
|
77
|
+
return "\n".join(lines)
|
|
78
|
+
|
|
79
|
+
def as_dict(self) -> dict[str, object]:
|
|
80
|
+
"""The CLI's `--json` wording: `hint` names commands, and the keys meant for a model are left out."""
|
|
81
|
+
payload: dict[str, object] = {"error": self.message}
|
|
82
|
+
if self.cli_hint:
|
|
83
|
+
payload["hint"] = self.cli_hint
|
|
84
|
+
payload.update({k: v for k, v in self.extra.items() if k not in SORTED_OUT})
|
|
85
|
+
return payload
|
|
86
|
+
|
|
87
|
+
def detail(self) -> str:
|
|
88
|
+
"""The extras that name something (`did_you_mean`, `candidates`, `installed`, `anchors`), one line each,
|
|
89
|
+
for the places an error is shown as text."""
|
|
90
|
+
lines = []
|
|
91
|
+
for key in ("did_you_mean", "candidates", "installed", "anchors", "obtainable"):
|
|
92
|
+
value = self.extra.get(key)
|
|
93
|
+
if value:
|
|
94
|
+
lines.append(f"{key}: {value}")
|
|
95
|
+
return "\n".join(lines)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class LibraryNotFound(ZimloreError):
|
|
99
|
+
"""No installed library matches a name. A subclass so callers (the service) can add what is obtainable
|
|
100
|
+
without matching on message text."""
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Named sets of catalogue names for `primarysource zim sync --group NAME`. Names only: no content, no URLs, no paths.
|
|
2
|
+
|
|
3
|
+
**The membership below is an EDITORIAL DEFAULT, not a decision.** Which documentation a "core" set should hold is
|
|
4
|
+
the maintainer's call (`docs/library-management.md` section 6, "should groups ship in the package"); until that is
|
|
5
|
+
made these sets are a starting point that a manifest can ignore, and a user who disagrees loses nothing by naming
|
|
6
|
+
libraries directly. They were chosen from catalogue sizes measured on 2026-11-07 (the catalogue lengths summed
|
|
7
|
+
to about 52 MB for `languages-core`, 29 MB for `web-testing` and 42 MB for `infra`, of which 32 MB is Terraform).
|
|
8
|
+
|
|
9
|
+
Every member is a DevDocs ZIM (`devdocs_en_<slug>`); `tests/test_sync.py` checks each is a valid catalogue name.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
EDITORIAL_DEFAULT = True
|
|
15
|
+
"""True while the membership awaits the maintainer's decision (library-management.md section 6)."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _devdocs(*slugs: str) -> tuple[str, ...]:
|
|
19
|
+
return tuple(f"devdocs_en_{slug}" for slug in slugs)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
GROUPS: dict[str, tuple[str, ...]] = {
|
|
23
|
+
"languages-core": _devdocs(
|
|
24
|
+
"python", "rust", "go", "php", "node", "npm", "typescript", "javascript", "c", "cpp", "ruby", "openjdk"
|
|
25
|
+
),
|
|
26
|
+
"web-testing": _devdocs(
|
|
27
|
+
"html", "css", "dom", "http", "playwright", "cypress", "pytest", "jest", "vitest", "puppeteer", "mocha"
|
|
28
|
+
),
|
|
29
|
+
"infra": _devdocs("bash", "git", "docker", "sqlite", "postgresql", "terraform", "kubectl"),
|
|
30
|
+
}
|