Made the mensa module a bit more flexible

This commit is contained in:
Matthias Schiffer 2011-03-07 19:47:25 +01:00
parent ab10b2ae43
commit b07ceef46b

View file

@ -79,7 +79,7 @@ class Module(ModuleBase):
row = handle_data_row(data, pos) row = handle_data_row(data, pos)
if not row: if not row:
return False break
meals.append(row[0]) meals.append(row[0])
pos = row[1] pos = row[1]
@ -113,6 +113,12 @@ class Module(ModuleBase):
stripunescape = (lambda item: (unescape(item[0].strip()), unescape(item[1].strip()))) stripunescape = (lambda item: (unescape(item[0].strip()), unescape(item[1].strip())))
meals = map(lambda item: map(stripunescape, item), meals) 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') reply = 'Mensa-Menü für den %s\n\n' % day.strftime('%d.%m.%y')
if meals[0][weekday][0]: if meals[0][weekday][0]:
reply += 'Eintopf: %s (%s)\n' % meals[0][weekday] reply += 'Eintopf: %s (%s)\n' % meals[0][weekday]
@ -122,10 +128,10 @@ class Module(ModuleBase):
reply += 'Hauptgericht 2: %s (%s)\n' % meals[3][weekday] reply += 'Hauptgericht 2: %s (%s)\n' % meals[3][weekday]
if meals[2][weekday][0]: if meals[2][weekday][0]:
reply += 'Vegetarisches Hauptgericht: %s (%s)\n' % meals[2][weekday] 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]: 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 return reply