Handle offers without a category

This commit is contained in:
f4lco
2021-01-27 20:54:48 +01:00
parent 4fad78261a
commit 9850231c4f
4 changed files with 2395 additions and 1 deletions
+8 -1
View File
@@ -42,13 +42,20 @@ def _prices(offer):
def _process_day(builder, day):
for offer in _offers(day):
builder.addMeal(date=day['data'],
category=offer['titel'],
category=_category(offer),
name=offer['beschreibung'],
notes=_notes(offer),
prices=_prices(offer),
roles=None)
def _category(offer):
# 'Angebot' is just a placeholder. We cannot tell if 'Angebot' or 'Info' is
# more appropriate because offers lacking the 'titel' attribute are real
# meals or informational texts.
return offer['titel'] or 'Angebot'
def _offers(day):
offers = day['angebote']
if isinstance(offers, list):