Use yield instead to return a list

This commit is contained in:
Florent Fourcot 2013-07-04 21:35:25 +02:00
commit 61718199d6
3 changed files with 3 additions and 10 deletions

View file

@ -70,13 +70,11 @@ class AdvertPage(BasePage):
class SearchPage(BasePage):
def iter_job_adverts(self):
adverts = []
rows = self.document.getroot().xpath('//td[@class="Contenu"]/table/tr')
for row in rows:
cols = self.is_row_advert(row)
if cols is not None:
adverts.append(self.create_job_advert(cols))
return adverts
yield self.create_job_advert(cols)
def is_row_advert(self, row):
cols = self.parser.select(row, 'td')