aboutsummaryrefslogtreecommitdiff
path: root/management/commands/_private.py
diff options
context:
space:
mode:
authorAlban Gruin2017-01-19 21:54:04 +0100
committerAlban Gruin2017-01-19 21:54:04 +0100
commitf55e7ff672ba18291d7361c4c8649e174c9fa556 (patch)
tree887ce3081f0b797dc1de088af3e866652e402d18 /management/commands/_private.py
parentd70781860ba63d457b63a977a2d403ad9aa160b9 (diff)
Amélioration de la qualité du code de la commande "timetables"
Diffstat (limited to 'management/commands/_private.py')
-rw-r--r--management/commands/_private.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/management/commands/_private.py b/management/commands/_private.py
index 7b71fc6..8767aa8 100644
--- a/management/commands/_private.py
+++ b/management/commands/_private.py
@@ -45,27 +45,29 @@ def get_events(soup, weeks, week, timetable):
rooms = None
notes = None
- if weeks[event.rawweeks.text].number != week:
- continue
-
- if event.resources.module is not None:
- title = event.resources.module.item.text
-
- if event.category is not None:
- type_ = event.category.text
+ if weeks[event.rawweeks.text].number == week 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))
+ begin = add_time(date, datetime.datetime.strptime(event.starttime.text, "%H:%M"))
+ end = add_time(date, datetime.datetime.strptime(event.endtime.text, "%H:%M"))
- if event.resources.group is not None:
groups = [get_from_db_or_create(Group, item.text, timetable) for item in event.resources.group.find_all("item")]
- if event.resources.room is not None:
- rooms = [get_from_db_or_create(Room, item.text) for item in event.resources.room.find_all("item")]
-
if event.notes is not None:
notes = event.notes.text
- date = weeks[event.rawweeks.text].get_day(int(event.day.text))
- begin = add_time(date, datetime.datetime.strptime(event.starttime.text, "%H:%M"))
- end = add_time(date, datetime.datetime.strptime(event.endtime.text, "%H:%M"))
+ if event.resources.module is not None:
+ title = event.resources.module.item.text
+ elif notes is not None:
+ title = notes
+ notes = None
+ else:
+ title = "Aucune information"
+
+ if event.category is not None:
+ type_ = event.category.text
+
+ if event.resources.room is not None:
+ rooms = [get_from_db_or_create(Room, item.text) for item in event.resources.room.find_all("item")]
yield title, type_, groups, rooms, notes, begin, end