Merge branch 'load_modules' into add_module_tests

# Conflicts:
#	src/auto_archiver/modules/gsheet_feeder/gsheet_feeder.py
#	src/auto_archiver/utils/misc.py
pull/189/head
erinhmclark 2025-02-10 19:00:05 +00:00
commit 8d894066f2
3 zmienionych plików z 9 dodań i 8 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
from __future__ import annotations
from abc import abstractmethod
from typing import IO, Optional
from typing import IO
import os
from loguru import logger

Wyświetl plik

@ -30,10 +30,10 @@ class HashEnricher(Enricher):
to_enrich.media[i].set("hash", f"{self.algorithm}:{hd}")
def calculate_hash(self, filename) -> str:
hash = None
hash_algo = None
if self.algorithm == "SHA-256":
hash = hashlib.sha256()
hash_algo = hashlib.sha256
elif self.algorithm == "SHA3-512":
hash = hashlib.sha3_512()
hash_algo = hashlib.sha3_512
else: return ""
return calculate_file_hash(filename, hash, self.chunksize)
return calculate_file_hash(filename, hash_algo, self.chunksize)

Wyświetl plik

@ -63,13 +63,14 @@ def json_loader(cli_val):
return json.loads(cli_val)
def calculate_file_hash(filename: str, hash_algo = hashlib.sha256(), chunksize: int = 16000000) -> str:
def calculate_file_hash(filename: str, hash_algo = hashlib.sha256, chunksize: int = 16000000) -> str:
hash = hash_algo()
with open(filename, "rb") as f:
while True:
buf = f.read(chunksize)
if not buf: break
hash_algo.update(buf)
return hash_algo.hexdigest()
hash.update(buf)
return hash.hexdigest()
def get_current_datetime_iso() -> str:
return datetime.now(timezone.utc).replace(tzinfo=timezone.utc).isoformat()