cm_crowdin: Fix CAF commit creation
Change-Id: Ifdc1691ff7f8f73a53e88cd9f69e53fab770439b
diff --git a/cm_crowdin_sync.py b/cm_crowdin_sync.py
index a19d5b9..7cfda11 100755
--- a/cm_crowdin_sync.py
+++ b/cm_crowdin_sync.py
@@ -288,17 +288,11 @@
# Execute 'crowdin-cli download' and show output
print(subprocess.check_output(['crowdin-cli', "download"]))
-print('\nSTEP 4A: Clean up of source cm_caf.xmls')
-# Remove all cm_caf.xml files, which you can find in the list 'cm_caf'
-for cm_caf_file in cm_caf:
- print('Removing ' + cm_caf_file)
- os.remove(cm_caf_file)
-
-print('\nSTEP 4B: Clean up of temp dir')
+print('\nSTEP 4: Remove temp dir')
# We are done with cm_caf.xml files, so remove tmp/
shutil.rmtree(os.getcwd() + '/tmp')
-print('\nSTEP 4C: Clean up of empty translations')
+print('\nSTEP 5: Remove useless empty translations')
# Some line of code that I found to find all XML files
result = [os.path.join(dp, f) for dp, dn, filenames in os.walk(os.getcwd()) for f in filenames if os.path.splitext(f)[1] == '.xml']
for xml_file in result:
@@ -314,9 +308,18 @@
print('Removing ' + xml_file)
os.remove(xml_file)
-print('\nSTEP 5: Push translations to Git')
+print('\nSTEP 5: Create list of pushable translations')
# Get all files that Crowdin pushed
proc = subprocess.Popen(['crowdin-cli', 'list', 'sources'],stdout=subprocess.PIPE)
+print(subprocess.check_output(['crowdin-cli', 'list', 'sources'])) # seems to fix some problems when the above is executed
+
+print('\nSTEP 6: Remove unwanted source cm_caf.xmls')
+# Remove all cm_caf.xml files, which you can find in the list 'cm_caf'
+for cm_caf_file in cm_caf:
+ print('Removing ' + cm_caf_file)
+ os.remove(cm_caf_file)
+
+print('\nSTEP 7: Commit to Gerrit')
xml = minidom.parse('android/default.xml')
xml_extra = minidom.parse('extra_packages.xml')
items = xml.getElementsByTagName('project')
@@ -337,7 +340,7 @@
for project_item in items:
# We need to have the Github repository for the git push url.
# Obtain them from android/default.xml or extra_packages.xml.
- if project_item.attributes["path"].value == good_path:
+ if project_item.attributes['path'].value == good_path:
if project_item.hasAttribute('revision'):
branch = project_item.attributes['revision'].value
else:
@@ -345,4 +348,4 @@
print('Committing ' + project_item.attributes['name'].value + ' on branch ' + branch + ' (based on android/default.xml or extra_packages.xml)')
push_as_commit(good_path, project_item.attributes['name'].value, branch)
-print('\nSTEP 6: Done!')
+print('\nDone!')