Fix some errors related to python3

This commit is contained in:
Akira TAGOH 2016-07-08 11:32:53 +09:00
parent 416cdd9d49
commit a34db434c6
1 changed files with 10 additions and 4 deletions

View File

@ -2,7 +2,13 @@
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import print_function from __future__ import print_function
import urllib2 try:
from urllib2 import urlopen
from urllib2 import URLError
except ImportError:
from urllib.request import urlopen
from urllib.error import URLError
import sys import sys
import os import os
from lxml import html from lxml import html
@ -10,13 +16,13 @@ from six.moves import range
datafile = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'list-unicodeset.html') datafile = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'list-unicodeset.html')
try: try:
fp = urllib2.urlopen('http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[%3AGC%3DZs%3A][%3ADI%3A]&abb=on&ucd=on&esc=on&g') fp = urlopen('http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[%3AGC%3DZs%3A][%3ADI%3A]&abb=on&ucd=on&esc=on&g')
data = fp.read() data = fp.read()
fp.close() fp.close()
fp = open(datafile, 'w'); fp = open(datafile, 'wb');
fp.write(data); fp.write(data);
fp.close(); fp.close();
except urllib2.URLError: except URLError:
# fall back reading the static data in repo # fall back reading the static data in repo
try: try:
fp = open(datafile) fp = open(datafile)