fixed issue with new fraction importer

This commit is contained in:
vabene1111
2020-12-15 21:52:56 +01:00
parent 77fae46aee
commit dd07c56ede

View File

@@ -79,10 +79,11 @@ def find_recipe_json(ld_json, url):
ingredient = " ".join(ingredient_split[2:]) ingredient = " ".join(ingredient_split[2:])
unit = ingredient_split[1] unit = ingredient_split[1]
if 'fraction' in unicodedata.decomposition(ingredient_split[0]): try:
frac_split = unicodedata.decomposition(ingredient_split[0]).split() if 'fraction' in unicodedata.decomposition(ingredient_split[0]):
amount = round(float((frac_split[1]).replace('003', '')) / float((frac_split[3]).replace('003', '')), 3) frac_split = unicodedata.decomposition(ingredient_split[0]).split()
else: amount = round(float((frac_split[1]).replace('003', '')) / float((frac_split[3]).replace('003', '')), 3)
except TypeError: # raised by unicodedata.decomposition if there was no unicode character in parsed data
try: try:
amount = float(ingredient_split[0].replace(',', '.')) amount = float(ingredient_split[0].replace(',', '.'))
except ValueError: except ValueError: