homes/common/.local/lib/python2.7/site-packages/powerline/lib/url.py
2013-05-02 18:11:33 +02:00

16 lines
413 B
Python

# vim:fileencoding=utf-8:noet
try:
from urllib.error import HTTPError
from urllib.request import urlopen
from urllib.parse import urlencode as urllib_urlencode # NOQA
except ImportError:
from urllib2 import urlopen, HTTPError # NOQA
from urllib import urlencode as urllib_urlencode # NOQA
def urllib_read(url):
try:
return urlopen(url, timeout=10).read().decode('utf-8')
except HTTPError:
return