| 46 | |
| 47 | |
| 48 | def get_file_hash(path, block_size=2 ** 20): |
| 49 | sha256 = hashlib.sha256(usedforsecurity=False) |
| 50 | with open(path, 'rb') as fd: |
| 51 | while True: |
| 52 | data = fd.read(block_size) |
| 53 | if not data: |
| 54 | break |
| 55 | sha256.update(data) |
| 56 | |
| 57 | if Path(path).suffix == '.pdf': |
| 58 | sha256.update(str(mpl._get_executable_info("gs").version).encode('utf-8')) |
| 59 | elif Path(path).suffix == '.svg': |
| 60 | sha256.update(str(mpl._get_executable_info("inkscape").version).encode('utf-8')) |
| 61 | |
| 62 | return sha256.hexdigest() |
| 63 | |
| 64 | |
| 65 | class _ConverterError(Exception): |