Skip to content

Commit 47a91ae

Browse files
committed
Add timestamps to hashes file
1 parent 16422f3 commit 47a91ae

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/calculate_hashes.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import json
3+
import yaml
34
import hashlib
45

56
# Directory to scan
@@ -23,7 +24,16 @@ def compute_hash(file_path):
2324
if file.endswith((".json", ".yaml", ".yml")):
2425
file_path = os.path.join(root, file)
2526
relative_path = os.path.relpath(file_path, directory)
26-
hashes[relative_path] = compute_hash(file_path)
27+
timestamp = ''
28+
if file.endswith(".json"):
29+
with open(file, "r") as f:
30+
data = json.load(f)
31+
timestamp = data["timestamp"]
32+
elif file.endswith(( ".yaml", ".yml")):
33+
with open(file, "r") as f:
34+
data = yaml.load(f, Loader=yaml.FullLoader)
35+
timestamp = data["timestamp"]
36+
hashes[relative_path] = {'hash': compute_hash(file_path), 'timestamp': timestamp}
2737

2838
# Write hashes to JSON file
2939
with open(output_file, "w") as f:

0 commit comments

Comments
 (0)