python/build/verify: move code to file_digest()

This commit is contained in:
Max Kellermann 2016-12-29 21:29:07 +01:00
parent 8bfabbe265
commit 3dde62befe
1 changed files with 8 additions and 3 deletions

View File

@ -16,9 +16,14 @@ def feed_file_path(h, path):
with open(path, 'rb') as f:
feed_file(h, f)
def file_digest(algorithm, path):
"""Calculate the digest of a file and return it in hexadecimal notation."""
h = algorithm()
feed_file_path(h, path)
return h.hexdigest()
def file_md5(path):
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
h = hashlib.md5()
feed_file_path(h, path)
return h.hexdigest()
return file_digest(hashlib.md5, path)