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