Skip to main content

review.coding.page

review.coding.page(root, directory)

Write the page of the next stage: coding-own.html or coding-final.html.

The first page is built from the run directories only: facts and evidence, the form, no proposal; nothing below proposals/ is read, so proposals may be written after the own answers. The second page is built only after answers-own.toml is taken in and committed, and only if every proposal passes check. It holds the runs that have a proposal. A page that exists must be the page that the files give.

Parameters

Name Type Description Default
root Path The project root. required
directory Path | str The review directory. required

Returns

Name Type Description
tuple[Paged | None, list[Problem]] tuple[Paged | None, list[Problem]]: The page and no problems, or None and the problems (a run changed, a proposal fails).

Raises

Name Type Description
ConfigurationError If the own answers are not committed, no run has a proposal (there is no second stage), both stages are taken in, a page file exists and is not the page that the files give, or the page would load an external resource or contain the absolute path of the project.

Examples

from pathlib import Path
from tempfile import TemporaryDirectory

from babregen import make_sample_repo
from babregen.review.coding import page, start

record = (
    'unit = "calc"\nprotocol = "score"\nstatus = "completed"\n'
    'accepted = false\n[base]\ncommit = "' + "a" * 40 + '"\n'
    "[[attempt]]\nn = 1\nwrote_module = false\n"
)
with TemporaryDirectory() as tmp:
    root = make_sample_repo(Path(tmp) / "demo")
    run = root / "regen" / "runs" / "rejected"
    run.mkdir(parents=True)
    (run / "run.toml").write_text(record)
    where = root / "regen" / "runs" / "coding"
    start(root, where, [run])
    done, problems = page(root, where)
    print(done.path.name, problems)
coding-own.html []