flake8 cleanup

Cleanup after cleanup
This commit is contained in:
e5e4eaeacd39c5cfba4d7c852c48277ae50331e6 2014-08-23 11:26:44 +10:00
parent bd3f1ca5c0
commit 89c5448ef5
10 changed files with 35 additions and 34 deletions

View file

@ -435,7 +435,8 @@ def tag_album(items, search_artist=None, search_album=None,
if not (search_artist and search_album):
# No explicit search terms -- use current metadata.
search_artist, search_album = cur_artist, cur_album
log.debug(u'Search terms: {0} - {1}'.format(search_artist, search_album))
log.debug(u'Search terms: {0} - {1}'.format(search_artist,
search_album))
# Is this album likely to be a "various artist" release?
va_likely = ((not consensus['artist']) or
@ -493,7 +494,8 @@ def tag_item(item, search_artist=None, search_title=None,
# Search terms.
if not (search_artist and search_title):
search_artist, search_title = item.artist, item.title
log.debug(u'Item search terms: {0} - {1}'.format(search_artist, search_title))
log.debug(u'Item search terms: {0} - {1}'.format(search_artist,
search_title))
# Get and evaluate candidate metadata.
for track_info in hooks.item_candidates(item, search_artist, search_title):

View file

@ -1298,7 +1298,8 @@ def modify_items(lib, mods, dels, query, write, move, album, confirm):
if move:
cur_path = obj.path
if lib.directory in ancestry(cur_path): # In library?
log.debug(u'moving object {0}'.format(displayable_path(cur_path)))
log.debug(u'moving object {0}'
.format(displayable_path(cur_path)))
obj.move()
obj.store()
@ -1386,7 +1387,7 @@ def move_items(lib, dest, query, copy, album):
entity = 'album' if album else 'item'
log.info('{0} {1} {2}s.'.format(action, len(objs), entity))
for obj in objs:
log.debug(u'moving: {0}'.format(displayable_pathobj.path)))
log.debug(u'moving: {0}'.format(util.displayable_pathobj.path))
obj.move(copy, basedir=dest)
obj.store()

View file

@ -54,7 +54,7 @@ def acoustid_match(path):
duration, fp = acoustid.fingerprint_file(util.syspath(path))
except acoustid.FingerprintGenerationError as exc:
log.error(u'fingerprinting of {0} failed: {1}'
.format(displayable_path(repr(path)), str(exc)))
.format(util.displayable_path(repr(path)), str(exc)))
return None
_fingerprints[path] = fp
try:
@ -62,9 +62,10 @@ def acoustid_match(path):
meta='recordings releases')
except acoustid.AcoustidError as exc:
log.debug(u'fingerprint matching {0} failed: {1}'
.format(displayable_path(repr(path)), str(exc)))
.format(util.displayable_path(repr(path)), str(exc)))
return None
log.debug(u'chroma: fingerprinted {0}'.format(displayable_path(repr(path))))
log.debug(u'chroma: fingerprinted {0}'
.format(util.displayable_path(repr(path))))
# Ensure the response is usable and parse it.
if res['status'] != 'ok' or not res.get('results'):

View file

@ -64,9 +64,9 @@ def record_import_mtime(item, source, destination):
mtime = os.stat(util.syspath(source)).st_mtime
item_mtime[destination] = mtime
log.debug(u"Recorded mtime {0} for item '{1}' imported from '{2}'"
.format(mtime, util.displayable_path(destination),
util.displayable_path(source)))
log.debug(u"Recorded mtime {0} for item '{1}' imported from '{2}'".format(
mtime, util.displayable_path(destination),
util.displayable_path(source)))
@ImportAddedPlugin.listen('album_imported')

View file

@ -370,8 +370,7 @@ class LastGenrePlugin(plugins.BeetsPlugin):
item.store()
log.info(u'genre for track {0} - {1} ({2}): {3}'
.format(item.artist, item.title, src,
item.genre)
)
item.genre))
if write:
item.try_write()
@ -385,22 +384,19 @@ class LastGenrePlugin(plugins.BeetsPlugin):
album = task.album
album.genre, src = self._get_genre(album)
log.debug(u'added last.fm album genre ({0}): {1}'.format(
src, album.genre
))
src, album.genre))
album.store()
if 'track' in self.sources:
for item in album.items():
item.genre, src = self._get_genre(item)
log.debug(u'added last.fm item genre ({0}): {1}'.format(
src, item.genre
))
src, item.genre))
item.store()
else:
item = task.item
item.genre, src = self._get_genre(item)
log.debug(u'added last.fm item genre ({0}): {1}'.format(
src, item.genre
))
src, item.genre))
item.store()

