aboutsummaryrefslogtreecommitdiff
path: root/management/parsers/ups2018.py
diff options
context:
space:
mode:
Diffstat (limited to 'management/parsers/ups2018.py')
-rw-r--r--management/parsers/ups2018.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/management/parsers/ups2018.py b/management/parsers/ups2018.py
index 4ae7ef7..805c761 100644
--- a/management/parsers/ups2018.py
+++ b/management/parsers/ups2018.py
@@ -19,6 +19,7 @@ from collections import OrderedDict
import asyncio
import calendar
import json
+import re
from django.utils import timezone
@@ -95,7 +96,11 @@ class Parser(AbstractParser):
if data[0] == "Global Event":
return
- i = 0
+ min_i = 0
+ if len(data) > 0 and re.match("^\(\d+:\d+-\d+:\d+\)$", data[0]):
+ min_i = 1
+
+ i = min_i
while i < len(data) and not data[i].startswith(
("L1 ", "L2 ", "L3 ", "L3P ", "M1 ", "M2 ", "DEUST ", "MAG1 ",
"1ERE ANNEE ", "2EME ANNEE ", "3EME ANNEE ",
@@ -104,7 +109,7 @@ class Parser(AbstractParser):
i += 1
groups = data[i]
- if i - 1 >= 0:
+ if i - 1 >= min_i:
# TODO: le jour où la version minimale supportée sera
# Python 3.7, il sera possible de remplacer OrderedDict
# par un dictionnaire classique.
@@ -112,7 +117,7 @@ class Parser(AbstractParser):
course.name = ", ".join(names.keys())
else:
course.name = "Sans nom"
- if i - 2 >= 0:
+ if i - 2 >= min_i:
course.type = data[i - 2]
if len(data) >= i + 2:
rooms = data[i + 1]