# HG changeset patch # User Jeff Hammel # Date 1527632921 25200 # Node ID 64979cfff46520251eb9f06eded938885ebe1214 # Parent 7e3a32f2794a50e88650b5ef807d101ec0a82a48 some py3 fixes diff -r 7e3a32f2794a -r 64979cfff465 makeitso/makeitso.py --- a/makeitso/makeitso.py Fri Apr 27 14:07:46 2018 -0700 +++ b/makeitso/makeitso.py Tue May 29 15:28:41 2018 -0700 @@ -16,7 +16,21 @@ import urllib # TODO: may have to use urllib2.urlopen to get reasonable timeouts -from ConfigParser import RawConfigParser +try: + # python 2 + from ConfigParser import RawConfigParser +except ImportError: + # python 3 + from configparser import RawConfigParser + +try: + # python 2 + string = (unicode, str) +except NameError: + # python 3 + string = (str,) + + from optparse import OptionParser # URL of -this file- @@ -214,7 +228,7 @@ # write output output = output or sys.stdout - if isinstance(output, basestring): + if isinstance(output, string): path = output if os.path.isdir(output): path = os.path.join(path, basename(self.name)) @@ -329,7 +343,7 @@ self.templates = [] entry_points = get_entry_points() for template in templates: - if isinstance(template, basestring): + if isinstance(template, string): # TODO: check if the template is a [e.g] PasteScript.template entry point if os.path.isdir(template): self.templates.append(DirectoryTemplate(template, interactive=self.interactive, variables=variables)) @@ -357,7 +371,7 @@ return missing def check_output(self, output): - if output and isinstance(output, basestring) and os.path.exists(output) and len(self.templates) > 1: + if output and isinstance(output, string) and os.path.exists(output) and len(self.templates) > 1: assert os.path.isdir(output), "Must specify a directory for multiple templates" for template in self.templates: if hasattr(template, 'check_output'):