Files
mixly3/boards/default/micropython_k210_mixgoai/build/lib/mixly_tool.py
2024-07-19 10:16:00 +08:00

26 lines
661 B
Python

import hashlib
import os
def sha_file(f):
if f not in set(os.listdir(".")):
return 'None:::sha_file_end'
else:
sha = hashlib.sha256()
with open(f, encoding='utf-8') as fd:
file_buffer = fd.read(128).encode("utf-8")
while len(file_buffer) > 0:
sha.update(file_buffer)
file_buffer = fd.read(128).encode("utf-8")
h = sha.digest()
return ''.join(['%.2x' % i for i in h]) + ":::sha_file_end"
def reload(mod):
import sys
mod_name = mod.__name__
try:
del sys.modules[mod_name]
__import__(mod_name)
except:
pass