MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / get_file_hash

Function get_file_hash

lib/matplotlib/testing/compare.py:48–62  ·  view source on GitHub ↗
(path, block_size=2 ** 20)

Source from the content-addressed store, hash-verified

46
47
48def 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
65class _ConverterError(Exception):

Callers 1

convertFunction · 0.85

Calls 2

PathClass · 0.85
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…