From e377df2ab0d626830b6695f6fe6bf038783b42b8 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Tue, 15 Mar 2022 12:51:15 -0800 Subject: [PATCH] capture #1043 (#1055) --- .flake8 | 2 +- mealie/services/scraper/cleaner.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index c4ae7060..57e78331 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -ignore = [ +extend-ignore = [ E501 # Line Length - See Black Config in pyproject.toml E402 # Import Not at Top of File ] diff --git a/mealie/services/scraper/cleaner.py b/mealie/services/scraper/cleaner.py index 0f65b40c..948d87d1 100644 --- a/mealie/services/scraper/cleaner.py +++ b/mealie/services/scraper/cleaner.py @@ -98,7 +98,12 @@ def clean_nutrition(nutrition: Optional[dict]) -> dict[str, str]: output_nutrition = {key: val.replace(",", ".") for key, val in output_nutrition.items()} - if "sodiumContent" in nutrition and "m" not in nutrition["sodiumContent"] and "g" in nutrition["sodiumContent"]: + if ( + "sodiumContent" in nutrition + and type(nutrition["sodiumContent"]) == str + and "m" not in nutrition["sodiumContent"] + and "g" in nutrition["sodiumContent"] + ): # Sodium is in grams. Parse its value, multiple by 1k and return to string. try: output_nutrition["sodiumContent"] = str(float(output_nutrition["sodiumContent"]) * 1000)