Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Python 3 Support #1

Open
t8y8 opened this issue Dec 22, 2016 · 4 comments
Open

Python 3 Support #1

t8y8 opened this issue Dec 22, 2016 · 4 comments
Assignees

Comments

@t8y8
Copy link

t8y8 commented Dec 22, 2016

After a quick glance at the code, I don't see any reason why this couldn't work with Py3.

In fact, I see more code written to prevent python3 than I think would be required to be compatible with python 3 :)

I'll take a more in depth review later and submit a PR
(I may just run futurize over it and compare the output)

@t8y8
Copy link
Author

t8y8 commented Dec 22, 2016

Output of futurize:

--- ScriptedInstaller.py	(original)
+++ ScriptedInstaller.py	(refactored)
@@ -1,4 +1,6 @@
 from __future__ import print_function
+from builtins import map
+from builtins import str
 import sys
 import os
 import re
@@ -183,9 +185,9 @@
     try:
         secrets = read_json_file(options.secretsFile)
         # be sure they have at least initial user and password
-        if require_initialuser and not 'content_admin_user' in secrets.keys():
+        if require_initialuser and not 'content_admin_user' in list(secrets.keys()):
             raise ValidationError('Missing content_admin_user in secrets file "%s"' % options.secretsFile)
-        if require_initialuser and not 'content_admin_pass' in secrets.keys():
+        if require_initialuser and not 'content_admin_pass' in list(secrets.keys()):
             raise ValidationError('Missing content_admin_pass in secrets file "%s"' % options.secretsFile)
         return secrets
     except IOError as ex:
@@ -275,7 +277,7 @@

 # parameter must be in keys, and must not be null, emtpy, or just whitespace
 def must_set_value_for_parameter(param_map, parameter):
-    return parameter in param_map.keys() and not(not param_map[parameter] or param_map[parameter].isspace())
+    return parameter in list(param_map.keys()) and not(not param_map[parameter] or param_map[parameter].isspace())

Everything else is already compatible (I'm also not confidant the import stuff is necessary, that seems to be a quirk of the tool)

@kevinpeoples
Copy link

Will there be and official version that support python 3+?

@kittychou
Copy link
Contributor

We don't currently have plans to update with an new version that supports Python 3+, but you are welcome to take the script and make the necessary modifications for your own use.

@t8y8
Copy link
Author

t8y8 commented Mar 22, 2017

Can't promise a timeline, but if this is as simple as I think, I'll try and get to it within the next month.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants