diff options
author | Michael W <baddaemon87@gmail.com> | 2020-03-22 18:38:19 +0100 |
---|---|---|
committer | Michael W <baddaemon87@gmail.com> | 2020-03-28 11:16:25 +0100 |
commit | da610ba942ebcd0f6c6a1bba4849246bfa6f364c (patch) | |
tree | 9292bf910e934da82fd09d5268f55d1073c8fd2e | |
parent | 6633d756a2c22575ab38e693866d32a201eb6015 (diff) | |
download | cm_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-x | crowdin_sync.py | 18 |
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): |