summaryrefslogtreecommitdiff
path: root/src/pyssg/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/pyssg/utils.py')
-rw-r--r--src/pyssg/utils.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/pyssg/utils.py b/src/pyssg/utils.py
index 216f535..487125f 100644
--- a/src/pyssg/utils.py
+++ b/src/pyssg/utils.py
@@ -81,12 +81,13 @@ def copy_file(src: str, dst: str) -> None:
# as seen in SO: https://stackoverflow.com/a/1131238
def get_checksum(path: str) -> str:
- log.debug('calculating md5 checksum for "%s"', path)
file_hash = md5()
with open(path, "rb") as f:
while chunk := f.read(4096):
file_hash.update(chunk)
- return file_hash.hexdigest()
+ out: str = file_hash.hexdigest()
+ log.debug('md5 checksum of "%s": %s', path, out)
+ return out
def get_expanded_path(path: str) -> str:
@@ -99,6 +100,12 @@ def get_expanded_path(path: str) -> str:
return epath
+def get_file_stats(path: str) -> tuple[str, float]:
+ time: float = os.stat(path).st_mtime
+ chksm: str = get_checksum(path)
+ return (chksm, time)
+
+
def get_time_now(fmt: str, tz: timezone=timezone.utc) -> str:
return datetime.now(tz=tz).strftime(fmt)