diff options
author | Michael W <baddaemon87@gmail.com> | 2020-03-28 20:31:35 +0100 |
---|---|---|
committer | Michael W <baddaemon87@gmail.com> | 2020-03-28 20:33:01 +0100 |
commit | ba72bd55496ca21563a359499839377effc0bb1b (patch) | |
tree | 04757a6cd10fbd8fc116ba8fdbe8bf96991cdd0c | |
parent | da610ba942ebcd0f6c6a1bba4849246bfa6f364c (diff) | |
download | cm_crowdin-ba72bd55496ca21563a359499839377effc0bb1b.tar.gz cm_crowdin-ba72bd55496ca21563a359499839377effc0bb1b.tar.bz2 cm_crowdin-ba72bd55496ca21563a359499839377effc0bb1b.zip |
crowdin: Fix removing invalid product strings
* Removing items from a list while iterating it is not a good idea
and results in unexpected results
* Instead of removing them, add them to an ignore list and check the
current item against it
Change-Id: I6395f78d8ace3da6f5c443bdf12e4da9ae032026
-rwxr-xr-x | crowdin_sync.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crowdin_sync.py b/crowdin_sync.py index ba4a5fc..f64e1d4 100755 --- a/crowdin_sync.py +++ b/crowdin_sync.py @@ -152,8 +152,12 @@ def clean_xml_file(base_path, project_path, filename, repo): # Remove strings with 'product=*' attribute but no 'product=default' # This will ensure aapt2 will not throw an error when building these + alreadyRemoved = [] productStrings = tree.xpath("//string[@product]") for ps in productStrings: + # if we already removed the items, don't process them + if ps in alreadyRemoved: + continue stringName = ps.get('name') stringsWithSameName = tree.xpath("//string[@name='{0}']" .format(stringName)) @@ -173,7 +177,7 @@ def clean_xml_file(base_path, project_path, filename, repo): .format(path, stringName)) for string in stringsWithSameName: tree.remove(string) - productStrings.remove(string) + alreadyRemoved.append(string) header = '' comments = tree.xpath('//comment()') |