forked from Botanical/BotanJS
13 lines
301 B
Python
13 lines
301 B
Python
from functools import lru_cache
|
|
from zlib import adler32 as _HashFunc
|
|
HashFunc = lambda v: hex( _HashFunc( v ) )[2:]
|
|
|
|
|
|
@lru_cache( maxsize = 1024 )
|
|
def checksum( file_path ):
|
|
try:
|
|
with open( file_path, "rb" ) as f:
|
|
return HashFunc( f.read() )
|
|
except FileNotFoundError:
|
|
return HashFunc( b"" )
|