sierra.plugins.expdef.yaml.plugin#
Plugin for parsing and manipulating template input files in YAML format.
Classes#
Read, write, and modify parsed YAML files into experiment definitions. |
Functions#
|
Unpickle all YAML modifications from the pickle file at the path. |
Module Contents#
- class sierra.plugins.expdef.yaml.plugin.ExpDef(input_fpath: pathlib.Path, write_config: sierra.core.experiment.definition.WriterConfig | None = None)[source]#

Read, write, and modify parsed YAML files into experiment definitions.
- attr_add(path: str, attr: str, value: str | int | float, noprint: bool = False) bool[source]#
Add a new attribute at the specified path. At most 1 attribute is added.
- attr_change(path: str, attr: str, value: str | int | float, noprint: bool = False) bool[source]#
Change an attribute value at the specified path.
All matching paths are modified.
- attr_get(path: str, attr: str) str | int | float | None[source]#
Get an attribute value at the specified path.
- element_add(path: str, tag: str, attr: sierra.core.types.StrDict | None = None, allow_dup: bool = True, noprint: bool = False) bool[source]#
Add tag name as a child element of enclosing parent.
- element_change(path: str, tag: str, value: str) bool[source]#
Change an element tag at the specified path.
This isn't well-defined in YAML. What effectively happens is that the subtree pointed to by
pathis re-added to the parent under the tagvalue, and the original subtree deleted.
- element_remove(path: str, tag: str, noprint: bool = False) bool[source]#
Remove an element at the specified path.
- element_remove_all(path: str, tag: str, noprint: bool = False) bool[source]#
Remove all matching elements at the specified path.
- n_mods() tuple[int, int][source]#
Return the number of modifications (element adds, attribute changes).
- write(base_opath: pathlib.Path) None[source]#
Write the modified YAML tree to disk.
- write_config_set(config: sierra.core.experiment.definition.WriterConfig) None[source]#
Set the write config for the object.
Provided for cases in which the configuration is dependent on whether or not certain tags are present in the input file.
- sierra.plugins.expdef.yaml.plugin.unpickle(fpath: pathlib.Path) sierra.core.experiment.definition.AttrChangeSet | sierra.core.experiment.definition.ElementAddList | None[source]#
Unpickle all YAML modifications from the pickle file at the path.
You don't know how many there are, so go until you get an exception.