From 4f373682e8d5e138262b4584533ad9e460a36459 Mon Sep 17 00:00:00 2001 From: Niko Strijbol Date: Wed, 24 Jan 2024 23:25:44 +0100 Subject: [PATCH] Implement allergens for vegetables --- server/scraper/resto/menu.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/server/scraper/resto/menu.py b/server/scraper/resto/menu.py index f3204c22..59c81893 100755 --- a/server/scraper/resto/menu.py +++ b/server/scraper/resto/menu.py @@ -166,7 +166,8 @@ "warme maaltijden: vlees", "groenten bij warme maaltijden", "zetmeel", - "soep" + "soep", + "groenten bij warme maaltijden" ] @@ -314,6 +315,7 @@ def get_day_menu(which, url, allergens: Dict[str, str]): # system) day_menu = pq(url=url) vegetables = [] + vegetables2 = [] meats = [] soups = [] @@ -399,6 +401,20 @@ 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}.") @@ -406,7 +422,7 @@ def get_day_menu(which, url, allergens: Dict[str, str]): 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