added mela recipes importer

This commit is contained in:
vabene1111
2022-04-04 21:09:47 +02:00
parent a2954554b5
commit 85aad42529
9 changed files with 118 additions and 44 deletions

View File

@@ -208,6 +208,9 @@ class IngredientParser:
note = ''
unit_note = ''
if len(x) == 0:
raise ValueError('string to parse cannot be empty')
# if the string contains parenthesis early on remove it and place it at the end
# because its likely some kind of note
if re.match('(.){1,6}\s\((.[^\(\)])+\)\s', x):
@@ -271,4 +274,9 @@ class IngredientParser:
if unit_note not in note:
note += ' ' + unit_note
return amount, self.apply_unit_automation(unit.strip()), self.apply_food_automation(ingredient.strip()), note.strip()
try:
unit = self.apply_unit_automation(unit.strip())
except Exception:
pass
return amount, unit, self.apply_food_automation(ingredient.strip()), note.strip()