python/build/verify: move code to file_digest()
This commit is contained in:
parent
8bfabbe265
commit
3dde62befe
|
@ -16,9 +16,14 @@ def feed_file_path(h, path):
|
||||||
with open(path, 'rb') as f:
|
with open(path, 'rb') as f:
|
||||||
feed_file(h, 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):
|
def file_md5(path):
|
||||||
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
|
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
|
||||||
|
|
||||||
h = hashlib.md5()
|
return file_digest(hashlib.md5, path)
|
||||||
feed_file_path(h, path)
|
|
||||||
return h.hexdigest()
|
|
||||||
|
|
Loading…
Reference in New Issue