autopep8 with 120 chars line length on my modules

This commit is contained in:
Julien Veyssier 2013-03-16 01:39:35 +01:00
commit 5d923bc73b
39 changed files with 434 additions and 426 deletions

View file

@ -30,35 +30,36 @@ 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.recette_description > div.data'):
links = self.parser.select(div,'div.info > p.title > a.fn')
for div in self.parser.select(self.document.getroot(), 'div.recette_description > div.data'):
links = self.parser.select(div, 'div.info > p.title > a.fn')
if len(links) > 0:
link = links[0]
title = unicode(link.text)
#id = unicode(link.attrib.get('href','').strip('/').replace('.htm','htm'))
id = unicode(self.parser.select(div,'div.carnet-add a',1).attrib.get('href','').split('=')[-1])
# id = unicode(link.attrib.get('href','').strip('/').replace('.htm','htm'))
id = unicode(self.parser.select(div, 'div.carnet-add a', 1).attrib.get('href', '').split('=')[-1])
thumbnail_url = NotAvailable
short_description = NotAvailable
imgs = self.parser.select(div,'img.recipe-image')
imgs = self.parser.select(div, 'img.recipe-image')
if len(imgs) > 0:
thumbnail_url = unicode(imgs[0].attrib.get('src',''))
short_description = unicode(' '.join(self.parser.select(div,'div.infos_column',1).text_content().split()).strip())
imgs_cost = self.parser.select(div,'div.infos_column img')
thumbnail_url = unicode(imgs[0].attrib.get('src', ''))
short_description = unicode(' '.join(self.parser.select(
div, 'div.infos_column', 1).text_content().split()).strip())
imgs_cost = self.parser.select(div, 'div.infos_column img')
cost_tot = len(imgs_cost)
cost_on = 0
for img in imgs_cost:
if img.attrib.get('src','').endswith('euro_on.png'):
if img.attrib.get('src', '').endswith('euro_on.png'):
cost_on += 1
short_description += u' %s/%s'%(cost_on,cost_tot)
short_description += u' %s/%s' % (cost_on, cost_tot)
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
@ -76,10 +77,10 @@ class RecipePage(BasePage):
instructions = NotAvailable
comments = []
title = unicode(self.parser.select(self.document.getroot(),'head > title',1).text.split(' - ')[1])
main = self.parser.select(self.document.getroot(),'div.recette_description',1)
title = unicode(self.parser.select(self.document.getroot(), 'head > title', 1).text.split(' - ')[1])
main = self.parser.select(self.document.getroot(), 'div.recette_description', 1)
rec_infos = self.parser.select(self.document.getroot(),'div.recette_infos div.infos_column strong')
rec_infos = self.parser.select(self.document.getroot(), 'div.recette_infos div.infos_column strong')
for info_title in rec_infos:
if u'Temps de préparation' in unicode(info_title.text):
if info_title.tail.strip() != '':
@ -96,31 +97,31 @@ class RecipePage(BasePage):
nb_person = int(info_title.tail)
ingredients = []
p_ing = self.parser.select(main,'div.data.top.left > div.content p')
p_ing = self.parser.select(main, 'div.data.top.left > div.content p')
for ing in p_ing:
ingtxt = unicode(ing.text_content().strip())
if ingtxt != '':
ingredients.append(ingtxt)
lines_instr = self.parser.select(main,'div.data.top.right div.content li')
lines_instr = self.parser.select(main, 'div.data.top.right div.content li')
if len(lines_instr) > 0:
instructions = u''
for line in lines_instr:
inst = ' '.join(line.text_content().strip().split())
instructions += '%s\n'% inst
instructions += '%s\n' % inst
instructions = instructions.strip('\n')
imgillu = self.parser.select(self.document.getroot(),'div.resume_recette_illustree img.photo')
imgillu = self.parser.select(self.document.getroot(), 'div.resume_recette_illustree img.photo')
if len(imgillu) > 0:
picture_url = unicode(imgillu[0].attrib.get('src',''))
picture_url = unicode(imgillu[0].attrib.get('src', ''))
for divcom in self.parser.select(self.document.getroot(),'div.comment-outer'):
for divcom in self.parser.select(self.document.getroot(), 'div.comment-outer'):
comtxt = unicode(' '.join(divcom.text_content().strip().split()))
if u'| Répondre' in comtxt:
comtxt = comtxt.strip('0123456789').replace(u' | Répondre','')
comtxt = comtxt.strip('0123456789').replace(u' | Répondre', '')
comments.append(comtxt)
recipe = Recipe(id,title)
recipe = Recipe(id, title)
recipe.preparation_time = preparation_time
recipe.cooking_time = cooking_time
recipe.nb_person = nb_person