summaryrefslogtreecommitdiff
path: root/program/utils.py
diff options
context:
space:
mode:
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()