sierra.core.experiment.xml

Helper classes for XML experiment definitions.

Adding/removing tags, modifying attributes, configuration for how to write XML files.

class sierra.core.experiment.xml.AttrChange(path: str, attr: str, value: Union[str, int, float])[source]

Specification for a change to an existing XML attribute.

Inheritance

Inheritance diagram of AttrChange
__dict__ = mappingproxy({'__module__': 'sierra.core.experiment.xml', '__doc__': '\n    Specification for a change to an existing XML attribute.\n    ', '__init__': <function AttrChange.__init__>, '__iter__': <function AttrChange.__iter__>, '__repr__': <function AttrChange.__repr__>, '__dict__': <attribute '__dict__' of 'AttrChange' objects>, '__weakref__': <attribute '__weakref__' of 'AttrChange' objects>, '__annotations__': {}})
__doc__ = '\n    Specification for a change to an existing XML attribute.\n    '
__init__(path: str, attr: str, value: Union[str, int, float]) None[source]
__iter__()[source]
__module__ = 'sierra.core.experiment.xml'
__repr__() str[source]

Return repr(self).

__weakref__

list of weak references to the object (if defined)

class sierra.core.experiment.xml.AttrChangeSet(*args: AttrChange)[source]

Data structure for AttrChange objects.

The order in which attributes are changed doesn’t matter from the standpoint of correctness (i.e., different orders won’t cause crashes).

Inheritance

Inheritance diagram of AttrChangeSet
__dict__ = mappingproxy({'__module__': 'sierra.core.experiment.xml', '__doc__': "\n    Data structure for :class:`AttrChange` objects.\n\n    The order in which attributes are changed doesn't matter from the standpoint\n    of correctness (i.e., different orders won't cause crashes).\n\n    ", 'unpickle': <staticmethod object>, '__init__': <function AttrChangeSet.__init__>, '__len__': <function AttrChangeSet.__len__>, '__iter__': <function AttrChangeSet.__iter__>, '__ior__': <function AttrChangeSet.__ior__>, '__or__': <function AttrChangeSet.__or__>, '__repr__': <function AttrChangeSet.__repr__>, 'add': <function AttrChangeSet.add>, 'pickle': <function AttrChangeSet.pickle>, '__dict__': <attribute '__dict__' of 'AttrChangeSet' objects>, '__weakref__': <attribute '__weakref__' of 'AttrChangeSet' objects>, '__annotations__': {}})
__doc__ = "\n    Data structure for :class:`AttrChange` objects.\n\n    The order in which attributes are changed doesn't matter from the standpoint\n    of correctness (i.e., different orders won't cause crashes).\n\n    "
__init__(*args: AttrChange) None[source]
__ior__(other: AttrChangeSet) AttrChangeSet[source]
__iter__() Iterator[AttrChange][source]
__len__() int[source]
__module__ = 'sierra.core.experiment.xml'
__or__(other: AttrChangeSet) AttrChangeSet[source]
__repr__() str[source]

Return repr(self).

__weakref__

list of weak references to the object (if defined)

add(chg: AttrChange) None[source]
pickle(fpath: Path, delete: bool = False) None[source]
static unpickle(fpath: Path) AttrChangeSet[source]

Unpickle XML changes.

You don’t know how many there are, so go until you get an exception.

class sierra.core.experiment.xml.TagAdd(path: str, tag: str, attr: Dict[str, str], allow_dup: bool)[source]

Specification for adding a new XML tag.

The tag may be added idempotently, or duplicates can be allowed.

Inheritance

Inheritance diagram of TagAdd
__dict__ = mappingproxy({'__module__': 'sierra.core.experiment.xml', '__doc__': '\n    Specification for adding a new XML tag.\n\n    The tag may be added idempotently, or duplicates can be allowed.\n    ', 'as_root': <staticmethod object>, '__init__': <function TagAdd.__init__>, '__iter__': <function TagAdd.__iter__>, '__repr__': <function TagAdd.__repr__>, '__dict__': <attribute '__dict__' of 'TagAdd' objects>, '__weakref__': <attribute '__weakref__' of 'TagAdd' objects>, '__annotations__': {}})
__doc__ = '\n    Specification for adding a new XML tag.\n\n    The tag may be added idempotently, or duplicates can be allowed.\n    '
__init__(path: str, tag: str, attr: Dict[str, str], allow_dup: bool)[source]

Init the object.

Parameters:
  • path – The path to the parent tag you want to add a new tag under, in XPath syntax. If None, then the tag will be added as the root XML tag.

  • tag – The name of the tag to add.

  • attr – A dictionary of (attribute, value) pairs to also create as children of the new tag when creating the new tag.

