Skip to main content

review.formats.load

review.formats.load(path, kind)

Read a review file strictly.

Parameters

Name Type Description Default
path Path The file. required
kind str One of KINDS. required

Returns

Name Type Description
dict[str, object] dict[str, object]: The parsed file, format included.

Raises

Name Type Description
ConfigurationError If the file is missing or not TOML, has no format or another format number than FORMAT, or fails validate.

Examples

from pathlib import Path
from tempfile import TemporaryDirectory

from babregen.review.formats import dump, load

data = {"run": "x", "checked_by": "fixture-rater", "proposal_sha256": "0" * 64,
        "agrees": True, "category": "generator error", "comment": "ok"}
with TemporaryDirectory() as tmp:
    path = Path(tmp) / "x.check.toml"
    path.write_text(dump("proposal-check", data), encoding="utf-8")
    print(load(path, "proposal-check")["agrees"])
True