Skip to content

Commit

Permalink
Implement allergens for vegetables
Browse files Browse the repository at this point in the history
  • Loading branch information
niknetniko committed Jan 24, 2024
1 parent 0f10162 commit 4f37368
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions server/scraper/resto/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@
"warme maaltijden: vlees",
"groenten bij warme maaltijden",
"zetmeel",
"soep"
"soep",
"groenten bij warme maaltijden"
]


Expand Down Expand Up @@ -314,6 +315,7 @@ def get_day_menu(which, url, allergens: Dict[str, str]):
# system)
day_menu = pq(url=url)
vegetables = []
vegetables2 = []
meats = []
soups = []

Expand Down Expand Up @@ -399,14 +401,28 @@ def get_day_menu(which, url, allergens: Dict[str, str]):
meats.append(dict(price=price, name=name, kind=kind, hot=hot_cold, allergens=food_allergens))
elif HEADING_TO_TYPE[last_heading] == 'vegetables':
vegetables.append(meal)
if ":" in meal:
kind, name = meal.split(":")
if kind != 'vegan' and kind != 'vegetarian':
kind = 'meat'
else:
kind = 'meat'
name = meal
vegetable_allergens = find_allergens_for_food(allergens, name)
vegetable = {
'name': meal,
'kind': kind,
'allergens': vegetable_allergens
}
vegetables2.append(vegetable)
else:
raise ValueError(f"Oops, HEADING_TO_TYPE contains unknown value for {last_heading}.")

# sometimes the closed indicator has a different layout.
if not vegetables and not soups and not meats:
return dict(open=False)

r = dict(open=True, vegetables=vegetables, soup=soups, meat=meats)
r = dict(open=True, vegetables=vegetables, vegetables2=vegetables2, soup=soups, meat=meats)
return r


Expand Down

0 comments on commit 4f37368

Please sign in to comment.