Skip to content

Instantly share code, notes, and snippets.

@patrickhammond
Created December 2, 2015 15:41
Show Gist options
  • Save patrickhammond/1742866c090b1d85d336 to your computer and use it in GitHub Desktop.
Save patrickhammond/1742866c090b1d85d336 to your computer and use it in GitHub Desktop.
Finds duplicate string values in an Android strings.xml file.
#!/usr/bin/python
import sys
import xml.etree.ElementTree
import collections
xmlFile = sys.argv[1]
strings = collections.Counter()
root = xml.etree.ElementTree.parse(xmlFile).getroot()
for string in root.findall('string'):
text = string.text
name = string.get('name')
if strings[text] == 0:
strings[text] = name
else:
print(name + " has the same value as " + strings[text])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment