diff --git a/fetch.py b/fetch.py index d79f947..c954a9c 100644 --- a/fetch.py +++ b/fetch.py @@ -17,6 +17,8 @@ import subprocess import sys from urllib.parse import urlparse +from urllib.request import urlopen + def fetch_file(url, verbose=False): """Fetch a file from the specified source using the appropriate protocol. @@ -39,7 +41,5 @@ def fetch_file(url, verbose=False): print('fatal: error running "gsutil": %s' % e.stderr, file=sys.stderr) sys.exit(1) - if scheme == 'file': - with open(url[len('file://'):], 'rb') as f: - return f.read() - raise ValueError('unsupported url %s' % url) + with urlopen(url) as f: + return f.read()