INNER CODE UNIT · Python
update_xml_attribute
jpush/jpush-react-native · .claude/skills/update-sdk/scripts/plugin_updater.py:146
def update_xml_attribute(file_path: str, attribute: str, new_version: str) -> bool:
"""Update a version attribute in an XML file (e.g., plugin.xml version="X.X.X")."""
path = Path(file_path)
if not path.exists():
print(f" WARNING: File not found: {file_path}")
return False
content = path.read_text(encoding="utf-8")
pattern = rf'({re.escape(attribute)}=")([^"]+)(")'
match = re.search(pattern, content)
if not match:
print(f" WARNING: Attribute '{attribute}' not found in {file_path}")
return False
old_version = match.group(2)
if old_version == new_version:
print(f" SKIP: {file_path} [{attribute}] already at {new_version}")
return True