load_puppet#

Import

from scenet import load_puppet

Defined in

scenet.assets.contract (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.assets.contract.load_puppet(path)[source]#

Read one *.puppet.yaml file into a validated specification.

Parameters:

path (Path) – The puppet file to read.

Return type:

PuppetSpec

Returns:

The validated puppet, ready to be posed.

Raises:
  • MalformedAssetError – The file is not UTF-8, not valid YAML – including a key written twice in one mapping – or not a mapping; or the mapping is not a well-formed puppet: an out-of-order landmark, a skeleton that is not a tree, a joint referring to a parent that does not exist. Also a ValueError.

  • FileReadError – The file cannot be read: a MissingFileError, also a FileNotFoundError, when it is not there.

Note

A puppet a document names by path is read by the compile instead, and a fault in it is located in the document as well.

Example

>>> from scenet import default_library, load_puppet
>>> from scenet.assets.contract import DEFAULT_LIBRARY_PATH
>>> alice = load_puppet(DEFAULT_LIBRARY_PATH / "alice.puppet.yaml")
>>> alice.name
'alice'
>>> round(alice.heads_tall, 1)
7.5

See also

PuppetLibrary.from_directory, to read a whole directory at once.