Skip to content

Commit 8eda729

Browse files
committed
Fix Python 3 incompat. use of urllib2.
1 parent 764ce01 commit 8eda729

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

planemo/lint.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import os
22

3-
import urllib2
3+
from six.moves.urllib.request import (
4+
urlopen,
5+
)
6+
from six.moves.urllib.error import (
7+
HTTPError,
8+
URLError,
9+
)
410
from planemo.xml import validation
511
from planemo.shed import find_urls_for_xml
612

@@ -22,12 +28,12 @@ def lint_urls(root, lint_ctx):
2228

2329
def validate_url(url, lint_ctx):
2430
try:
25-
handle = urllib2.urlopen(url)
31+
handle = urlopen(url)
2632
handle.read(100)
2733
lint_ctx.info("URL OK %s" % url)
28-
except urllib2.HTTPError as e:
34+
except HTTPError as e:
2935
lint_ctx.error("HTTP Error %s accessing %s" % (e.code, url))
30-
except urllib2.URLError as e:
36+
except URLError as e:
3137
lint_ctx.error("URL Error %s accessing %s" % (str(e), url))
3238

3339
for url in urls:

0 commit comments

Comments
 (0)