crowdin: Improve empty resource file removal
* Instead of maintaining a list of all variants of empty resource tags,
just count the number of sub elements
* Equal to zero -> No child elements -> remove
Change-Id: I47deff72c943beffea8a1b0f1c190fcfd458d94a
diff --git a/crowdin_sync.py b/crowdin_sync.py
index 5e72454..a3f37ee 100755
--- a/crowdin_sync.py
+++ b/crowdin_sync.py
@@ -199,23 +199,10 @@
fh.close()
# Remove files which don't have any translated strings
- empty_contents = {
- '<resources/>',
- '<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"/>',
- ('<resources xmlns:android='
- '"http://schemas.android.com/apk/res/android"/>'),
- ('<resources xmlns:android="http://schemas.android.com/apk/res/android"'
- ' xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"/>'),
- ('<resources xmlns:tools="http://schemas.android.com/tools"'
- ' xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"/>'),
- '<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">\n</resources>',
- '<resources>\n</resources>'
- }
- for line in empty_contents:
- if line in content:
- print('Removing ' + path)
- os.remove(path)
- break
+ contentList = list(tree)
+ if len(contentList) == 0:
+ print('Removing ' + path)
+ os.remove(path)
def push_as_commit(config_files, base_path, path, name, branch, username):
print('Committing %s on branch %s' % (name, branch))