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

@ -43,7 +43,7 @@ class SeeklyricsBackend(BaseBackend, ICapLyrics):
return self.browser.get_lyrics(id)
def iter_lyrics(self, criteria, pattern):
return self.browser.iter_lyrics(criteria,quote_plus(pattern.encode('iso-8859-1')))
return self.browser.iter_lyrics(criteria, quote_plus(pattern.encode('iso-8859-1')))
def fill_songlyrics(self, songlyrics, fields):
if 'content' in fields:
@ -52,5 +52,5 @@ class SeeklyricsBackend(BaseBackend, ICapLyrics):
return songlyrics
OBJECTS = {
SongLyrics:fill_songlyrics
SongLyrics: fill_songlyrics
}

View file

@ -36,14 +36,14 @@ class SeeklyricsBrowser(BaseBrowser):
'http://www.seeklyrics.com/search.php.*t=2': ArtistResultsPage,
'http://www.seeklyrics.com/lyrics/.*html': SonglyricsPage,
'http://www.seeklyrics.com/lyrics/.*/': ArtistSongsPage,
}
}
def iter_lyrics(self, criteria, pattern):
if criteria == 'artist':
type = 2
else:
type = 1
self.location('http://www.seeklyrics.com/search.php?q=%s&t=%s' % (pattern,type))
self.location('http://www.seeklyrics.com/search.php?q=%s&t=%s' % (pattern, type))
assert self.is_on_page(ArtistResultsPage) or self.is_on_page(SongResultsPage)
return self.page.iter_lyrics()

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

View file

@ -25,7 +25,7 @@ class SeeklyricsTest(BackendTest):
BACKEND = 'seeklyrics'
def test_search_song_n_get(self):
l_lyrics = list(self.backend.iter_lyrics('song','Complainte'))
l_lyrics = list(self.backend.iter_lyrics('song', 'Complainte'))
for songlyrics in l_lyrics:
assert songlyrics.id
assert songlyrics.title
@ -38,7 +38,7 @@ class SeeklyricsTest(BackendTest):
assert full_lyr.content is not NotLoaded
def test_search_artist(self):
l_lyrics = list(self.backend.iter_lyrics('artist','boris vian'))
l_lyrics = list(self.backend.iter_lyrics('artist', 'boris vian'))
for songlyrics in l_lyrics:
assert songlyrics.id
assert songlyrics.title