use either urllib2 or urllib.request as necessary

This commit is contained in:
Jeremy Carbaugh 2012-03-11 22:18:12 -07:00
parent 8d512d7e07
commit fad10e5a98

View File

@ -1,5 +1,10 @@
import os
import urllib2
try:
from urllib.request import urlopen # attemp py3 first
except ImportError:
from urllib2 import urlopen # fallback to py2
"""
General utilities used within saucebrush that may be useful elsewhere.
"""
@ -112,7 +117,7 @@ class RemoteFile(object):
self._url = url
def __iter__(self):
resp = urllib2.urlopen(self._url)
resp = urlopen(self._url)
for line in resp:
yield line.rstrip()
resp.close()