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

@ -23,27 +23,27 @@ from weboob.capabilities.base import NotAvailable, NotLoaded
from weboob.tools.browser import BasePage
__all__ = ['SongResultsPage','SonglyricsPage', 'ArtistResultsPage', 'ArtistSongsPage']
__all__ = ['SongResultsPage', 'SonglyricsPage', 'ArtistResultsPage', 'ArtistSongsPage']
class ArtistResultsPage(BasePage):
def iter_lyrics(self):
for link in self.parser.select(self.document.getroot(),'table[title~=Results] a.tlink'):
for link in self.parser.select(self.document.getroot(), 'table[title~=Results] a.tlink'):
artist = unicode(link.text_content())
self.browser.location('http://www.seeklyrics.com%s'%link.attrib.get('href',''))
self.browser.location('http://www.seeklyrics.com%s' % link.attrib.get('href', ''))
assert self.browser.is_on_page(ArtistSongsPage)
for lyr in self.browser.page.iter_lyrics(artist):
yield lyr
class ArtistSongsPage(BasePage):
def iter_lyrics(self,artist):
for th in self.parser.select(self.document.getroot(),'th.text'):
def iter_lyrics(self, artist):
for th in self.parser.select(self.document.getroot(), 'th.text'):
txt = th.text_content()
if txt.startswith('Top') and txt.endswith('Lyrics'):
for link in self.parser.select(th.getparent().getparent(),'a.tlink'):
title = unicode(link.attrib.get('title','').replace(' Lyrics',''))
id = link.attrib.get('href','').replace('/lyrics/','').replace('.html','')
for link in self.parser.select(th.getparent().getparent(), 'a.tlink'):
title = unicode(link.attrib.get('title', '').replace(' Lyrics', ''))
id = link.attrib.get('href', '').replace('/lyrics/', '').replace('.html', '')
songlyrics = SongLyrics(id, title)
songlyrics.artist = artist
songlyrics.content = NotLoaded
@ -53,15 +53,15 @@ class ArtistSongsPage(BasePage):
class SongResultsPage(BasePage):
def iter_lyrics(self):
first = True
for tr in self.parser.select(self.document.getroot(),'table[title~=Results] tr'):
for tr in self.parser.select(self.document.getroot(), 'table[title~=Results] tr'):
if first:
first = False
continue
artist = NotAvailable
ftitle = self.parser.select(tr,'a > font > font',1)
ftitle = self.parser.select(tr, 'a > font > font', 1)
title = unicode(ftitle.getparent().getparent().text_content())
id = ftitle.getparent().getparent().attrib.get('href','').replace('/lyrics/','').replace('.html','')
aartist = self.parser.select(tr,'a')[-1]
id = ftitle.getparent().getparent().attrib.get('href', '').replace('/lyrics/', '').replace('.html', '')
aartist = self.parser.select(tr, 'a')[-1]
artist = unicode(aartist.text)
songlyrics = SongLyrics(id, title)
songlyrics.artist = artist
@ -73,12 +73,12 @@ class SonglyricsPage(BasePage):
def get_lyrics(self, id):
artist = NotAvailable
title = NotAvailable
l_artitle = self.parser.select(self.document.getroot(),'table.text td > b > h2')
l_artitle = self.parser.select(self.document.getroot(), 'table.text td > b > h2')
if len(l_artitle) > 0:
artitle = l_artitle[0].text.split(' Lyrics by ')
artist = unicode(artitle[1])
title = unicode(artitle[0])
content = unicode(self.parser.select(self.document.getroot(),'div#songlyrics',1).text_content().strip())
content = unicode(self.parser.select(self.document.getroot(), 'div#songlyrics', 1).text_content().strip())
songlyrics = SongLyrics(id, title)
songlyrics.artist = artist
songlyrics.content = content