Skip to main content

review.page.page_sha256

review.page.page_sha256(spec)

The hash of a page: SHA-256 of the canonical JSON of its data.

The data holds the hash of the visible markup, the questions and the export table, so the hash covers everything the page shows. An export carries it as page_sha256, and the intake rebuilds the page to compare.

Parameters

Name Type Description Default
spec PageSpec The page. required

Returns

Name Type Description
str str 64 hex digits.

Raises

Name Type Description
ConfigurationError If the spec is inconsistent.

Examples

from babregen.review.page import (
    Column, Item, PageSpec, Question, page_sha256,
)
from babregen.review.vocab import VERDICTS

spec = PageSpec(
    title="Demo", items=(Item("a", "A", consts={"unit": "u", "id": "M1"}),),
    questions=(Question("verdict", "Verdict", choices=VERDICTS),
               Question("reason", "Reason", kind="line")),
    start_key="shown_at", save_key="rated_at",
    kind="gate-verdicts", file_prefix="demo",
    top=(Column("format", "const", value=1),
         Column("rater", "const", value="fixture-rater"),
         Column("written_at", "meta", "exported_at")),
    columns=(Column("unit", "item"), Column("id", "item"),
             Column("verdict", "state"), Column("reason", "state"),
             Column("drawn", "const", value=False)),
)
print(len(page_sha256(spec)))
64