[cuisineaz] pep8fication
This commit is contained in:
parent
b0526d65a0
commit
f0abb61123
4 changed files with 61 additions and 49 deletions
|
|
@ -25,6 +25,7 @@ from .pages import RecipePage, ResultsPage
|
||||||
|
|
||||||
__all__ = ['CuisineazBrowser']
|
__all__ = ['CuisineazBrowser']
|
||||||
|
|
||||||
|
|
||||||
class CuisineazBrowser(BaseBrowser):
|
class CuisineazBrowser(BaseBrowser):
|
||||||
DOMAIN = 'www.cuisineaz.com'
|
DOMAIN = 'www.cuisineaz.com'
|
||||||
PROTOCOL = 'http'
|
PROTOCOL = 'http'
|
||||||
|
|
@ -36,7 +37,8 @@ class CuisineazBrowser(BaseBrowser):
|
||||||
}
|
}
|
||||||
|
|
||||||
def iter_recipes(self, pattern):
|
def iter_recipes(self, pattern):
|
||||||
self.location('http://www.cuisineaz.com/recettes/recherche_v2.aspx?recherche=%s' % (pattern.replace(' ','-')))
|
self.location('http://www.cuisineaz.com/recettes/recherche_v2.aspx?recherche=%s' % (
|
||||||
|
pattern.replace(' ', '-')))
|
||||||
assert self.is_on_page(ResultsPage)
|
assert self.is_on_page(ResultsPage)
|
||||||
return self.page.iter_recipes()
|
return self.page.iter_recipes()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ class ResultsPage(BasePage):
|
||||||
|
|
||||||
link = self.parser.select(div, 'a.rechRecetTitle', 1)
|
link = self.parser.select(div, 'a.rechRecetTitle', 1)
|
||||||
title = unicode(link.text)
|
title = unicode(link.text)
|
||||||
id = unicode(link.attrib.get('href','').split('/')[-1].replace('.aspx',''))
|
id = unicode(link.attrib.get('href', '').split(
|
||||||
|
'/')[-1].replace('.aspx', ''))
|
||||||
|
|
||||||
short_description = u''
|
short_description = u''
|
||||||
ldivprix = self.parser.select(div, 'div.prix')
|
ldivprix = self.parser.select(div, 'div.prix')
|
||||||
|
|
@ -51,11 +51,14 @@ class ResultsPage(BasePage):
|
||||||
if len(spanprix) > 0:
|
if len(spanprix) > 0:
|
||||||
nbprixneg = unicode(spanprix[0].text).count(u'€')
|
nbprixneg = unicode(spanprix[0].text).count(u'€')
|
||||||
nbprixtot = unicode(divprix.text_content()).count(u'€')
|
nbprixtot = unicode(divprix.text_content()).count(u'€')
|
||||||
short_description += u'Cost: %s/%s ; '%(nbprixtot - nbprixneg, nbprixtot)
|
short_description += u'Cost: %s/%s ; ' % (
|
||||||
|
nbprixtot - nbprixneg, nbprixtot)
|
||||||
|
|
||||||
short_description += unicode(' '.join(self.parser.select(div,'div.rechResume',1).text_content().split()).strip()).replace(u'€','')
|
short_description += unicode(' '.join(self.parser.select(
|
||||||
|
div, 'div.rechResume', 1).text_content().split()).strip()).replace(u'€', '')
|
||||||
short_description += u' '
|
short_description += u' '
|
||||||
short_description += unicode(' '.join(self.parser.select(div,'div.rechIngredients',1).text_content().split()).strip())
|
short_description += unicode(' '.join(self.parser.select(
|
||||||
|
div, 'div.rechIngredients', 1).text_content().split()).strip())
|
||||||
|
|
||||||
recipe = Recipe(id, title)
|
recipe = Recipe(id, title)
|
||||||
recipe.thumbnail_url = thumbnail_url
|
recipe.thumbnail_url = thumbnail_url
|
||||||
|
|
@ -81,8 +84,10 @@ class RecipePage(BasePage):
|
||||||
instructions = NotAvailable
|
instructions = NotAvailable
|
||||||
comments = []
|
comments = []
|
||||||
|
|
||||||
title = unicode(self.parser.select(self.document.getroot(),'div#ficheRecette h1.fn.recetteH1',1).text)
|
title = unicode(self.parser.select(
|
||||||
main = self.parser.select(self.document.getroot(),'div#ficheRecette',1)
|
self.document.getroot(), 'div#ficheRecette h1.fn.recetteH1', 1).text)
|
||||||
|
main = self.parser.select(
|
||||||
|
self.document.getroot(), 'div#ficheRecette', 1)
|
||||||
imgillu = self.parser.select(main, 'div#recetteLeft img.photo')
|
imgillu = self.parser.select(main, 'div#recetteLeft img.photo')
|
||||||
if len(imgillu) > 0:
|
if len(imgillu) > 0:
|
||||||
picture_url = unicode(imgillu[0].attrib.get('src', ''))
|
picture_url = unicode(imgillu[0].attrib.get('src', ''))
|
||||||
|
|
@ -105,16 +110,21 @@ class RecipePage(BasePage):
|
||||||
ingredients.append(ingtxt)
|
ingredients.append(ingtxt)
|
||||||
|
|
||||||
instructions = u''
|
instructions = u''
|
||||||
l_divinst = self.parser.select(main,'div#preparation span.instructions div')
|
l_divinst = self.parser.select(
|
||||||
|
main, 'div#preparation span.instructions div')
|
||||||
for inst in l_divinst:
|
for inst in l_divinst:
|
||||||
instructions += '%s: ' % inst.text
|
instructions += '%s: ' % inst.text
|
||||||
instructions += '%s\n' % inst.getnext().text
|
instructions += '%s\n' % inst.getnext().text
|
||||||
|
|
||||||
for divcom in self.parser.select(self.document.getroot(), 'div.comment'):
|
for divcom in self.parser.select(self.document.getroot(), 'div.comment'):
|
||||||
author = unicode(self.parser.select(divcom,'div.commentAuthor span',1).text)
|
author = unicode(self.parser.select(
|
||||||
date = unicode(self.parser.select(divcom,'div.commentDate',1).text)
|
divcom, 'div.commentAuthor span', 1).text)
|
||||||
comtxt = unicode(self.parser.select(divcom,'p',1).text_content().strip())
|
date = unicode(self.parser.select(
|
||||||
comments.append('author: %s, date: %s, text: %s'%(author, date, comtxt))
|
divcom, 'div.commentDate', 1).text)
|
||||||
|
comtxt = unicode(self.parser.select(
|
||||||
|
divcom, 'p', 1).text_content().strip())
|
||||||
|
comments.append('author: %s, date: %s, text: %s' % (
|
||||||
|
author, date, comtxt))
|
||||||
|
|
||||||
recipe = Recipe(id, title)
|
recipe = Recipe(id, title)
|
||||||
recipe.preparation_time = preparation_time
|
recipe.preparation_time = preparation_time
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
from weboob.tools.test import BackendTest
|
from weboob.tools.test import BackendTest
|
||||||
|
|
||||||
|
|
||||||
class CuisineazTest(BackendTest):
|
class CuisineazTest(BackendTest):
|
||||||
BACKEND = 'cuisineaz'
|
BACKEND = 'cuisineaz'
|
||||||
|
|
||||||
|
|
@ -29,4 +30,3 @@ class CuisineazTest(BackendTest):
|
||||||
assert full_recipe.instructions
|
assert full_recipe.instructions
|
||||||
assert full_recipe.ingredients
|
assert full_recipe.ingredients
|
||||||
assert full_recipe.title
|
assert full_recipe.title
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue