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

Read, write, and modify parsed XML files into experiment definitions.
- attr_add(path: str, attr: str, value: str | int | float, noprint: bool = False) bool[source]#
Add the specified attribute to the element matching the specified path.
Only the FIRST element matching the specified path searching from the tree root is modified.
- Parameters:
path -- An expression uniquely identifying the element containing the attribute to add. The element must exist or an error will be raised.
attr -- An expression uniquely identifying the attribute to change within the enclosing element.
value -- The value to set the attribute to.
- attr_change(path: str, attr: str, value: str | int | float, noprint: bool = False) bool[source]#
Change the specified attribute of the element at the specified path.
Only the attribute of the FIRST element matching the specified path is changed.
- Parameters:
path -- An expression uniquely identifying the element containing the attribute to change. The element must exist or an error will be raised.
attr -- An expression uniquely identify the attribute to change within the enclosing element.
value -- The value to set the attribute to.
- attr_get(path: str, attr: str) str | int | float | None[source]#
Retrieve the specified attribute of the element at the specified path.
If it does not exist, None is returned.
- 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 the specified tag of the element matching the specified path.
- Parameters:
path -- An expression uniquely identifying the element containing the tag to change. The element must exist or an error will be raised.
tag -- An expression uniquely identifying the tag to change within the enclosing element.
value -- The value to set the tag to.
- element_remove(path: str, tag: str, noprint: bool = False) bool[source]#
Remove the first matching element in
pathmatchingtag.
- element_remove_all(path: str, tag: str, noprint: bool = False) bool[source]#
Remove the specified child tag(s) in the enclosing parent.
If more than one tag matches in the parent, all matching child tags are removed.
- Parameters:
path -- An expression uniquely identifying the element containing the tag(s) to remove. The element must exist or an error will be raised.
tag -- An expression uniquely identifying the tag to remove within the enclosing element.
- abstract flatten(keys: list[str]) None[source]#
Replace the specified filepath attributes with their contents.
Filepaths are interpreted relative to the directory in which the original experiment definition template resides, and assumed to be defined as such.
- has_attr(path: str, attr: str) bool[source]#
Determine if the attribute uniquely identified by
pathexists.
- write(base_opath: pathlib.Path) None[source]#
Write the definition stored in the object to the filesystem.
- 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/element are present in the input file.
- sierra.plugins.expdef.xml.plugin.unpickle(fpath: pathlib.Path) sierra.core.experiment.definition.AttrChangeSet | sierra.core.experiment.definition.ElementAddList | None[source]#
Unickle all XML modifications from the pickle file at the path.
You don't know how many there are, so go until you get an exception.