__iter__()[source]
__module__ = 'sierra.core.experiment.xml'
__repr__() str[source]

Return repr(self).

__weakref__

list of weak references to the object (if defined)

static as_root(tag: str, attr: Dict[str, str]) TagAdd[source]
class sierra.core.experiment.xml.TagAddList(*args: TagAdd)[source]

Data structure for TagAdd objects.

The order in which tags are added matters (i.e., if you add dependent tags in the wrong order you will get an exception), hence the list representation.

Inheritance

Inheritance diagram of TagAddList
__dict__ = mappingproxy({'__module__': 'sierra.core.experiment.xml', '__doc__': '\n    Data structure for :class:`TagAdd` objects.\n\n    The order in which tags are added matters (i.e., if you add dependent tags\n    in the wrong order you will get an exception), hence the list\n    representation.\n    ', 'unpickle': <staticmethod object>, '__init__': <function TagAddList.__init__>, '__len__': <function TagAddList.__len__>, '__iter__': <function TagAddList.__iter__>, '__repr__': <function TagAddList.__repr__>, 'extend': <function TagAddList.extend>, 'append': <function TagAddList.append>, 'prepend': <function TagAddList.prepend>, 'pickle': <function TagAddList.pickle>, '__dict__': <attribute '__dict__' of 'TagAddList' objects>, '__weakref__': <attribute '__weakref__' of 'TagAddList' objects>, '__annotations__': {}})
__doc__ = '\n    Data structure for :class:`TagAdd` objects.\n\n    The order in which tags are added matters (i.e., if you add dependent tags\n    in the wrong order you will get an exception), hence the list\n    representation.\n    '
__init__(*args: TagAdd) None[source]
__iter__() Iterator[TagAdd][source]
__len__() int[source]
__module__ = 'sierra.core.experiment.xml'
__repr__() str[source]

Return repr(self).

__weakref__

list of weak references to the object (if defined)

append(other: TagAdd) None[source]
extend(other: TagAddList) None[source]
pickle(fpath: Path, delete: bool = False) None[source]
prepend(other: TagAdd) None[source]
static unpickle(fpath: Path) Optional[TagAddList][source]

Unpickle XML modifications.

You don’t know how many there are, so go until you get an exception.

class sierra.core.experiment.xml.TagRm(path: str, tag: str)[source]

Specification for removal of an existing XML tag.

Inheritance

Inheritance diagram of TagRm
__dict__ = mappingproxy({'__module__': 'sierra.core.experiment.xml', '__doc__': '\n    Specification for removal of an existing XML tag.\n    ', '__init__': <function TagRm.__init__>, '__iter__': <function TagRm.__iter__>, '__repr__': <function TagRm.__repr__>, '__dict__': <attribute '__dict__' of 'TagRm' objects>, '__weakref__': <attribute '__weakref__' of 'TagRm' objects>, '__annotations__': {}})
__doc__ = '\n    Specification for removal of an existing XML tag.\n    '
__init__(path: str, tag: str)[source]

Init the object.

Parameters:
  • path – The path to the parent of the tag you want to remove, in XPath syntax.

  • tag – The name of the tag to remove.

__iter__()[source]
__module__ = 'sierra.core.experiment.xml'
__repr__() str[source]

Return repr(self).

__weakref__

list of weak references to the object (if defined)

class sierra.core.experiment.xml.TagRmList(*args: TagRm)[source]

Data structure for TagRm objects.

The order in which tags are removed matters (i.e., if you remove dependent tags in the wrong order you will get an exception), hence the list representation.

Inheritance

Inheritance diagram of TagRmList
__dict__ = mappingproxy({'__module__': 'sierra.core.experiment.xml', '__doc__': '\n    Data structure for :class:`TagRm` objects.\n\n    The order in which tags are removed matters (i.e., if you remove dependent\n    tags in the wrong order you will get an exception), hence the list\n    representation.\n\n    ', '__init__': <function TagRmList.__init__>, '__len__': <function TagRmList.__len__>, '__iter__': <function TagRmList.__iter__>, '__repr__': <function TagRmList.__repr__>, 'extend': <function TagRmList.extend>, 'append': <function TagRmList.append>, 'pickle': <function TagRmList.pickle>, '__dict__': <attribute '__dict__' of 'TagRmList' objects>, '__weakref__': <attribute '__weakref__' of 'TagRmList' objects>, '__annotations__': {}})
__doc__ = '\n    Data structure for :class:`TagRm` objects.\n\n    The order in which tags are removed matters (i.e., if you remove dependent\n    tags in the wrong order you will get an exception), hence the list\n    representation.\n\n    '
__init__(*args: TagRm) None[source]
__iter__() Iterator[TagRm][source]
__len__() int[source]
__module__ = 'sierra.core.experiment.xml'
__repr__() str[source]

