parse_scene#

Import

from scenet import parse_scene

Defined in

scenet.frontends.yaml_front (source)

Install

pip install scenet

Since

0.1

Stability

Public: follows semantic versioning. Below 1.0, a minor release may change it, and the CHANGELOG says how.

scenet.frontends.yaml_front.parse_scene(text, *, source=None)[source]#

Parse a multi-panel document, resolving over inheritance.

A document with a top-level panels: mapping holds a sequence; anything else is treated as a single panel named “panel”, so the two forms share one entry point and a single-panel file needs no ceremony.

Panel order follows declaration order, which is reading order. page: and pages: are read and checked, but only the panels come back: see parse_scene_document.

Parameters:
  • text (str) – A panels: document.

  • source (Path | None) – Path the text came from, prefixed to every error message.

Return type:

dict[str, PanelIR]

Returns:

Panel name to scene graph, each with the chain of over it names already resolved.

Raises:
  • PanelSyntaxError – The document is malformed, or a panel does not validate.

  • CompositionError – An over: names a panel that does not exist, or the chain is a cycle.

Note

Pages are not read: parse_scene_document keeps them.

Example

>>> from scenet import parse_scene
>>> panels = parse_scene(
...     "panels: {wide: {cast: {a: {reference: alice}}}, close: {over: wide}}"
... )
>>> list(panels), list(panels["close"].cast)
(['wide', 'close'], ['a'])

See also

compile_scene, to compile it.