(fpath, md5=None)
| 18 | |
| 19 | |
| 20 | def 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 | |
| 36 | def makedir_exist_ok(dirpath): |
no test coverage detected