From d9acf1e652c1613a93bcc6f2d7b88694d18204d5 Mon Sep 17 00:00:00 2001 From: "Prism V. Penguin" Date: Mon, 4 Sep 2017 19:33:06 +0200 Subject: [PATCH] added Python3 compatibility (with six.moves) Using six.moves.urllib for Py2 and Py3 compatibility. --- download.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/download.py b/download.py index 05090a1..fb8cd87 100644 --- a/download.py +++ b/download.py @@ -7,7 +7,7 @@ from os.path import join import subprocess -import urllib2 +from six.moves.urllib.request import urlopen __author__ = 'Fisher Yu' __email__ = 'fy@cs.princeton.edu' @@ -16,7 +16,7 @@ def list_categories(tag): url = 'http://lsun.cs.princeton.edu/htbin/list.cgi?tag=' + tag - f = urllib2.urlopen(url) + f = urlopen(url) return json.loads(f.read()) @@ -51,8 +51,8 @@ def main(): if args.category == 'test': download(args.out_dir, '', 'test', args.tag) elif args.category not in categories: - print('Error:', args.category, "doesn't exist in", - args.tag, 'LSUN release') + print('Error:', args.category, "doesn't exist in", args.tag, + 'LSUN release') else: download(args.out_dir, args.category, 'train', args.tag) download(args.out_dir, args.category, 'val', args.tag)