Return repr(self).

__weakref__

list of weak references to the object (if defined)

append(other: TagRm) None[source]
extend(other: TagRmList) None[source]
pickle(fpath: Path, delete: bool = False) None[source]
class sierra.core.experiment.xml.WriterConfig(values: List[dict])[source]

Config for writing XMLExpDef.

Different parts of the XML tree can be written to multiple XML files.

values

Dict with the following possible key, value pairs:

src_parent - The parent of the root of the XML tree

specifying a sub-tree to write out as a child of dest_root. This key is required.

src_tag - The name of the tag within src_parent to write

out. This key is required.

dest_parent - The new name of src_root when writing out

the partial XML tree to a new file. This key is optional.

create_tags - Additional tags to create under

dest_parent. Must form a tree with a single root.

opath_leaf - Additional bits added to whatever the opath

file stem that is set for the XMLExpDef instance. This key is optional. Can be used to add an extension.

child_grafts - Additional bits of the XML tree to add under

the new dest_root/src_tag, specified as a list of XPath strings. You can’t just have multiple src_roots because that makes unambiguous renaming of src_root -> dest_root impossible. This key is optional.

Inheritance

Inheritance diagram of WriterConfig
__dict__ = mappingproxy({'__module__': 'sierra.core.experiment.xml', '__doc__': "Config for writing :class:`~sierra.core.experiment.definition.XMLExpDef`.\n\n    Different parts of the XML tree can be written to multiple XML files.\n\n    Attributes:\n\n        values: Dict with the following possible key, value pairs:\n\n                ``src_parent`` - The parent of the root of the XML tree\n                                 specifying a sub-tree to write out as a child\n                                 of ``dest_root``. This key is required.\n\n                ``src_tag`` - The name of the tag within ``src_parent`` to write\n                              out. This key is required.\n\n                ``dest_parent`` - The new name of ``src_root`` when writing out\n                                  the partial XML tree to a new file. This key\n                                  is optional.\n\n                ``create_tags`` - Additional tags to create under\n                                  ``dest_parent``. Must form a tree with a\n                                  single root.\n\n                ``opath_leaf`` - Additional bits added to whatever the opath\n                                 file stem that is set for the\n                                 :class:`~sierra.core.experiment.definition.XMLExpDef`\n                                 instance. This key is optional. Can be used to\n                                 add an extension.\n\n                ``child_grafts`` - Additional bits of the XML tree to add under\n                                   the new ``dest_root/src_tag``, specified as a\n                                   list of XPath strings. You can't just have\n                                   multiple src_roots because that makes\n                                   unambiguous renaming of ``src_root`` ->\n                                   ``dest_root`` impossible. This key is\n                                   optional.\n\n    ", '__init__': <function WriterConfig.__init__>, 'add': <function WriterConfig.add>, '__dict__': <attribute '__dict__' of 'WriterConfig' objects>, '__weakref__': <attribute '__weakref__' of 'WriterConfig' objects>, '__annotations__': {}})
__doc__ = "Config for writing :class:`~sierra.core.experiment.definition.XMLExpDef`.\n\n    Different parts of the XML tree can be written to multiple XML files.\n\n    Attributes:\n\n        values: Dict with the following possible key, value pairs:\n\n                ``src_parent`` - The parent of the root of the XML tree\n                                 specifying a sub-tree to write out as a child\n                                 of ``dest_root``. This key is required.\n\n                ``src_tag`` - The name of the tag within ``src_parent`` to write\n                              out. This key is required.\n\n                ``dest_parent`` - The new name of ``src_root`` when writing out\n                                  the partial XML tree to a new file. This key\n                                  is optional.\n\n                ``create_tags`` - Additional tags to create under\n                                  ``dest_parent``. Must form a tree with a\n                                  single root.\n\n                ``opath_leaf`` - Additional bits added to whatever the opath\n                                 file stem that is set for the\n                                 :class:`~sierra.core.experiment.definition.XMLExpDef`\n                                 instance. This key is optional. Can be used to\n                                 add an extension.\n\n                ``child_grafts`` - Additional bits of the XML tree to add under\n                                   the new ``dest_root/src_tag``, specified as a\n                                   list of XPath strings. You can't just have\n                                   multiple src_roots because that makes\n                                   unambiguous renaming of ``src_root`` ->\n                                   ``dest_root`` impossible. This key is\n                                   optional.\n\n    "
__init__(values: List[dict]) None[source]
__module__ = 'sierra.core.experiment.xml'
__weakref__

list of weak references to the object (if defined)

add(value: dict) None[source]