an.project#

Project init/load/save — the on-disk anatomy of an an project.

Layout (from spec §11):

my-scene/ ├── an.toml ├── scene.md ├── ir/scene.json ├── assets/{characters,props,environments,voices,styles,sounds}/ ├── artifacts/{audio,visemes,shots,previews}/ ├── output/ └── .an/{decisions.jsonl,verifier_runs/,memory.md}

Module Attributes

RENDER_REPORTS_GITIGNORE

A render report records what a render on THIS machine found — warnings, exception text — so it is per-machine output, not project source (an#254).

PROBES_GITIGNORE

Probe frames and contact sheets (an probe, an library sheet, an#347): looks at work in progress, which may show private-study material.

LOCKS_GITIGNORE

The file locks an options manifest's writers take (<ref>.json.lock, an#587): empty, per machine, never project source.

PROJECT_GITIGNORE

What a project's .gitignore keeps out of version control (an init adds each line a .gitignore lacks, never removing one).

Functions

gitignore_matcher([lines])

rel -> bool: whether any of lines (each a .gitignore line) covers the project-relative POSIX path rel, by git's rules (an#725): a line with a / before its end is anchored at the project root, one without matches a name at any depth; a trailing / matches folders only; wildcards never cross a /; a matched folder covers everything under it; case counts.

gitignored(rel, *[, lines])

Whether a project's .gitignore keeps rel (a project-relative POSIX path) local: PROJECT_GITIGNORE, or lines, read by git's rules (gitignore_matcher(), an#725).

init(project_dir, *[, name, force])

Create a fresh an project at project_dir.

keep_out_of_git(pdir, lines)

Add lines to an OLDER project's .gitignore (an an init from before they existed left them out) — conservatively: never a line whose folder the file already says anything about (a project may have chosen to commit its reports, !artifacts/render_reports/), never through a symlink (a shared ignore file), and never creating a .gitignore in a project that is not in a git work tree.

keep_reports_out_of_git(pdir)

Add RENDER_REPORTS_GITIGNORE to an older project's .gitignore the first time a render writes a report (an#309), by keep_out_of_git()'s rules.

load(project_dir, *[, check_kinds, ...])

Load an existing project.

save(project)

Persist a Project's current scene back to disk (md + json).

Classes

Project(root, mall, scene)

A loaded an project: directory + mall + current scene.

an.project.LOCKS_GITIGNORE: tuple[str, ...] = ('artifacts/voice_options/*.lock',)#

The file locks an options manifest’s writers take (<ref>.json.lock, an#587): empty, per machine, never project source.

an.project.PROBES_GITIGNORE: tuple[str, ...] = ('artifacts/probes/',)#

Probe frames and contact sheets (an probe, an library sheet, an#347): looks at work in progress, which may show private-study material.

an.project.PROJECT_GITIGNORE: tuple[str, ...] = ('artifacts/render_reports/', 'artifacts/probes/', 'artifacts/voice_options/*.lock')#

What a project’s .gitignore keeps out of version control (an init adds each line a .gitignore lacks, never removing one).

class an.project.Project(root, mall, scene)[source]#

Bases: object

A loaded an project: directory + mall + current scene.

an.project.RENDER_REPORTS_GITIGNORE: tuple[str, ...] = ('artifacts/render_reports/',)#

A render report records what a render on THIS machine found — warnings, exception text — so it is per-machine output, not project source (an#254).

an.project.gitignore_matcher(lines=('artifacts/render_reports/', 'artifacts/probes/', 'artifacts/voice_options/*.lock'))[source]#

rel -> bool: whether any of lines (each a .gitignore line) covers the project-relative POSIX path rel, by git’s rules (an#725): a line with a / before its end is anchored at the project root, one without matches a name at any depth; a trailing / matches folders only; wildcards never cross a /; a matched folder covers everything under it; case counts. A facade over dol.gitignore_matcher() (an#800), byte-exact against git check-ignore. What it does not read the way git does is refused with a ValueError rather than misread (a misread line could copy what it should keep local): negation (!), comments (#), **, escapes (\), [^...], POSIX classes ([:alpha:]), //, an unterminated or malformed [...], surrounding spaces and empty lines; so is a rel that is not a plain project-relative POSIX path (a backslash, ./, ..). Case always counts, as git’s does with core.ignorecase=false (on macOS git ignores case by default). For a genre or tool that copies a project (a sync, an export) and keeps the same files local as git.

>>> local = gitignore_matcher(("artifacts/shot_cache/", "notes.txt", "artifacts/v/*.lock"))
>>> local("artifacts/shot_cache/blobs/x"), local("deep/notes.txt"), local("artifacts/audio/a.wav")
(True, True, False)
>>> local("artifacts/v/a.json.lock"), local("artifacts/v/sub/a.lock")
(True, False)
>>> gitignore_matcher(("cache/",))("cache"), gitignore_matcher(("a/*/c",))("a/b/c/d")
(False, True)
Return type:

Callable[[str], bool]

an.project.gitignored(rel, *, lines=('artifacts/render_reports/', 'artifacts/probes/', 'artifacts/voice_options/*.lock'))[source]#

Whether a project’s .gitignore keeps rel (a project-relative POSIX path) local: PROJECT_GITIGNORE, or lines, read by git’s rules (gitignore_matcher(), an#725).

>>> gitignored("artifacts/probes/shot1/frame.png"), gitignored("scene.md")
(True, False)
>>> gitignored("artifacts/voice_options/jerry.json.lock")
True
Return type:

bool

an.project.init(project_dir, *, name=None, force=False)[source]#

Create a fresh an project at project_dir.

Idempotent unless the directory already contains a non-empty scene.md; pass force=True to overwrite. Returns the absolute project root. The project’s .gitignore gains PROJECT_GITIGNORE (lines it lacks).

Return type:

Path

an.project.keep_out_of_git(pdir, lines)[source]#

Add lines to an OLDER project’s .gitignore (an an init from before they existed left them out) — conservatively: never a line whose folder the file already says anything about (a project may have chosen to commit its reports, !artifacts/render_reports/), never through a symlink (a shared ignore file), and never creating a .gitignore in a project that is not in a git work tree.

Return type:

None

an.project.keep_reports_out_of_git(pdir)[source]#

Add RENDER_REPORTS_GITIGNORE to an older project’s .gitignore the first time a render writes a report (an#309), by keep_out_of_git()’s rules.

Return type:

None

an.project.load(project_dir, *, check_kinds=True, scene_file='scene.md', sync=True)[source]#

Load an existing project. Reconciles scene.md / ir/scene.json first (unless sync=False).

sync=False is the read-only load (an#573): the scene is read past a stale pair with an.ir.sync.read_scene() and nothing is written to the scene files; project.mall["scenes"] is then a read-only view of that scene. For commands that only look (an cache info, an cache gc, credits, world show). an validate keeps syncing: it reports the sync’s own warnings (a tie that disagrees) as findings, which this path does not emit.

scene_file names another scene of the project (scene.studio.md, its JSON twin ir/scene.studio.json, an#539; resolved by an.ir.sync.resolve_scene_file(), so a bad or missing one raises SceneFileError); the assets are the project’s.

Registers the installed genres first (an.genres.load(), ADR 0001 decision 3: discovery is explicit, and loading a project is one of the places it happens), so the scene’s genre kinds — the cut-out genre’s play, expression and character — read as their own models.

Then refuses a scene that names an action kind, entity kind or renderer nothing registered (an.ir.validate.require_registered_kinds()): the schema holds those as str (ADR 0001 decision 2), so without this a typo’d kind: enviroment would load and render silently without its backdrop. check_kinds=False is for an validate, which reports them as findings instead.

Return type:

Project

an.project.save(project)[source]#

Persist a Project’s current scene back to disk (md + json).

Return type:

None