ogstools.ogs6py.build_tree module#

class ogstools.ogs6py.build_tree.BuildTree[source]#

Bases: object

Helper class to create a nested dictionary representing the xml structure.

__init__(tree)[source]#
static populate_tree(parent, tag, text=None, attr=None, overwrite=False)[source]#

Add an element to the xml tree.

Parameters:
  • parent (Element) – Parent of the new element.

  • tag (str) – Tag of the new element.

  • text (Any | list | dict | None) – Text / value of the new element. If given a dict, the key and value pairs will create corresponding subelements.

  • attr (dict[str, str] | None) – Attributes of the new element.

  • overwrite (bool) – If True, overrides the last child of parent with a matching tag.

Return type:

Element

static find_or_populate(parent, tag)[source]#

Find an existing tag in parent or create it.

Return type:

Element

static get_child_tag(parent, tag, attr=None, attr_val=None)[source]#

Search for child tag based on tag and possible attributes-

Return type:

Element

static get_child_tag_for_type(parent, tag, subtagval, subtag='type')[source]#

Search for child tag based on subtag type.

Return type:

Element