Refactor: build_dir_xml() function

- rename for clarity
- remove unnecessary checks
This commit is contained in:
JKarasti 2024-09-23 22:12:40 +03:00 committed by jkarasti
parent cd9eafbd63
commit a78f0a7000

View file

@ -52,15 +52,13 @@ def build_data(base_path, path_prefix, dir_id, dir_name):
return data return data
def build_dir_xml(root, data): def build_directory_xml(root, data):
attrs = {} attrs = {}
if "id" in data: attrs["Id"] = data["directory_id"]
attrs["Id"] = data["directory_id"] attrs["Name"] = data["directory_name"]
if "name" in data: directory_el = ET.SubElement(root, "Directory", attrs)
attrs["Name"] = data["directory_name"]
el = ET.SubElement(root, "Directory", attrs)
for subdata in data["dirs"]: for subdata in data["dirs"]:
build_dir_xml(el, subdata) build_directory_xml(directory_el, subdata)
def build_components_xml(root, data): def build_components_xml(root, data):
@ -214,7 +212,7 @@ def main():
) )
# Create the directory structure for the installed product # Create the directory structure for the installed product
build_dir_xml(programfilesfolder_el, data) build_directory_xml(programfilesfolder_el, data)
# Create a component group for application components # Create a component group for application components
applicationcomponents_el = ET.SubElement( applicationcomponents_el = ET.SubElement(