mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
fixed issue with new fraction importer
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user