Skip to content

Commit 18dafe8

Browse files
committed
Code cleanup in download() in bootstrap.py
Make download() receive less parameters and use it explicitly 2 times in get().
1 parent f5884f6 commit 18dafe8

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/bootstrap/bootstrap.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ def get(url, path, verbose=False):
2525
temp_path = temp_file.name
2626
sha_file = tempfile.NamedTemporaryFile(suffix=".sha256", delete=True)
2727
sha_path = sha_file.name
28-
download(sha_path, sha_url, temp_path, url, verbose)
28+
download(sha_path, sha_url, verbose)
29+
download(temp_path, url, verbose)
2930
verify(sha_path, temp_path, verbose)
3031
sha_file.close()
3132
print("moving " + temp_path + " to " + path)
3233
shutil.move(temp_path, path)
3334
temp_file.close()
3435

3536

36-
def download(sha_path, sha_url, temp_path, url, verbose):
37-
for _url, _path in ((url, temp_path), (sha_url, sha_path)):
38-
print("downloading " + _url + " to " + _path)
39-
# see http://serverfault.com/questions/301128/how-to-download
40-
if sys.platform == 'win32':
41-
run(["PowerShell.exe", "/nologo", "-Command",
42-
"(New-Object System.Net.WebClient)"
43-
".DownloadFile('{}', '{}')".format(_url, _path)],
44-
verbose=verbose)
45-
else:
46-
run(["curl", "-o", _path, _url], verbose=verbose)
37+
def download(path, url, verbose):
38+
print("downloading " + url + " to " + path)
39+
# see http://serverfault.com/questions/301128/how-to-download
40+
if sys.platform == 'win32':
41+
run(["PowerShell.exe", "/nologo", "-Command",
42+
"(New-Object System.Net.WebClient)"
43+
".DownloadFile('{}', '{}')".format(url, path)],
44+
verbose=verbose)
45+
else:
46+
run(["curl", "-o", path, url], verbose=verbose)
4747

4848

4949
def verify(sha_path, temp_path, verbose):

0 commit comments

Comments
 (0)