Remove the sha256sum function for files and update tests

This commit is contained in:
Veronica Berglyd Olsen
2023-08-25 16:55:45 +02:00
parent b3fcea29da
commit 0d262c0ae8
3 changed files with 4 additions and 64 deletions
-20
View File
@@ -25,7 +25,6 @@ from __future__ import annotations
import json
import uuid
import hashlib
import logging
import unicodedata
import xml.etree.ElementTree as ET
@@ -488,25 +487,6 @@ def makeFileNameSafe(text: str) -> str:
return "".join(c for c in text if c.isalnum() or c in allowed)
def sha256sum(path: str | Path) -> str | None:
"""Make a shasum of a file using a buffer.
Based on: https://stackoverflow.com/a/44873382/5825851
"""
digest = hashlib.sha256()
bData = bytearray(65536)
mData = memoryview(bData)
try:
with open(path, mode="rb", buffering=0) as inFile:
for n in iter(lambda: inFile.readinto(mData), 0):
digest.update(mData[:n])
except Exception:
logger.error("Could not create sha256sum of: %s", path)
logException()
return None
return digest.hexdigest()
# =============================================================================================== #
# Other Functions
# =============================================================================================== #