Fixed import of urlopen[2]
on Python 3.
This commit is contained in:
12
gitfiti.py
12
gitfiti.py
@ -13,7 +13,13 @@ from datetime import datetime, timedelta
|
|||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import urllib2
|
try:
|
||||||
|
# Python 3+
|
||||||
|
from urllib.error import HTTPError, URLError
|
||||||
|
from urllib.request import urlopen
|
||||||
|
except ImportError:
|
||||||
|
# Python 2
|
||||||
|
from urllib2 import HTTPError, URLError, urlopen
|
||||||
|
|
||||||
|
|
||||||
GITHUB_BASE_URL = 'https://github.com/'
|
GITHUB_BASE_URL = 'https://github.com/'
|
||||||
@ -199,8 +205,8 @@ def get_calendar(username, base_url):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
url = base_url + '/contributions'
|
url = base_url + '/contributions'
|
||||||
page = urllib2.urlopen(url)
|
page = urlopen(url)
|
||||||
except (urllib2.HTTPError, urllib2.URLError) as e:
|
except (HTTPError, URLError) as e:
|
||||||
print('There was a problem fetching data from {0}'.format(url))
|
print('There was a problem fetching data from {0}'.format(url))
|
||||||
print(e)
|
print(e)
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
Reference in New Issue
Block a user