Skip to content

Commit

Permalink
Fixed function to create components node if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb-sitton-inl committed Jun 20, 2024
1 parent 9f38fff commit be84894
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/heron.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,18 @@ def create_componentsets_in_HERON(comp_sets_folder, heron_input_xml):

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
# print(f" \n The following components are already in the HERON input XML file:'{heron_comp_list}'")

comp_set_files_list = os.listdir(comp_sets_folder)

Expand Down

0 comments on commit be84894

Please sign in to comment.