make invalid ingredients/units into warnings
This commit is contained in:
parent
da38086e98
commit
a4064a941d
1 changed files with 12 additions and 3 deletions
15
recipes.py
15
recipes.py
|
@ -108,7 +108,10 @@ class PriceDB:
|
|||
self.unit = None
|
||||
if "unit" in dct:
|
||||
assert_type(dct, "unit", str)
|
||||
self.unit = units.get(dct["unit"])
|
||||
try:
|
||||
self.unit = units.get(dct["unit"])
|
||||
except RuntimeError as e:
|
||||
issues.append(str(e))
|
||||
return issues
|
||||
|
||||
|
||||
|
@ -120,7 +123,10 @@ class IngredientInstance:
|
|||
assert_type(dct, "name", str)
|
||||
self.name = dct["name"]
|
||||
|
||||
self.ingredient = ingredients.get(self.name)
|
||||
try:
|
||||
self.ingredient = ingredients.get(self.name)
|
||||
except RuntimeError as e:
|
||||
issues.append(str(e))
|
||||
|
||||
self.amount = 1.0
|
||||
if "amount" in dct:
|
||||
|
@ -134,7 +140,10 @@ class IngredientInstance:
|
|||
self.unit = None
|
||||
if "unit" in dct:
|
||||
assert_type(dct, "unit", str)
|
||||
self.unit = units.get(dct["unit"])
|
||||
try:
|
||||
self.unit = units.get(dct["unit"])
|
||||
except RuntimeError as e:
|
||||
issues.append(str(e))
|
||||
|
||||
self.note = ""
|
||||
if "note" in dct:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue