summaryrefslogtreecommitdiff
path: root/program/utils.py
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2021-06-15 20:52:55 (GMT)
committerChristian Pointner <equinox@helsinki.at>2021-06-15 20:52:55 (GMT)
commit09276cc47736785e7a2784172a2cf3663de4e57e (patch)
tree202b46bfc67595a64bda7aa4ac359e0957b09189 /program/utils.py
parentb2415eb92622563f567106e2c4951ed498273e53 (diff)
parent88fb9a1d5bc7dc5f22d96fcee970f4ec9f88b289 (diff)
Merge branch 'topic/new-show-and-note-images' into stable
Diffstat (limited to 'program/utils.py')
-rw-r--r--program/utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/program/utils.py b/program/utils.py
index 1a81766..3bfecc4 100644
--- a/program/utils.py
+++ b/program/utils.py
@@ -3,8 +3,10 @@ from django.conf import settings
import json
import urllib
import bisect
+import hashlib
from os.path import join
from datetime import datetime, date, timedelta
+from functools import partial
def get_automation_id_choices():
@@ -56,3 +58,11 @@ def tofirstdayinisoweek(year, week):
if date(year, 1, 4).isoweekday() > 4:
ret -= timedelta(days=7)
return ret
+
+
+def hash_file(file, block_size=65536):
+ hasher = hashlib.sha256()
+ for buf in iter(partial(file.read, block_size), b''):
+ hasher.update(buf)
+
+ return hasher.hexdigest()