misc cleanup

This commit is contained in:
smilerz
2021-05-02 20:06:53 -05:00
parent e345d2eb39
commit 984d5aae11
5 changed files with 7 additions and 8 deletions

View File

@ -14,11 +14,10 @@ from recipe_scrapers._utils import get_minutes
def get_from_scraper(scrape, space): def get_from_scraper(scrape, space):
# converting the scrape_me object to the existing json format based on ld+json # converting the scrape_me object to the existing json format based on ld+json
recipe_json = {} recipe_json = {}
try: try:
recipe_json['name'] = parse_name(scrape.title() or None) recipe_json['name'] = parse_name(scrape.title() or None)
except (TypeError, AttributeError, ElementNotFoundInHtml, NotImplementedError): except Exception:
recipe_json['name'] = None recipe_json['name'] = None
if not recipe_json['name']: if not recipe_json['name']:
try: try:
@ -28,7 +27,7 @@ def get_from_scraper(scrape, space):
try: try:
description = scrape.schema.data.get("description") or '' description = scrape.schema.data.get("description") or ''
except (AttributeError, ElementNotFoundInHtml, NotImplementedError, SchemaOrgException): except Exception:
description = '' description = ''
recipe_json['description'] = parse_description(description) recipe_json['description'] = parse_description(description)

View File

@ -25,9 +25,9 @@ def text_scraper(text, url=None):
class TextScraper(scraper_class): class TextScraper(scraper_class):
def __init__( def __init__(
self, self,
page_data, page_data,
url=None url=None
): ):
self.wild_mode = False self.wild_mode = False
# self.exception_handling = None # TODO add new method here, old one was deprecated # self.exception_handling = None # TODO add new method here, old one was deprecated

View File

@ -722,6 +722,7 @@
msg += err.bodyText msg += err.bodyText
} else { } else {
msg += ' ' + err.status + ' ' + err.statusText msg += ' ' + err.status + ' ' + err.statusText
this.preview = true
} }
this.makeToast(gettext('Error'), msg, 'danger') this.makeToast(gettext('Error'), msg, 'danger')
}) })

View File

@ -680,7 +680,6 @@ def recipe_from_source(request):
'images': images, 'images': images,
}) })
else: else:
return JsonResponse( return JsonResponse(
{ {

View File

@ -163,7 +163,7 @@ def import_url(request):
elif isinstance(ing['amount'], float) \ elif isinstance(ing['amount'], float) \
or isinstance(ing['amount'], int): or isinstance(ing['amount'], int):
ingredient.amount = ing['amount'] ingredient.amount = ing['amount']
ingredient.note = ing['note'] if 'note' in ing else '' ingredient.note = ing['note'].strip() if 'note' in ing else ''
ingredient.save() ingredient.save()
step.ingredients.add(ingredient) step.ingredients.add(ingredient)