View file

@ -375,7 +375,7 @@ def scrape_lyrics_from_url(url):
except Exception, e:
log.debug('Error {0} when replacing containing marker by p marker'
.format(e,exc_info=True))
.format(e, exc_info=True))
# Make better soup from current soup! The previous unclosed <p> sections
# are now closed. Use str() rather than prettify() as it's more
@ -554,6 +554,5 @@ class LyricsPlugin(BeetsPlugin):
if isinstance(lyrics, str):
lyrics = lyrics.decode('utf8', 'ignore')
log.debug(u'got lyrics from backend: {0}'
.format(backend.__name__)
)
.format(backend.__name__))
return lyrics.strip()

View file

@ -578,11 +578,11 @@ class ReplayGainPlugin(BeetsPlugin):
"""
if not self.track_requires_gain(item):
log.info(u'Skipping track {0} - {1}'
.format(item.artist,item.title))
.format(item.artist, item.title))
return
log.info(u'analyzing {0} - {1}'
.format(item.artist,item.title))
.format(item.artist, item.title))
try:
track_gains = self.backend_instance.compute_track_gain([item])

View file

@ -64,7 +64,8 @@ class ScrubPlugin(BeetsPlugin):
# Walk through matching files and remove tags.
for item in lib.items(ui.decargs(args)):
log.info(u'scrubbing: {0}'.format(util.displayable_path(item.path)))
log.info(u'scrubbing: {0}'.format(
util.displayable_path(item.path)))
# Get album art if we need to restore it.
if opts.write:

View file

@ -63,7 +63,8 @@ class SpotifyPlugin(BeetsPlugin):
self.config['show_failures'].set(True)
if self.config['mode'].get() not in ['list', 'open']:
log.warn(u'{0} is not a valid mode'.format(self.config['mode'].get()))
log.warn(u'{0} is not a valid mode'
.format(self.config['mode'].get()))
return False
self.opts = opts
@ -112,7 +113,8 @@ class SpotifyPlugin(BeetsPlugin):
try:
r.raise_for_status()
except HTTPError as e:
log.debug(u'URL returned a {0} error'.format(e.response.status_code))
log.debug(u'URL returned a {0} error'
.format(e.response.status_code))
failures.append(search_url)
continue
@ -128,13 +130,13 @@ class SpotifyPlugin(BeetsPlugin):
# Simplest, take the first result
chosen_result = None
if len(r_data) == 1 or self.config['tiebreak'].get() == "first":
log.debug(u'Spotify track(s) found, count: {0}'.format(len(r_data)))
log.debug(u'Spotify track(s) found, count: {0}'
.format(len(r_data)))
chosen_result = r_data[0]
elif len(r_data) > 1:
# Use the popularity filter
log.debug(u'Most popular track chosen, count: {0}'
.format(len(r_data))
)
.format(len(r_data)))
chosen_result = max(r_data, key=lambda x: x['popularity'])
if chosen_result:
@ -147,16 +149,14 @@ class SpotifyPlugin(BeetsPlugin):
if failure_count > 0:
if self.config['show_failures'].get():
log.info(u'{0} track(s) did not match a Spotify ID:'
.format(failure_count)
)
.format(failure_count))
for track in failures:
log.info(u'track: {0}'.format(track))
log.info(u'') # Is this necesssary
else:
log.warn(u'{0} track(s) did not match a Spotify ID;\n'
u'use --show-failures to display'
.format(failure_count)
)
.format(failure_count))
return results

View file

@ -164,7 +164,8 @@ class LyricsScrapingPluginTest(unittest.TestCase):
# a random improvement in the scraping algo: we want to
# be noticed if it's the case.
if is_lyrics_content_ok(s['title'], res):
log.debug(u'Source {0} actually return valid lyrics!'.format(s['url']))
log.debug(u'Source {0} actually return valid lyrics!'
.format(s['url']))
def test_is_page_candidate(self):
for s in self.sourcesOk: