default unit is now piece, not None
This commit is contained in:
parent
d42cb1beee
commit
a41aa52993
1 changed files with 4 additions and 2 deletions
|
@ -13,6 +13,8 @@ import jsonschema.exceptions
|
|||
class Context:
|
||||
def __init__(self) -> None:
|
||||
self.units = Units(self)
|
||||
self.default_unit = Unit(self, {"name": "piece"})
|
||||
self.units.units.append(self.default_unit)
|
||||
self.ingredients = Ingredients(self)
|
||||
self.issues: List[str] = []
|
||||
|
||||
|
@ -159,7 +161,7 @@ class PriceDB(Element):
|
|||
if self["unit"] is None:
|
||||
self.ctx.issues.append(f"unknown unit {unitstr}")
|
||||
else:
|
||||
self["unit"] = None
|
||||
self["unit"] = self.ctx.default_unit
|
||||
|
||||
|
||||
class IngredientInstance(Element):
|
||||
|
@ -177,7 +179,7 @@ class IngredientInstance(Element):
|
|||
if self["unit"] is None:
|
||||
self.ctx.issues.append("unknown unit {unitstr}")
|
||||
else:
|
||||
self["unit"] = None
|
||||
self["unit"] = self.ctx.default_unit
|
||||
|
||||
if "note" not in dct:
|
||||
self["note"] = ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue