inventory_to_yaml

function of dascore.core.inventory source

inventory_to_yaml(
    inventory: Inventory ,
    path: str | pathlib._local.Path | None[str, Path, None] = None,
)-> ‘str’

Serialize an inventory to YAML, optionally writing it to a path.

Reached as inventory.io.to_yaml.

A field still holding its default is left out, so the document states what the inventory says rather than every field it has; what is written reloads equal to this inventory.

Parameters

Parameter Description
inventory The inventory to serialize.
path Where to write the text, or None to only return it.

Examples

import dascore as dc
_, inventory = dc.examples.inventory_patch_pair()
# Writing YAML needs pyyaml, which is not a core dependency.
text = inventory.io.to_yaml()  # doctest: +SKIP
dc.inventory(text) == inventory  # doctest: +SKIP
True