Another correction for the mensa module
This commit is contained in:
parent
7b39527686
commit
e5cd4bb203
1 changed files with 11 additions and 26 deletions
|
@ -59,7 +59,7 @@ class Module(ModuleBase):
|
|||
r = re.compile(r'\s*<td class="schrift_(gerichte|spezial)">(.+?)</td>', re.DOTALL)
|
||||
match = r.match(mealstr, pos)
|
||||
while match:
|
||||
meals.append((match.group(2), match.group(1) == 'spezial'))
|
||||
meals.append(match.group(2))
|
||||
|
||||
if len(meals) >= 4:
|
||||
break
|
||||
|
@ -102,36 +102,21 @@ class Module(ModuleBase):
|
|||
s = s.replace('"', '"')
|
||||
s = s.replace('<br />', ' ‒ ')
|
||||
s = re.sub('\s+', ' ', s)
|
||||
s = re.sub(r'<span[^>]*>(.+?)</span>', r'\1', s)
|
||||
return s
|
||||
|
||||
meals = map(lambda (s, special): (unescape(s), special), meals)
|
||||
meals = map(unescape, meals)
|
||||
prices = map(unescape, prices)
|
||||
|
||||
reply = 'Mensa-Menü für den %s\n\n' % day.strftime('%d.%m.%y')
|
||||
if meals[0][0]:
|
||||
if meals[0][1]:
|
||||
reply += 'Mensatipp: '
|
||||
else:
|
||||
reply += 'Eintopf: '
|
||||
reply += '%s (%s)\n' % (meals[0][0], prices[0])
|
||||
if meals[1][0]:
|
||||
if meals[1][1]:
|
||||
reply += 'Mensatipp: '
|
||||
else:
|
||||
reply += 'Hauptgericht 1: '
|
||||
reply += '%s (%s)\n' % (meals[1][0], prices[1])
|
||||
if meals[2][0]:
|
||||
if meals[2][1]:
|
||||
reply += 'Mensatipp: '
|
||||
else:
|
||||
reply += 'Hauptgericht 2: '
|
||||
reply += '%s (%s)\n' % (meals[2][0], prices[2])
|
||||
if meals[3][0]:
|
||||
if meals[3][1]:
|
||||
reply += 'Mensatipp: '
|
||||
else:
|
||||
reply += 'Vegetarisches Hauptgericht: '
|
||||
reply += '%s (%s)\n' % (meals[3][0], prices[3])
|
||||
if meals[0]:
|
||||
reply += 'Eintopf: %s (%s)\n' % (meals[0].strip(), prices[0].strip())
|
||||
if meals[1]:
|
||||
reply += 'Hauptgericht 1: %s (%s)\n' % (meals[1].strip(), prices[1].strip())
|
||||
if meals[2]:
|
||||
reply += 'Hauptgericht 2: %s (%s)\n' % (meals[2].strip(), prices[2].strip())
|
||||
if meals[3]:
|
||||
reply += 'Vegetarisches Hauptgericht: %s (%s)\n' % (meals[3].strip(), prices[3].strip())
|
||||
|
||||
return reply
|
||||
|
||||
|
|
Reference in a new issue