Skip to content

Commit

Permalink
Merge pull request #16 from caleb-sitton-inl/fix-create-compsets-hero…
Browse files Browse the repository at this point in the history
…n-function

Fixed function to create components node if missing
  • Loading branch information
GabrielSoto-INL authored Jun 24, 2024
2 parents 9f38fff + 5070b1d commit a7ab000
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/heron.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,27 @@

def create_componentsets_in_HERON(comp_sets_folder, heron_input_xml):
"""
Create/update components (componnet-sets) in HERON input file
Create/update components (component-sets) in HERON input file
@ In, comp_sets_folder, str, The path of the folder that includes several files of the user-input files
These user-input files determine the components which will be grouped together in one set
These user-input files determine the components which will be grouped together in one set
@ In, heron_input_xml, str, The path of the original HERON xml file at which components will be updated/created
@ Out, HERON_inp_tree, xml.etree.ElementTree.ElementTree, the updated HERON inut file (XML tree)
"""

HERON_inp_tree = ET.parse(heron_input_xml)
components_list = HERON_inp_tree.findall("Components") # The "components" node
# if the "components" node is not found
if not components_list:
print("\n", f"The 'Components' node is not found in the HERON input xml file: {heron_input_xml}")
else:
for components in components_list:
component = components.findall("Component")
heron_comp_list = [] # The list of compoenents
for comp in component:
heron_comp_list.append(comp.attrib["name"]) # The list of components found in the HERON input XML file
# print(f" \n The following components are already in the HERON input XML file:'{heron_comp_list}'")

print("\n", f"The 'Components' node is not found in the HERON input xml file {heron_input_xml} and a new 'Components' node is created")
new_comps_node = ET.SubElement(HERON_inp_tree.getroot(), 'Components')
components_list = [new_comps_node]

for components in components_list:
component = components.findall("Component")
heron_comp_list = [] # The list of components
for comp in component:
heron_comp_list.append(comp.attrib["name"]) # The list of components found in the HERON input XML file

comp_set_files_list = os.listdir(comp_sets_folder)

# Goin through the FORCE componentSets to extract relevant info
Expand Down

0 comments on commit a7ab000

Please sign in to comment.