compile_book_file#
Import |
|
Defined in |
|
Install |
|
Since |
0.10 |
Stability |
Public: follows semantic versioning. Below 1.0, a minor release may change it, and the CHANGELOG says how. |
- scenet.pipeline.compile_book_file(path, *, library=None, metrics=None, dependencies=None)[source]#
Compile any supported document and its pages, choosing the frontend by extension.
- Parameters:
path (
Path) – A*.panel.yaml,*.scene.yamlor*.scriptfile.library (
PuppetLibrary|None) – Characters to draw from. Defaults to the two shipped puppets.metrics (
FontMetrics|None) – Font to measure lettering against.dependencies (
set[Path] |None) – Optional set to populate with paths read during compilation, each resolved.
- Return type:
- Returns:
Every panel, and the pages they are laid out on – none for a single panel or a comic script.
- Raises:
SourceError – The extension is not one any frontend reads.
FileReadError – The file cannot be read: a
MissingFileError, also aFileNotFoundError, when it is not there.PanelSyntaxError – The document – a
ScriptSyntaxErrorfor a script – is malformed or invalid, or a file it names cannot be read or is not what it says.CompositionError – An
over:names a panel that does not exist, or the chain is a cycle.UnknownPuppetError – A cast member references a puppet the library lacks.
UnknownPoseError – A cast member’s
poseis one its puppet does not declare.UnknownExpressionError – A cast member’s
expressionis one its puppet does not declare.LayoutError – The staging cannot be satisfied: a depth order that is a cycle, or a panel with no cast to place.
BalloonPlacementError – A balloon or a caption has no legal position.
SfxPlacementError – A sound effect has no legal position.
Note
The frontend is chosen by extension alone:
.scriptis a comic script, and any.yamlor.ymla panel or a scene by what it holds. This is whatscenet buildcalls.Example
>>> from pathlib import Path >>> from tempfile import TemporaryDirectory >>> from scenet import compile_book_file >>> with TemporaryDirectory() as folder: ... path = Path(folder) / "page.scene.yaml" ... _ = path.write_text( ... "cast: {a: {reference: alice}}\n" ... "panels: {one: {}, two: {}}\n" ... "pages: [{tiers: [{panels: [one, two]}]}]", ... encoding="utf-8", ... ) ... read = set() ... book = compile_book_file(path, dependencies=read) >>> list(book.panels), len(book.pages) (['one', 'two'], 1) >>> path.resolve() in read True
See also
compile_book, for text.compile_document, for its panels alone.Added in version 0.13: The
dependenciesparameter.