autopep8 with 120 chars line length on my modules
This commit is contained in:
parent
6a7bc0924d
commit
5d923bc73b
39 changed files with 434 additions and 426 deletions
|
|
@ -30,27 +30,28 @@ class ResultsPage(BasePage):
|
|||
""" Page which contains results as a list of recipies
|
||||
"""
|
||||
def iter_recipes(self):
|
||||
for div in self.parser.select(self.document.getroot(),'div.m_search_result'):
|
||||
tds = self.parser.select(div,'td')
|
||||
for div in self.parser.select(self.document.getroot(), 'div.m_search_result'):
|
||||
tds = self.parser.select(div, 'td')
|
||||
if len(tds) == 2:
|
||||
title = NotAvailable
|
||||
thumbnail_url = NotAvailable
|
||||
short_description = NotAvailable
|
||||
imgs = self.parser.select(tds[0],'img')
|
||||
imgs = self.parser.select(tds[0], 'img')
|
||||
if len(imgs) > 0:
|
||||
thumbnail_url = unicode(imgs[0].attrib.get('src',''))
|
||||
link = self.parser.select(tds[1],'div.m_search_titre_recette a',1)
|
||||
thumbnail_url = unicode(imgs[0].attrib.get('src', ''))
|
||||
link = self.parser.select(tds[1], 'div.m_search_titre_recette a', 1)
|
||||
title = unicode(link.text)
|
||||
id = link.attrib.get('href','').replace('.aspx','').replace('/recettes/recette_','')
|
||||
short_description = unicode(' '.join(self.parser.select(tds[1],'div.m_search_result_part4',1).text.strip().split('\n')))
|
||||
id = link.attrib.get('href', '').replace('.aspx', '').replace('/recettes/recette_', '')
|
||||
short_description = unicode(' '.join(self.parser.select(tds[
|
||||
1], 'div.m_search_result_part4', 1).text.strip().split('\n')))
|
||||
|
||||
recipe = Recipe(id,title)
|
||||
recipe = Recipe(id, title)
|
||||
recipe.thumbnail_url = thumbnail_url
|
||||
recipe.short_description= short_description
|
||||
recipe.instructions = NotLoaded
|
||||
recipe.ingredients = NotLoaded
|
||||
recipe.nb_person = NotLoaded
|
||||
recipe.cooking_time = NotLoaded
|
||||
recipe.short_description = short_description
|
||||
recipe.instructions = NotLoaded
|
||||
recipe.ingredients = NotLoaded
|
||||
recipe.nb_person = NotLoaded
|
||||
recipe.cooking_time = NotLoaded
|
||||
recipe.preparation_time = NotLoaded
|
||||
yield recipe
|
||||
|
||||
|
|
@ -68,30 +69,30 @@ class RecipePage(BasePage):
|
|||
instructions = NotAvailable
|
||||
comments = []
|
||||
|
||||
title = unicode(self.parser.select(self.document.getroot(),'h1.m_title',1).text_content().strip())
|
||||
main = self.parser.select(self.document.getroot(),'div.m_content_recette_main',1)
|
||||
preparation_time = int(self.parser.select(main,'p.m_content_recette_info span.preptime',1).text_content())
|
||||
cooking_time = int(self.parser.select(main,'p.m_content_recette_info span.cooktime',1).text_content())
|
||||
ing_header_line = self.parser.select(main,'p.m_content_recette_ingredients span',1).text_content()
|
||||
title = unicode(self.parser.select(self.document.getroot(), 'h1.m_title', 1).text_content().strip())
|
||||
main = self.parser.select(self.document.getroot(), 'div.m_content_recette_main', 1)
|
||||
preparation_time = int(self.parser.select(main, 'p.m_content_recette_info span.preptime', 1).text_content())
|
||||
cooking_time = int(self.parser.select(main, 'p.m_content_recette_info span.cooktime', 1).text_content())
|
||||
ing_header_line = self.parser.select(main, 'p.m_content_recette_ingredients span', 1).text_content()
|
||||
if '(pour' in ing_header_line and ')' in ing_header_line:
|
||||
nb_person = int(ing_header_line.split('pour ')[-1].split('personnes)')[0].split()[0])
|
||||
ingredients = self.parser.select(main,'p.m_content_recette_ingredients',1).text_content().strip().split('- ')
|
||||
ingredients=ingredients[1:]
|
||||
rinstructions = self.parser.select(main,'div.m_content_recette_todo',1).text_content().strip()
|
||||
ingredients = self.parser.select(main, 'p.m_content_recette_ingredients', 1).text_content().strip().split('- ')
|
||||
ingredients = ingredients[1:]
|
||||
rinstructions = self.parser.select(main, 'div.m_content_recette_todo', 1).text_content().strip()
|
||||
instructions = u''
|
||||
for line in rinstructions.split('\n'):
|
||||
instructions += '%s\n'%line.strip()
|
||||
instructions += '%s\n' % line.strip()
|
||||
instructions = instructions.strip('\n')
|
||||
imgillu = self.parser.select(self.document.getroot(),'a.m_content_recette_illu img')
|
||||
imgillu = self.parser.select(self.document.getroot(), 'a.m_content_recette_illu img')
|
||||
if len(imgillu) > 0:
|
||||
picture_url = unicode(imgillu[0].attrib.get('src',''))
|
||||
for divcom in self.parser.select(self.document.getroot(),'div.m_commentaire_row'):
|
||||
note = self.parser.select(divcom,'div.m_commentaire_note span',1).text.strip()
|
||||
user = self.parser.select(divcom,'div.m_commentaire_content span',1).text.strip()
|
||||
content = self.parser.select(divcom,'div.m_commentaire_content p',1).text.strip()
|
||||
comments.append(u'user: %s, note: %s, comment: %s'%(user,note,content))
|
||||
picture_url = unicode(imgillu[0].attrib.get('src', ''))
|
||||
for divcom in self.parser.select(self.document.getroot(), 'div.m_commentaire_row'):
|
||||
note = self.parser.select(divcom, 'div.m_commentaire_note span', 1).text.strip()
|
||||
user = self.parser.select(divcom, 'div.m_commentaire_content span', 1).text.strip()
|
||||
content = self.parser.select(divcom, 'div.m_commentaire_content p', 1).text.strip()
|
||||
comments.append(u'user: %s, note: %s, comment: %s' % (user, note, content))
|
||||
|
||||
recipe = Recipe(id,title)
|
||||
recipe = Recipe(id, title)
|
||||
recipe.preparation_time = preparation_time
|
||||
recipe.cooking_time = cooking_time
|
||||
recipe.nb_person = nb_person
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue