File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 11import os
22import json
3+ import yaml
34import 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
2939with open (output_file , "w" ) as f :
You can’t perform that action at this time.
0 commit comments