forked from N3evin/AmiiboAPI
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsha1sum.py
More file actions
29 lines (22 loc) · 609 Bytes
/
Copy pathsha1sum.py
File metadata and controls
29 lines (22 loc) · 609 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
# coding=utf-8
import hashlib
import json
import os
if __name__ == '__main__':
hashes = {}
def hashFile(filename):
global hashes
with open(filename, 'rb') as file:
hashes[filename] = hashlib.sha1(file.read()).hexdigest()
def hashDir(directory):
for entry in os.scandir(directory):
if (entry.is_file()):
hashFile(directory + '/' + entry.name)
else:
hashDir(directory + '/' + entry.name)
hashFile('last-updated.json')
hashDir('database')
hashDir('images')
with open('sha1sum.json', 'w') as file:
json.dump(hashes, file, sort_keys=True, indent='\t')