MCPcopy
hub / github.com/ermongroup/ddim / check_integrity

Function check_integrity

datasets/utils.py:20–33  ·  view source on GitHub ↗
(fpath, md5=None)

Source from the content-addressed store, hash-verified

18
19
20def check_integrity(fpath, md5=None):
21 if md5 is None:
22 return True
23 if not os.path.isfile(fpath):
24 return False
25 md5o = hashlib.md5()
26 with open(fpath, 'rb') as f:
27 # read in 1MB chunks
28 for chunk in iter(lambda: f.read(1024 * 1024), b''):
29 md5o.update(chunk)
30 md5c = md5o.hexdigest()
31 if md5c != md5:
32 return False
33 return True
34
35
36def makedir_exist_ok(dirpath):

Callers 3

_check_integrityMethod · 0.90
download_urlFunction · 0.85

Calls 1

updateMethod · 0.80

Tested by

no test coverage detected