changeset 17:a42a02bb46ed

py3
author Jeff Hammel <k0scist@gmail.com>
date Mon, 20 Feb 2017 15:11:21 -0800
parents 8ae3a7fd466a
children c570adf77a48
files martini/config.py setup.py
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/martini/config.py	Mon Feb 20 14:56:46 2017 -0800
+++ b/martini/config.py	Mon Feb 20 15:11:21 2017 -0800
@@ -4,7 +4,6 @@
 import sys
 
 
-
 try:
     from collections import OrderedDict
 except ImportError:
@@ -29,16 +28,24 @@
     from io import StringIO
 
 
+try:
+    # python 2
+    string = (str, unicode)
+except:
+    # python 3
+    string = (str,)
+
+
 def file_pointer(resource):
     """returns a file-like object given a string"""
     # XXX could go in utils.py
 
-    if not isinstance(resource, basestring):
+    if not isinstance(resource, string):
         # assume resource is already a file-like object
         return resource
 
     if os.path.exists(resource):
-        return file(resource)
+        return open(resource)
     if sum([resource.startswith(http)
             for http in ('http://', 'https://')]):
         return urlopen(resource)
--- a/setup.py	Mon Feb 20 14:56:46 2017 -0800
+++ b/setup.py	Mon Feb 20 15:11:21 2017 -0800
@@ -6,7 +6,8 @@
 except:
     description = ''
 
-version = '0.5.2'
+version = '0.5.3'
+
 
 setup(name='martINI',
       version=version,