summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2020-03-22 18:38:19 +0100
committerMichael W <baddaemon87@gmail.com>2020-03-28 11:16:25 +0100
commitda610ba942ebcd0f6c6a1bba4849246bfa6f364c (patch)
tree9292bf910e934da82fd09d5268f55d1073c8fd2e
parent6633d756a2c22575ab38e693866d32a201eb6015 (diff)
downloadcm_crowdin-da610ba942ebcd0f6c6a1bba4849246bfa6f364c.tar.gz
cm_crowdin-da610ba942ebcd0f6c6a1bba4849246bfa6f364c.tar.bz2
cm_crowdin-da610ba942ebcd0f6c6a1bba4849246bfa6f364c.zip
crowdin: Replace minidom with lxml.etree
* We use lxml already in other places, so thats just commonisation * It was still marked as "TODO", so get it done Change-Id: Ie53c67ec01abff0e42f7250b799bc90b5ea4239b
-rwxr-xr-xcrowdin_sync.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/crowdin_sync.py b/crowdin_sync.py
index 7111033..ba4a5fc 100755
--- a/crowdin_sync.py
+++ b/crowdin_sync.py
@@ -36,7 +36,6 @@ import yaml
from lxml import etree
from signal import signal, SIGINT
-from xml.dom import minidom
# ################################# GLOBALS ################################## #
@@ -372,13 +371,12 @@ def check_dependencies():
def load_xml(x):
try:
- return minidom.parse(x)
- except IOError:
- print('You have no %s.' % x, file=sys.stderr)
+ return etree.parse(x)
+ except etree.XMLSyntaxError:
+ print('Malformed %s.' % x, file=sys.stderr)
return None
except Exception:
- # TODO: minidom should not be used.
- print('Malformed %s.' % x, file=sys.stderr)
+ print('You have no %s.' % x, file=sys.stderr)
return None
@@ -473,7 +471,7 @@ def download_crowdin(base_path, branch, xml, username, config):
paths.append(p.replace('/%s' % branch, ''))
print('\nUploading translations to Gerrit')
- items = [x for sub in xml for x in sub.getElementsByTagName('project')]
+ items = [x for xmlfile in xml for x in xmlfile.findall("//project")]
all_projects = []
for path in paths:
@@ -517,7 +515,7 @@ def download_crowdin(base_path, branch, xml, username, config):
resultPath = None
resultProject = None
for project in items:
- path = project.attributes['path'].value
+ path = project.get('path')
if not (result + '/').startswith(path +'/'):
continue
# We want the longest match, so projects in subfolders of other projects are also
@@ -536,10 +534,10 @@ def download_crowdin(base_path, branch, xml, username, config):
result = resultPath
all_projects.append(result)
- br = resultProject.getAttribute('revision') or branch
+ br = resultProject.get('revision') or branch
push_as_commit(files, base_path, result,
- resultProject.getAttribute('name'), br, username)
+ resultProject.get('name'), br, username)
def sig_handler(signal_received, frame):