diff --git a/src/xml_parser.py b/src/xml_parser.py index 606059e..2c53423 100644 --- a/src/xml_parser.py +++ b/src/xml_parser.py @@ -1,6 +1,5 @@ import lxml.etree as ET from pathlib import Path -import click from models.savefile import SaveFile from lib import sanitize_name @@ -10,7 +9,7 @@ def write_xml_data(savefile: SaveFile) -> None: if not filename.parent.exists(): filename.parent.mkdir(parents=True, exist_ok=True) - root = _generate_xml_configuration() + root = _generate_xml_root() for code in savefile.conceptCodes: root = add_connection(root, code.name, code.attributes) @@ -72,7 +71,7 @@ def add_connection(root: ET.Element, name: str, attr_list: list[str], descriptio ET.SubElement(item, "SetParameter", Param="RootProperty", Source="FixedValue", Value="conceptCodes") return root -def _generate_xml_configuration() -> ET.Element: +def _generate_xml_root() -> ET.Element: """ Generate a default XML configuration for a PowerShell connector. @@ -95,23 +94,4 @@ def _generate_xml_configuration() -> ET.Element: ET.SubElement(command_sequence, "Item", Command="Initialize-CodeServer", Order="1") ET.SubElement(environment_initialization, "Disconnect") ET.SubElement(root, "Schema") - return root - -def get_xml_data(xml_file: Path) -> ET.Element: - """ - Get XML data from a file. If the file does not exist, generate a default configuration. - - Args: - xml_file (Path): The path to the XML file. - - Returns: - ET.Element: The root element of the XML configuration. - """ - if not xml_file.exists(): - return _generate_xml_configuration() - try: - parser = ET.XMLParser(strip_cdata=False) - tree = ET.parse(xml_file, parser=parser) - return tree - except ET.XMLSyntaxError as e: - raise click.FileError(xml_file, f"Not a valid XML file. {e}") \ No newline at end of file + return root \ No newline at end of file