catch error when trying to parse into ingredient/note

This commit is contained in:
Jakob Wenzel
2021-01-07 19:49:02 +01:00
parent 8ed2562454
commit 29903af085

View File

@@ -129,6 +129,9 @@ def parse(x):
# only two arguments, first one is the amount which means this is the ingredient # only two arguments, first one is the amount which means this is the ingredient
ingredient = tokens[1] ingredient = tokens[1]
except ValueError: except ValueError:
# can't parse first argument as amount -> no unit -> parse everything as ingredient try:
ingredient, note = parse_ingredient(tokens) # can't parse first argument as amount -> no unit -> parse everything as ingredient
ingredient, note = parse_ingredient(tokens)
except ValueError:
ingredient = ' '.join(tokens[1:])
return amount, unit.strip(), ingredient.strip(), note.strip() return amount, unit.strip(), ingredient.strip(), note.strip()