Skip to content

About

No description or website provided.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

SREF Reader

A Python library that reads and validates SREF (Structured Recipe Exchange Format) recipe JSON, .sref packages, and .srefbundle bundles, and converts amounts between registered units exactly. It does not write recipes; SREF Writer is the separate library for that.

Install

Python 3.10 or later. From the repository root:

python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install .

The only runtime dependency is jsonschema. The SREF schemas and unit registry ship inside the distribution, so no specification checkout is needed at runtime.

Example

import json
import sref_reader

recipe = sref_reader.read_recipe(
    json.dumps(
        {
            "sref": {"version": "0.4.0", "unit_registry": "0.2.0"},
            "id": "tea",
            "title": "Tea",
            "instruction_sections": [
                {
                    "id": "method",
                    "steps": [{"id": "steep", "text": "Steep the tea, then strain."}],
                }
            ],
        }
    ).encode("utf-8")
)
print(recipe["title"])

Documentation

  • Usage: reading, diagnostics, unit conversion, streaming bundles, and resource limits.
  • Development: checks, conformance, and testing the installed distribution.

Compatibility

__version__ and pyproject.toml version this library. SUPPORTED_FORMAT (0.4.0) and SUPPORTED_REGISTRY (0.2.0) name the SREF and unit-registry versions it implements. The three numbers are independent.

The vendored SREF snapshot is loaded through importlib.resources and checked against its manifest digests; altered bytes fail to load. Documents are checked against the schema and then against the semantic and archive rules the schema cannot express. A document from a compatible newer SREF version keeps its unrecognized members and extensions, and no meaning is invented for them.

Contributing

Every commit carries a Developer Certificate of Origin sign-off, created with git commit -s:

Signed-off-by: Your Name <your-email@example.com>

The sign-off certifies the statement at https://developercertificate.org/, and CI rejects a commit whose sign-off does not name its author.

Licence

MIT, in LICENSE.txt. The vendored schemas and registry data keep SREF's CC0 1.0 Universal dedication.

About

No description or website provided.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages