ub-needs-exchange
A library for the sphinx-needs family, which the extensions pull in – not a Sphinx extension, and nothing to add to conf.py.
It is the record of the needs.json exchange format: the file sphinx-needs’ needs builder writes, its needimport directive and needs_external_needs option read, and ubCode both writes and reads. It holds the part of that format more than one tool reads, so that it is read one way:
the envelope – the project, the current_version, the versions, and a format_version;
selecting a version – the one asked for, or the file’s current one;
the records – each keyed by its id, with the version’s needs_schema defaults merged under it, and the legacy description of a record with no content (as sphinx-needs wrote them before 4.0) read as its content.
It also holds the grammar of a need id, ub_needs_exchange.need_id: how nc::m2::REQ_1 splits at its last :: into the namespace nc::m2 and the local id REQ_1, with a conformance corpus of its own (tests/fixtures/need_id_conformance.toml).
Standard library only: no Sphinx, no docutils, no sibling distribution. A converter or a build action that runs without the documentation toolchain can use it.
Reading a file
from ub_needs_exchange import ExchangeError, load
try:
version = load("needs.json").select_version(None) # or a version's name
except ExchangeError as err:
err.code # what is wrong, e.g. "version_not_found"
err.message # for a person
else:
records = version.records()
for record in records:
record.key # the need's id
record.fields # its fields, schema defaults merged under them
version.diagnostics # findings about the version -- report them, or not
[d for r in records for d in r.diagnostics] # findings about each record
Every refusal is an ExchangeError whose code names the rule that was broken; every finding is a Diagnostic with a code, the path of what was found in the file, and a message.
A draft of the next format, "2a1", is read only on opt-in – select_version(None, drafts=("2a1",)) – and is experimental: it may change or be removed in any release (design/v2a1-draft.md).
Consumers decide the policy
This package decides nothing a consumer has reason to decide differently: which fields a project defines and which of a record’s keys it takes, the ids it accepts, the prefix it adds, how a record becomes a need, and whether a finding deserves a warning are each tool’s own.
The contract
design/exchange-contract.md is the normative specification, and tests/fixtures/needs_json_reading_conformance.toml is its executable half: a corpus of needs.json files and expected results that this package’s suite runs, and that ubCode is to vendor and run against its own readers.
Metadata
Release files for ub-needs-exchange 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ub_needs_exchange-1.2.0.tar.gz | 16.3 kB | Without provenance | Details for ub_needs_exchange-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ub_needs_exchange-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for ub_needs_exchange-1.2.0-py3-none-any.whl |
Total release size: 33.1 kB
Release files / ub_needs_exchange-1.2.0.tar.gz
| Download URL | ub_needs_exchange-1.2.0.tar.gz |
|---|---|
| Size | 16.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5ab53946b6bbbd88b9a2677f56688963981a8bc5fe2835208d07402bcd1451d
|
|
BLAKE2b-256 checksum How to use checksums |
dc9331062ca49b2d415dd709b5f65e9b1fb1a1d9d66be77ae034b40af09eacf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ub_needs_exchange-1.2.0-py3-none-any.whl
| Download URL | ub_needs_exchange-1.2.0-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e92a06455ec4c20ce43d8108856002dbc00c9b603d27f68e1a0b249737fa94a4
|
|
BLAKE2b-256 checksum How to use checksums |
ce043abedb71d73fc6dd84b8188ace4eb1a32baa66c42e3c2cac14520bb2f46f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for ub-needs-exchange 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.