Add leeway for people using too many >s in their metadata declarations.

This commit is contained in:
Thelie 2022-05-18 10:54:44 +02:00
parent 576a9bb324
commit 0f9f7b237c

View file

@ -68,15 +68,26 @@ def parse_recipe_from_file(path):
serving_keys = ["servings", "serves"] serving_keys = ["servings", "serves"]
time_keys = ["time", "total time"] time_keys = ["time", "total time", "total-time"]
def get_metadata_value(keys, recipe, substitute="N/A"): def get_metadata_value(keys, recipe, substitute="N/A"):
# Sometimes people use too many >s for their metadata…
meta_data = { rem_beginning_duplicate(key, ">").strip(): recipe["metadata"][key] for key in recipe["metadata"].keys() }
for key in keys: for key in keys:
if key in recipe["metadata"].keys(): if key in meta_data.keys():
return recipe["metadata"][key] return meta_data[key]
return substitute return substitute
def rem_beginning_duplicate(in_str, rem_char):
while in_str and in_str[0] == rem_char:
in_str = in_str[1:]
return in_str
def get_step_ingredients(step): def get_step_ingredients(step):
ingredients = [] ingredients = []