add tree_map for dependency checker

This commit is contained in:
wl-zhao
2024-11-07 10:56:06 +08:00
parent 24c17beccf
commit 85e01a8711
4 changed files with 1232 additions and 29 deletions
+1197
View File
File diff suppressed because it is too large Load Diff
+20
View File
@@ -0,0 +1,20 @@
import hashlib
import time
from pathlib import PurePosixPath, Path, PureWindowsPath
def windows_to_linux_path(windows_path):
return PureWindowsPath(windows_path).as_posix()
def compute_sha256(file_path, chunk_size=1024 ** 2):
# Create a new sha256 hash object
start = time.time()
sha256 = hashlib.sha256()
print("start compute sha256 for", file_path)
# Open the file in binary mode
with open(file_path, 'rb') as file:
# Read the file in chunks to handle large files efficiently
while chunk := file.read(chunk_size):
sha256.update(chunk)
print("finish compute sha256 for", file_path, f"time: {time.time() - start}")
# Return the hexadecimal digest of the hash
return sha256.hexdigest()