Add choices to dishes in semantic actions
This commit is contained in:
parent
1d9e7cc170
commit
5fcac5f937
1 changed files with 11 additions and 1 deletions
|
@ -19,11 +19,19 @@ def filter_instance(cls, iterable):
|
||||||
|
|
||||||
class HldsSemanticActions:
|
class HldsSemanticActions:
|
||||||
def location(self, ast):
|
def location(self, ast):
|
||||||
|
choices = {choice.id: choice for choice in filter_instance(Choice, ast["items_"])}
|
||||||
|
dishes = filter_instance(Dish, ast["items_"])
|
||||||
|
for dish in dishes:
|
||||||
|
for i, choice in enumerate(dish.choices):
|
||||||
|
if not isinstance(choice, Choice):
|
||||||
|
assert "id" in choice
|
||||||
|
dish.choices[i] = choices[choice["id"]]
|
||||||
|
|
||||||
return Location(
|
return Location(
|
||||||
ast["id"],
|
ast["id"],
|
||||||
name=ast["name"],
|
name=ast["name"],
|
||||||
attributes={att["key"]: att["value"] for att in ast["attributes"]},
|
attributes={att["key"]: att["value"] for att in ast["attributes"]},
|
||||||
dishes=filter_instance(Dish, ast["items_"]),
|
dishes=dishes,
|
||||||
)
|
)
|
||||||
|
|
||||||
def base_block(self, ast):
|
def base_block(self, ast):
|
||||||
|
@ -59,6 +67,8 @@ class HldsSemanticActions:
|
||||||
tags=ast["tags"],
|
tags=ast["tags"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
noindent_choice_entry = indent_choice_entry
|
||||||
|
|
||||||
def price(self, ast):
|
def price(self, ast):
|
||||||
return "{0[currency]} {0[value]}".format(ast)
|
return "{0[currency]} {0[value]}".format(ast)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue