Remove urllib2 python2 support
@@ -4,6 +4,7 @@ import logging
import os
import re
import traceback
+import urllib.request
import numpy as np
@@ -92,8 +93,6 @@ def open_file(file_ref, **encoding_kwargs):
first_line = lines[0]
if URL_REGEXP.match(first_line): # it's a URL
logger.info("Loading URL {}".format(first_line))
- try:
- import urllib.request
response = urllib.request.urlopen(file_ref)
if response.headers.get_content_charset() is None:
@@ -108,19 +107,6 @@ def open_file(file_ref, **encoding_kwargs):
# translated into '\n' before being returned to the caller.
file_ref = StringIO(response.read().decode(encoding), newline=None)
logger.debug("Retrieved data decoded via {}".format(encoding))
- except ImportError:
- # deprecated: was part of python 2.7 support
- import urllib2
-
- response = urllib2.urlopen(first_line)
- encoding = response.headers.getparam("charset")
-
- tmp_str = response.read()
- tmp_list = tmp_str.splitlines()
- new_str = "\n".join(tmp_list)
- # file_ref = StringIO(response.read())
- file_ref = StringIO(new_str)
- logger.debug("Retrieved data had encoding {}".format(encoding))
elif len(lines) > 1: # it's LAS data as a string.
file_ref = StringIO(file_ref)
else: # it must be a filename
