INNER CODE UNIT · Python
validate_file
sameerasw/essentials · scripts/validate_strings.py:143
def validate_file(file_path, base_strings, auto_fix=False):
"""Validates a single strings.xml file."""
issues_found = []
file_modified = False
try:
with open(file_path, 'r', encoding='utf-8') as f:
lines = f.readlines()
content = "".join(lines)
except Exception as e:
return [f"Unable to read file: {e}"], False
# Check XML Syntax
try:
tree = ET.parse(file_path)
root = tree.getroot()
except ET.ParseError as pe:
line_num, col = pe.position if hasattr(pe, 'position') else (0, 0)