diff --git a/xml_tools/handlers/missing_strings.py b/xml_tools/handlers/missing_strings.py index fc850abf2..eba720515 100644 --- a/xml_tools/handlers/missing_strings.py +++ b/xml_tools/handlers/missing_strings.py @@ -21,9 +21,7 @@ def compare_and_update(source_path: Path, dest_path: Path, missing_path: Path) - # Parse source and destination files _, _, source_strings = XMLProcessor.parse_file(source_path) _, _, dest_strings = XMLProcessor.parse_file(dest_path) - _, _, missing_path_strings = ( - XMLProcessor.parse_file(missing_path) if missing_path.exists() else (None, None, {}) - ) + _, _, missing_path_strings = XMLProcessor.parse_file(missing_path) # Find missing strings missing_strings = {} diff --git a/xml_tools/utils/xml.py b/xml_tools/utils/xml.py index df79d73df..4d473fc8c 100644 --- a/xml_tools/utils/xml.py +++ b/xml_tools/utils/xml.py @@ -41,6 +41,9 @@ def parse_file(path: Path) -> Tuple[ET.ElementTree, ET.Element, Dict[str, Dict[s Note: Only elements with 'name' attributes are included in the returned dictionary. """ + if not path.exists() or path.stat().st_size < 2: + return None, None, {} + try: tree = ET.parse(path) root = tree.getroot()