Skip to content

Commit

Permalink
breaking: add python 3 compatibility to bin/cordova_plist_to_config_x…
Browse files Browse the repository at this point in the history
…ml (#769)
  • Loading branch information
cclauss authored May 20, 2020
1 parent b9265b8 commit 43e3bbd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bin/cordova_plist_to_config_xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'))


Expand All @@ -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()


Expand Down

0 comments on commit 43e3bbd

Please sign in to comment.