diff --git a/source/ingredient.py b/source/ingredient.py index 6e58623..bd76ce3 100644 --- a/source/ingredient.py +++ b/source/ingredient.py @@ -1,10 +1,11 @@ from errors import IgnoredIngredient +from logger_mixin import LoggerMixin -class Ingredient: - def __init__( - self, ingredient_input: dict, ignored_ingredients: list[str] - ): +class Ingredient (LoggerMixin): + def __init__(self, ingredient_input: dict, ignored_ingredients: list[str]): + super().__init__() + self.ingredient_input = ingredient_input self.ignored_ingredients = ignored_ingredients @@ -30,22 +31,31 @@ def parse_input(self) -> None: self._parse_input_with_ingredient_amounts() def _parse_input_with_no_ingredient_amounts(self) -> None: + self.log.debug("Parsing input with no ingredient amount") self.food = self.ingredient_input["display"] def _parse_input_with_ingredient_amounts(self) -> None: + self.log.debug("Parsing input with ingredient amount") + self.log.debug(f"Complete ingredient: {self.ingredient_input}") food_name = self.ingredient_input["food"]["name"] if food_name.lower() in self.ignored_ingredients: raise IgnoredIngredient(f"Found ignored ingredient {food_name}") self.food = food_name + quantity = self.ingredient_input.get("quantity", None) if quantity: self.specification += str(quantity) unit = self.ingredient_input.get("unit", None) + self.log.debug(f"Unit: {unit}") if unit: - self.specification += unit.get("abbreviation", unit["name"]) + unit_formatted = unit.get("abbreviation", unit["name"]) + self.log.debug(f"In if: {unit_formatted}") + self.specification += unit_formatted + + self.log.debug(f"Specification afterwards: {self.specification}") note = self.ingredient_input.get("note", None) if note: