diff options
author | Max Kellermann <max@musicpd.org> | 2016-12-29 21:32:28 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-12-29 21:32:28 +0100 |
commit | e334b16aaa13eaf1c7ad29388ab109cf8aecb324 (patch) | |
tree | 668449f2bfdf4dcbfce8068547e894e7928fbe7b /python | |
parent | 5626ace245213b84944c1742f16a8ea2fe074e3d (diff) |
python/build/download: move file_md5() to verify.py
Diffstat (limited to 'python')
-rw-r--r-- | python/build/download.py | 14 | ||||
-rw-r--r-- | python/build/verify.py | 13 |
2 files changed, 14 insertions, 13 deletions
diff --git a/python/build/download.py b/python/build/download.py index d41b30a5b..56af5c7bd 100644 --- a/python/build/download.py +++ b/python/build/download.py @@ -1,19 +1,7 @@ +from build.verify import file_md5 import os -import hashlib import urllib.request -def file_md5(path): - """Calculate the MD5 checksum of a file and return it in hexadecimal notation.""" - - with open(path, 'rb') as f: - m = hashlib.md5() - while True: - data = f.read(65536) - if len(data) == 0: - # end of file - return m.hexdigest() - m.update(data) - def download_and_verify(url, md5, parent_path): """Download a file, verify its MD5 checksum and return the local path.""" diff --git a/python/build/verify.py b/python/build/verify.py new file mode 100644 index 000000000..8ec190cac --- /dev/null +++ b/python/build/verify.py @@ -0,0 +1,13 @@ +import hashlib + +def file_md5(path): + """Calculate the MD5 checksum of a file and return it in hexadecimal notation.""" + + with open(path, 'rb') as f: + m = hashlib.md5() + while True: + data = f.read(65536) + if len(data) == 0: + # end of file + return m.hexdigest() + m.update(data) |