changeset 16:8ae3a7fd466a

py3
author Jeff Hammel <k0scist@gmail.com>
date Mon, 20 Feb 2017 14:56:46 -0800
parents 5de4f7d434de
children a42a02bb46ed
files martini/config.py setup.py
diffstat 2 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/martini/config.py	Mon Feb 20 14:50:23 2017 -0800
+++ b/martini/config.py	Mon Feb 20 14:56:46 2017 -0800
@@ -2,19 +2,32 @@
 
 import os
 import sys
-import urllib2
 
-from ConfigParser import ConfigParser
-from ConfigParser import InterpolationMissingOptionError
-from ConfigParser import MissingSectionHeaderError
-from ConfigParser import NoOptionError
-from StringIO import StringIO
+
 
 try:
     from collections import OrderedDict
 except ImportError:
     from odict import OrderedDict
 
+try:
+    # python 2
+    from urllib2 import urlopen
+    from ConfigParser import ConfigParser
+    from ConfigParser import InterpolationMissingOptionError
+    from ConfigParser import MissingSectionHeaderError
+    from ConfigParser import NoOptionError
+    from StringIO import StringIO
+
+except ImportError:
+    # python 3
+    from urllib.request import urlopen
+    from configparser import ConfigParser
+    from configparser import InterpolationMissingOptionError
+    from configparser import MissingSectionHeaderError
+    from configparser import NoOptionError
+    from io import StringIO
+
 
 def file_pointer(resource):
     """returns a file-like object given a string"""
@@ -28,7 +41,7 @@
         return file(resource)
     if sum([resource.startswith(http)
             for http in ('http://', 'https://')]):
-        return urllib2.urlopen(resource)
+        return urlopen(resource)
     return StringIO(resource)
 
 
--- a/setup.py	Mon Feb 20 14:50:23 2017 -0800
+++ b/setup.py	Mon Feb 20 14:56:46 2017 -0800
@@ -6,7 +6,7 @@
 except:
     description = ''
 
-version = '0.5.1'
+version = '0.5.2'
 
 setup(name='martINI',
       version=version,