Skip to content

Commit

Permalink
add component_name argument
Browse files Browse the repository at this point in the history
  • Loading branch information
joergbuchwald committed Jul 4, 2024
1 parent 5bb9ac7 commit dee9e0a
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions ogs6py/classes/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def add_property(self, **args):
Parameters
----------
medium_id : `int` or `str`
phase_type : `str`
phase_type : `str` optional
component_name : `str`
name : `str`
type : `str`
value : `float` or `str`
Expand Down Expand Up @@ -212,9 +213,26 @@ def add_property(self, **args):
if phase is None:
phase = self.populate_tree(phases, "phase")
self.populate_tree(phase, "type", text=args['phase_type'])
properties = self.populate_tree(phase, "properties")
if "component_name" in args:
components = self.populate_tree(phase, "components")
component = self.populate_tree(components, "component")
self.populate_tree(component, "name", text=args['component_name'])
properties = self.populate_tree(component, "properties")
else:
properties = self.populate_tree(phase, "properties")
else:
properties = self.get_child_tag(phase, "properties")
if "component_name" in args:
components = self.get_child_tag(phase, "components")
if components is None:
components = self.populate_tree(phase, "components")
component = self.get_child_tag_for_type(components, "component",
args['component_name'], subtag="name")
if component is None:
component = self.populate_tree(components, "component")
self.populate_tree(component, "name", text=args['component_name'])
properties = self.populate_tree(component, "properties", overwrite=True)
else:
properties = self.get_child_tag(phase, "properties")
else:
properties = self.get_child_tag(medium, "properties")
if properties is None:
Expand Down

0 comments on commit dee9e0a

Please sign in to comment.