diff --git a/src/xml_parser.py b/src/xml_parser.py index 43d8b9b..56d995e 100644 --- a/src/xml_parser.py +++ b/src/xml_parser.py @@ -1,10 +1,11 @@ import lxml.etree as ET from pathlib import Path import click +from datetime import datetime def write_xml_data(root: ET.Element, file_path: Path, pretty: bool = True) -> None: if file_path.exists(): - file_path.rename(file_path.with_suffix(".bak")) + file_path.rename(str(file_path) + f".{datetime.now().strftime('%Y-%m-%d.%H%M%S')}.bak") xml_str = ET.tostring(root, encoding="utf-8", xml_declaration=True, pretty_print=pretty) if pretty: # Parse the XML string to ensure proper indentation