aboutsummaryrefslogtreecommitdiff
path: root/inc/sum.py
diff options
context:
space:
mode:
Diffstat (limited to 'inc/sum.py')
-rw-r--r--inc/sum.py33
1 files changed, 0 insertions, 33 deletions
diff --git a/inc/sum.py b/inc/sum.py
deleted file mode 100644
index fff7a814..00000000
--- a/inc/sum.py
+++ /dev/null
@@ -1,33 +0,0 @@
1def sha256sum(_):
2 sha256 = hashlib.sha256()
3 with io.open(_, mode="rb") as fd:
4 content = fd.read()
5 sha256.update(content)
6 return sha256.hexdigest()
7
8
9def walksum(_):
10 sha256 = hashlib.sha256()
11 x = Path(_)
12 if not x.exists():
13 return -1
14 try:
15 for root, directories, files in os.walk(_):
16 for names in sorted(files):
17 filepath = os.path.join(root, names)
18 try:
19 fl = open(filepath, 'rb')
20 except:
21 fl.close()
22 continue
23 while 1:
24 buf = fl.read(4096)
25 if not buf:
26 break
27 sha256.update(hashlib.sha256(buf).hexdigest())
28 fl.close()
29 except:
30 import traceback
31 traceback.print_exc()
32 return -2
33 return sha256.hexdigest()