Skip to main content

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 legacy description read as content and the version’s needs_schema defaults merged under it.

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.

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.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ub-needs-exchange 1.1.0
File Size Uploaded Provenance Actions
ub_needs_exchange-1.1.0.tar.gz 7.7 kB Without provenance Details for ub_needs_exchange-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ub-needs-exchange 1.1.0
File Interpreter ABI Platform Actions
ub_needs_exchange-1.1.0-py3-none-any.whl Python 3 none any Details for ub_needs_exchange-1.1.0-py3-none-any.whl

Total release size: 16.6 kB

Release files / ub_needs_exchange-1.1.0.tar.gz

Download URL ub_needs_exchange-1.1.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
febf13174d3a562294155e22a890d4682c8d641ee1f0672bb281e7247f28c4d6
BLAKE2b-256 checksum
How to use checksums
e5e18a47127b537865122938df08c64fd125f31bf0165a4a08514897febedf96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.1.0-py3-none-any.whl

Download URL ub_needs_exchange-1.1.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e62dacbca79269f3932a58cdbeb8ce9796e0bf1b0a2bc0d7b7f100c7e38773f
BLAKE2b-256 checksum
How to use checksums
4ea022e27331970c7d3e6aeb856af7589c90310ed0c26b233363b24cca13c4ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.1.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page