Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python 3 compatibility to bin/cordova_plist_to_config_xml #769

Merged
merged 3 commits into from
May 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=' ')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add a space here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To put a space between each line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand (did not work with Python for about 10 years), hope someone else can review it. We do appreciate your efforts to get this whole Python compatibility issue fixed.

Copy link
Contributor Author

@cclauss cclauss Feb 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which do we want?

>>> for char in "abcdefg":
...     print(char, end="")  # --> abcdefg
    -- or --
>>> for char in "abcdefg":
...     print(char, end=" ")  # --> a b c d e f g

file_handle.close()


Expand Down