diff options
-rw-r--r-- | management/parsers/ups2018.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/management/parsers/ups2018.py b/management/parsers/ups2018.py index f1da5bf..6d39c8f 100644 --- a/management/parsers/ups2018.py +++ b/management/parsers/ups2018.py @@ -92,9 +92,7 @@ class Parser(AbstractParser): def __get_event(self, event, today, beginning_of_month, end_of_month, year, week): - begin = timezone.make_aware( - datetime.strptime(event["start"], "%Y-%m-%dT%H:%M:%S") - ) + begin = event["begin"] end = timezone.make_aware( datetime.strptime(event["end"], "%Y-%m-%dT%H:%M:%S") ) @@ -108,7 +106,7 @@ class Parser(AbstractParser): if event_year != year or event_week != week: return - data = event["text"].split("<br>") + data = event["data"] rooms = None if data[0] == "Global Event": return @@ -185,10 +183,23 @@ class Parser(AbstractParser): return None # Pas de date de mise à jour dans ce format def get_weeks(self): - # FIXME: détection automatique à partir des événements présents - beginning, _ = get_week(*get_current_week()) - self.weeks = {"1": beginning} + weeks = set() + for i, month in enumerate(self.events): + for event in month: + begin = timezone.make_aware( + datetime.strptime(event["start"], "%Y-%m-%dT%H:%M:%S") + ) + + data = event["text"].split("<br>") + + event["begin"] = begin + event["data"] = data + + if data[0] != "Global Event": + beginning, _ = get_week(*begin.isocalendar()[:2]) + weeks.add(beginning) + self.weeks = {str(i + 1): week for i, week in enumerate(sorted(weeks))} return self.weeks def ajax_req(self, month): |