load_script#
Import |
|
Defined in |
|
Install |
|
Since |
0.1 |
Stability |
Public: follows semantic versioning. Below 1.0, a minor release may change it, and the CHANGELOG says how. |
- scenet.frontends.script_front.load_script(path)[source]#
Read and validate a comic script from disk.
- Parameters:
path (
Path) – A*.scriptfile in the comic-script format writers already use.- Return type:
- Returns:
Panel name to scene graph, in the order the panels appear.
- Raises:
FileReadError – The file cannot be read: a
MissingFileError, also aFileNotFoundError, when it is not there.ScriptSyntaxError – The script cannot be parsed, a panel does not validate, or the file is not UTF-8.
Note
Only the script is read; files its front matter names are read when it is compiled.
Example
>>> from pathlib import Path >>> from tempfile import TemporaryDirectory >>> from scenet import load_script >>> with TemporaryDirectory() as folder: ... path = Path(folder) / "one.script" ... _ = path.write_text( ... "---\ncast: {ALICE: {reference: alice}}\n---\nPANEL 1\n\nALICE\nHi.\n", ... encoding="utf-8", ... ) ... panels = load_script(path) >>> len(panels) 1
See also
parse_script, for text.