diff options
Diffstat (limited to 'management/commands/_private.py')
-rw-r--r-- | management/commands/_private.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/management/commands/_private.py b/management/commands/_private.py index f14dae6..5b4a7ff 100644 --- a/management/commands/_private.py +++ b/management/commands/_private.py @@ -27,7 +27,8 @@ import requests class Week: def __init__(self, number, start): self.number = number - self.start = timezone.make_aware(datetime.datetime.strptime(start, "%d/%m/%Y")) + self.start = timezone.make_aware( + datetime.datetime.strptime(start, "%d/%m/%Y")) def get_day(self, id): return self.start + datetime.timedelta(id) @@ -58,7 +59,7 @@ def get_from_db_or_create(cls, timetable=None, **kwargs): return obj -def get_events(soup, weeks, year, week, timetable): +def get_events(timetable, year, week, soup, weeks_in_soup): for event in soup.find_all("event"): title = None type_ = None @@ -66,11 +67,12 @@ def get_events(soup, weeks, year, week, timetable): rooms = None notes = None - if weeks[event.rawweeks.text].number == week and \ - weeks[event.rawweeks.text].year == year and \ + if weeks_in_soup[event.rawweeks.text].number == week and \ + weeks_in_soup[event.rawweeks.text].year == year and \ event.resources.group is not None and \ event.starttime is not None and event.endtime is not None: - date = weeks[event.rawweeks.text].get_day(int(event.day.text)) + date = weeks_in_soup[event.rawweeks.text].get_day(int( + event.day.text)) begin = add_time(date, datetime.datetime.strptime( event.starttime.text, "%H:%M")) @@ -104,7 +106,8 @@ def get_events(soup, weeks, year, week, timetable): def get_weeks(soup): weeks = {} for span in soup.find_all("span"): - weeks[span.alleventweeks.text] = Week(int(span.title.text), span["date"]) + weeks[span.alleventweeks.text] = Week(int(span.title.text), + span["date"]) return weeks |