diff options
Diffstat (limited to 'fetch.py')
-rw-r--r-- | fetch.py | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -17,6 +17,8 @@ | |||
17 | import subprocess | 17 | import subprocess |
18 | import sys | 18 | import sys |
19 | from urllib.parse import urlparse | 19 | from urllib.parse import urlparse |
20 | from urllib.request import urlopen | ||
21 | |||
20 | 22 | ||
21 | def fetch_file(url, verbose=False): | 23 | def fetch_file(url, verbose=False): |
22 | """Fetch a file from the specified source using the appropriate protocol. | 24 | """Fetch a file from the specified source using the appropriate protocol. |
@@ -39,7 +41,5 @@ def fetch_file(url, verbose=False): | |||
39 | print('fatal: error running "gsutil": %s' % e.stderr, | 41 | print('fatal: error running "gsutil": %s' % e.stderr, |
40 | file=sys.stderr) | 42 | file=sys.stderr) |
41 | sys.exit(1) | 43 | sys.exit(1) |
42 | if scheme == 'file': | 44 | with urlopen(url) as f: |
43 | with open(url[len('file://'):], 'rb') as f: | 45 | return f.read() |
44 | return f.read() | ||
45 | raise ValueError('unsupported url %s' % url) | ||