123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import hashlib
- import os
- import sys
- ignore_folder = ["node_modules", "dist", "coverage", "build", "scripts", "test-config"]
- ignore_file_name = [
- "DS_Store",
- "env.local",
- "env.development.local",
- "env.test.local",
- "env.production.local",
- ".eslintrc.js",
- ".gitignore",
- "jest.config.js",
- "typedoc-mkdocs.json",
- ".env",
- "dev.env",
- ]
- ignore_file_extension = [".md"]
- def hash_file(file_path):
- hasher = hashlib.sha256()
- with open(file_path, "rb") as f:
- buf = f.read()
- hasher.update(buf)
- return hasher.hexdigest()
- def hash_files_in_frontend_folder(frontend_folder):
- combined_hasher = hashlib.sha256()
- file_hashes = {}
- lookup_fe_folder = [f"{frontend_folder}{os.sep}taipy", f"{frontend_folder}{os.sep}taipy-gui"]
- if len(sys.argv) > 1 and sys.argv[1] == "--taipy-gui-only":
- lookup_fe_folder.pop(0)
- for root_folder in lookup_fe_folder:
-
- for root, _, files in sorted(os.walk(root_folder)):
- if any(ignore in root for ignore in ignore_folder):
- continue
-
- for file in sorted(files):
- if any(ignore in file for ignore in ignore_file_name):
- continue
- if any(file.endswith(ignore) for ignore in ignore_file_extension):
- continue
- file_path = os.path.join(root, file)
- file_hash = hash_file(file_path)
- file_hashes[file_path] = file_hash
- combined_hasher.update(file_hash.encode())
- combined_hash = combined_hasher.hexdigest()
- return file_hashes, combined_hash
- if __name__ == "__main__":
- frontend_folder = "frontend"
- file_hashes, combined_hash = hash_files_in_frontend_folder(frontend_folder)
-
-
- print(f"Taipy Frontend hash {combined_hash}")
-
- with open("hash.txt", "w") as f:
- f.write(combined_hash)
|