Coverage for /Users/jerry/Development/yenta/yenta/utils/files.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from hashlib import sha1
2from pathlib import Path
5def file_hash(path: Path, block_size=65536):
6 s = sha1()
8 if path.exists():
9 with open(path, 'rb') as f:
10 stop = False
11 while not stop:
12 data = f.read(block_size)
13 if len(data) > 0:
14 s.update(data)
15 else:
16 stop = True
18 return s