Add @after/@before on blocks!
This commit is contained in:
parent
da4afef4ad
commit
6094d30aae
@ -372,6 +372,15 @@ class MenuLoader:
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def get_all_menublock_recipes(self, block: MenuBlock) -> Iterable[MenuRecipe]:
|
||||||
|
for child in block.contents:
|
||||||
|
if isinstance(child, MenuRecipe):
|
||||||
|
yield child
|
||||||
|
elif isinstance(child, MenuBlock):
|
||||||
|
yield from self.get_all_menublock_recipes(child)
|
||||||
|
else:
|
||||||
|
raise RuntimeError(f"Unknown child {child!r}")
|
||||||
|
|
||||||
def dagify_recipe(
|
def dagify_recipe(
|
||||||
self,
|
self,
|
||||||
recipe: MenuRecipe,
|
recipe: MenuRecipe,
|
||||||
@ -490,10 +499,15 @@ class MenuLoader:
|
|||||||
target = self.resolve_ref(recipe, recipe_edge.recipe_id)
|
target = self.resolve_ref(recipe, recipe_edge.recipe_id)
|
||||||
|
|
||||||
if isinstance(target, MenuBlock):
|
if isinstance(target, MenuBlock):
|
||||||
# TODO(feature)
|
# Get all recipes and apply the edge to them.
|
||||||
raise NotImplementedError(
|
for target_recipe in self.get_all_menublock_recipes(target):
|
||||||
"@after/@before on block is not yet here sadly"
|
for target_instance in self.get_related_instances(
|
||||||
)
|
sous, for_indices, recipe, target_recipe
|
||||||
|
):
|
||||||
|
if recipe_edge.kind == "after":
|
||||||
|
self._dag.add_ordering(target_instance, instance)
|
||||||
|
elif recipe_edge.kind == "before":
|
||||||
|
self._dag.add_ordering(instance, target_instance)
|
||||||
elif isinstance(target, MenuRecipe):
|
elif isinstance(target, MenuRecipe):
|
||||||
for target_instance in self.get_related_instances(
|
for target_instance in self.get_related_instances(
|
||||||
sous, for_indices, recipe, target
|
sous, for_indices, recipe, target
|
||||||
|
Loading…
Reference in New Issue
Block a user