From 35e94be2bceaacb8944ef08a84d9fee8fc65e58c Mon Sep 17 00:00:00 2001 From: Felix Schneider Date: Sun, 26 Jan 2025 13:07:49 +0100 Subject: [PATCH] Fix erroneous space in specification if unit and quantity are None --- source/ingredient.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/ingredient.py b/source/ingredient.py index d62da0a..961eb79 100644 --- a/source/ingredient.py +++ b/source/ingredient.py @@ -19,7 +19,10 @@ def _get_name(raw_data: dict) -> str: @staticmethod def _get_specification(raw_data: dict) -> str: - return f"{Ingredient._get_quantity(raw_data)}{Ingredient._get_unit(raw_data)}{Ingredient._get_note(raw_data)}" + specification = f"{Ingredient._get_quantity(raw_data)}{Ingredient._get_unit(raw_data)}" + note = Ingredient._get_note(raw_data) + specification += note if specification == "" else f" {note}" + return specification @staticmethod def _get_quantity(raw_data: dict) -> str: @@ -53,7 +56,7 @@ def _get_note(raw_data: dict) -> str: if not raw_data["note"]: return "" - return f" ({raw_data['note']})" + return f"({raw_data['note']})" @staticmethod def is_ignored(name_of_ingredient: str, ignored_ingredients: list[Ingredient]) -> bool: