Skip to content

Commit be10ce4

Browse files
authored
Getattr fix patched (#5)
* Update webArchiver.py * Update webArchiver.py
1 parent 0cbf493 commit be10ce4

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

webArchiver.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,10 @@ def forcedir(file_path):
9595

9696

9797
def hasher(filein, hname, blocksize):
98-
htype = {
99-
"blake2s": lambda: hashlib.blake2s(),
100-
"sha384": lambda: hashlib.sha384(),
101-
"sha512": lambda: hashlib.sha512(),
102-
"sha3_256": lambda: hashlib.sha3_256(),
103-
"sha256": lambda: hashlib.sha256(),
104-
"md5": lambda: hashlib.md5(),
105-
"sha3_512": lambda: hashlib.sha3_512(),
106-
"sha3_224": lambda: hashlib.sha3_224(),
107-
"shake_128": lambda: hashlib.shake_128(),
108-
"shake_256": lambda: hashlib.shake_256(),
109-
"sha1": lambda: hashlib.sha1(),
110-
"blake2b": lambda: hashlib.blake2b(),
111-
"sha224": lambda: hashlib.sha224(),
112-
"sha3_384": lambda: hashlib.sha3_384(),
113-
}.get(hname, lambda: (print("wrong hash type"), exit(1)))()
98+
htype = getattr(hashlib, hname, print)()
99+
if htype is None:
100+
print("wrong hash type")
101+
exit(1)
114102
with open(filein, 'rb') as fi:
115103
while True:
116104
data = fi.read(blocksize)

0 commit comments

Comments
 (0)