From b07ceef46be030b0c82855149b1fe5d55bc4cebb Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 7 Mar 2011 19:47:25 +0100 Subject: Made the mensa module a bit more flexible --- modules/mensa.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/mensa.py b/modules/mensa.py index 4867670..d8ee447 100644 --- a/modules/mensa.py +++ b/modules/mensa.py @@ -79,7 +79,7 @@ class Module(ModuleBase): row = handle_data_row(data, pos) if not row: - return False + break meals.append(row[0]) pos = row[1] @@ -113,6 +113,12 @@ class Module(ModuleBase): stripunescape = (lambda item: (unescape(item[0].strip()), unescape(item[1].strip()))) meals = map(lambda item: map(stripunescape, item), meals) + if len(meals) == 0: + return False + + while len(meals) < 6: + meals.insert(len(meals)-1, [[None], [None], [None], [None], [None]]) + reply = 'Mensa-Menü für den %s\n\n' % day.strftime('%d.%m.%y') if meals[0][weekday][0]: reply += 'Eintopf: %s (%s)\n' % meals[0][weekday] @@ -122,10 +128,10 @@ class Module(ModuleBase): reply += 'Hauptgericht 2: %s (%s)\n' % meals[3][weekday] if meals[2][weekday][0]: reply += 'Vegetarisches Hauptgericht: %s (%s)\n' % meals[2][weekday] - #if meals[4][weekday][0]: - # reply += 'Wok: %s (%s)\n' % meals[4][weekday] if meals[4][weekday][0]: - reply += 'Beilagen: %s (%s)\n' % meals[4][weekday] + reply += 'Wok: %s (%s)\n' % meals[4][weekday] + if meals[5][weekday][0]: + reply += 'Beilagen: %s (%s)\n' % meals[5][weekday] return reply -- cgit v1.2.3