aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorAlban Gruin2018-01-27 17:56:45 +0100
committerAlban Gruin2018-01-27 18:13:25 +0100
commitc9388e29b2f9ee18a9e190683a8a33fb710684c5 (patch)
tree1d9402e02719110d3a0f15b74500b57afe0d2fd4 /utils.py
parent465c1c13f2e5a77f296de92d4b5b14cf319c68c5 (diff)
PEP8
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/utils.py b/utils.py
index 9f0a6b5..839d8bc 100644
--- a/utils.py
+++ b/utils.py
@@ -18,9 +18,11 @@ import re
from django.utils import timezone
+
def get_current_week():
return tz_now().isocalendar()[:2]
+
def get_current_or_next_week():
year, week, day = tz_now().isocalendar()
if day >= 6:
@@ -28,6 +30,7 @@ def get_current_or_next_week():
return year, week
+
def get_week(year, week):
start = timezone.make_aware(datetime.datetime.strptime(
"{0}-W{1}-1".format(year, week), "%Y-W%W-%w"))
@@ -35,6 +38,7 @@ def get_week(year, week):
return start, end
+
def group_courses(courses):
grouped_courses = []
for i, course in enumerate(courses):
@@ -45,6 +49,7 @@ def group_courses(courses):
return grouped_courses
+
def parse_group(name):
# Explication de la regex
#
@@ -66,7 +71,8 @@ def parse_group(name):
parts = search.groups()
- # On retourne la section (parts[0]), le semestre (parts[2]) et le groupe (parts[5])
+ # On retourne la section (parts[0]), le semestre (parts[2]) et le
+ # groupe (parts[5])
if parts[2] is not None:
return parts[0], int(parts[2]), parts[5]
else:
@@ -75,6 +81,7 @@ def parse_group(name):
# une erreur.
return parts[0], None, parts[5]
+
def tz_now():
"""Retourne la date et l’heure avec le bon fuseau horaire"""
return timezone.make_aware(datetime.datetime.now())