From 43e3bbd28bdef80c6dbf615fe732fca273826f69 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 20 May 2020 09:54:56 +0200 Subject: [PATCH] breaking: add python 3 compatibility to bin/cordova_plist_to_config_xml (#769) --- bin/cordova_plist_to_config_xml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/cordova_plist_to_config_xml b/bin/cordova_plist_to_config_xml index e781c630d..0d61b3b93 100755 --- a/bin/cordova_plist_to_config_xml +++ b/bin/cordova_plist_to_config_xml @@ -23,11 +23,12 @@ Converts a project's Cordova.plist file into a config.xml one. This conversion i Usage: plist2xml.py path/to/project """ +from __future__ import print_function -import StringIO import fileinput -import plistlib +import io import os +import plistlib import re import sys from xml.dom import minidom @@ -88,10 +89,10 @@ def ConvertPlist(src_path, dst_path): root.append(ElementTree.Element('access', attrib={'origin':value})) tree = ElementTree.ElementTree(root) - s = StringIO.StringIO() - tree.write(s, encoding='UTF-8') - mini_dom = minidom.parseString(s.getvalue()) - with open(dst_path, 'w') as out: + with io.BytesIO() as s: + tree.write(s, encoding='UTF-8') + mini_dom = minidom.parseString(s.getvalue()) + with open(dst_path, 'wb') as out: out.write(mini_dom.toprettyxml(encoding='UTF-8')) @@ -101,7 +102,7 @@ def UpdateProjectFile(path): if 'Cordova.plist' in line: line = line.replace('Cordova.plist', 'config.xml') line = line.replace('lastKnownFileType = text.plist.xml', 'lastKnownFileType = text.xml') - print line, + print(line, end=' ') file_handle.close()