Skip to content

Commit

Permalink
Fix erroneous space in specification if unit and quantity are None
Browse files Browse the repository at this point in the history
  • Loading branch information
felixschndr committed Jan 26, 2025
1 parent 2fe6ea8 commit 35e94be
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions source/ingredient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 35e94be

Please # to comment.