[cuisineaz] strip accents in pattern
This commit is contained in:
parent
b219926ffe
commit
f20f59cdc7
1 changed files with 8 additions and 1 deletions
|
|
@ -22,8 +22,13 @@ from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import CuisineazBrowser
|
from .browser import CuisineazBrowser
|
||||||
|
|
||||||
|
import unicodedata
|
||||||
|
|
||||||
__all__ = ['CuisineazBackend']
|
__all__ = ['CuisineazBackend']
|
||||||
|
|
||||||
|
def strip_accents(s):
|
||||||
|
return ''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn')
|
||||||
|
|
||||||
|
|
||||||
class CuisineazBackend(BaseBackend, ICapRecipe):
|
class CuisineazBackend(BaseBackend, ICapRecipe):
|
||||||
NAME = 'cuisineaz'
|
NAME = 'cuisineaz'
|
||||||
|
|
@ -41,7 +46,9 @@ class CuisineazBackend(BaseBackend, ICapRecipe):
|
||||||
return self.browser.get_recipe(id)
|
return self.browser.get_recipe(id)
|
||||||
|
|
||||||
def iter_recipes(self, pattern):
|
def iter_recipes(self, pattern):
|
||||||
return self.browser.iter_recipes(pattern.encode('utf-8'))
|
# the search form does that so the url is clean of special chars
|
||||||
|
# we go directly on search results by the url so we strip it too
|
||||||
|
return self.browser.iter_recipes(strip_accents(pattern).encode('utf-8'))
|
||||||
|
|
||||||
def fill_recipe(self, recipe, fields):
|
def fill_recipe(self, recipe, fields):
|
||||||
if 'nb_person' in fields or 'instructions' in fields:
|
if 'nb_person' in fields or 'instructions' in fields:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue