[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']
|
||||
|
||||
|
||||
class CuisineazBrowser(BaseBrowser):
|
||||
DOMAIN = 'www.cuisineaz.com'
|
||||
PROTOCOL = 'http'
|
||||
|
|
@ -36,7 +37,8 @@ class CuisineazBrowser(BaseBrowser):
|
|||
}
|
||||
|
||||
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)
|
||||
return self.page.iter_recipes()
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ class ResultsPage(BasePage):
|
|||
|
||||
link = self.parser.select(div, 'a.rechRecetTitle', 1)
|
||||
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''
|
||||
ldivprix = self.parser.select(div, 'div.prix')
|
||||
|
|
@ -51,11 +51,14 @@ class ResultsPage(BasePage):
|
|||
if len(spanprix) > 0:
|
||||
nbprixneg = unicode(spanprix[0].text).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 += 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.thumbnail_url = thumbnail_url
|
||||
|
|
@ -81,8 +84,10 @@ class RecipePage(BasePage):
|
|||
instructions = NotAvailable
|
||||
comments = []
|
||||
|
||||
title = unicode(self.parser.select(self.document.getroot(),'div#ficheRecette h1.fn.recetteH1',1).text)
|
||||
main = self.parser.select(self.document.getroot(),'div#ficheRecette',1)
|
||||
title = unicode(self.parser.select(
|
||||
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')
|
||||
if len(imgillu) > 0:
|
||||
picture_url = unicode(imgillu[0].attrib.get('src', ''))
|
||||
|
|
@ -105,16 +110,21 @@ class RecipePage(BasePage):
|
|||
ingredients.append(ingtxt)
|
||||
|
||||
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:
|
||||
instructions += '%s: ' % inst.text
|
||||
instructions += '%s\n' % inst.getnext().text
|
||||
|
||||
for divcom in self.parser.select(self.document.getroot(), 'div.comment'):
|
||||
author = unicode(self.parser.select(divcom,'div.commentAuthor span',1).text)
|
||||
date = unicode(self.parser.select(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))
|
||||
author = unicode(self.parser.select(
|
||||
divcom, 'div.commentAuthor span', 1).text)
|
||||
date = unicode(self.parser.select(
|
||||
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.preparation_time = preparation_time
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
from weboob.tools.test import BackendTest
|
||||
|
||||
|
||||
class CuisineazTest(BackendTest):
|
||||
BACKEND = 'cuisineaz'
|
||||
|
||||
|
|
@ -29,4 +30,3 @@ class CuisineazTest(BackendTest):
|
|||
assert full_recipe.instructions
|
||||
assert full_recipe.ingredients
|
||||
assert full_recipe.title
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue