From 89c5448ef5f5376059f3be1afa45643afa0c8183 Mon Sep 17 00:00:00 2001 From: e5e4eaeacd39c5cfba4d7c852c48277ae50331e6 Date: Sat, 23 Aug 2014 11:26:44 +1000 Subject: [PATCH] flake8 cleanup Cleanup after cleanup --- beets/autotag/match.py | 6 ++++-- beets/ui/commands.py | 5 +++-- beetsplug/chroma.py | 7 ++++--- beetsplug/importadded.py | 6 +++--- beetsplug/lastgenre/__init__.py | 12 ++++-------- beetsplug/lyrics.py | 5 ++--- beetsplug/replaygain.py | 4 ++-- beetsplug/scrub.py | 3 ++- beetsplug/spotify.py | 18 +++++++++--------- test/lyrics_sources.py | 3 ++- 10 files changed, 35 insertions(+), 34 deletions(-) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index d90e870e3..6022ee607 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -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): diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 7400b7356..caefdc2a1 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -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() diff --git a/beetsplug/chroma.py b/beetsplug/chroma.py index ed6b02686..40903dad8 100644 --- a/beetsplug/chroma.py +++ b/beetsplug/chroma.py @@ -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'): diff --git a/beetsplug/importadded.py b/beetsplug/importadded.py index 23267b27a..8b4b7c6b5 100644 --- a/beetsplug/importadded.py +++ b/beetsplug/importadded.py @@ -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') diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index a361bda53..73f580a77 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -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() diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index d3170c703..027657a2b 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -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

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() diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 9da717c62..2bea72d96 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -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]) diff --git a/beetsplug/scrub.py b/beetsplug/scrub.py index a407c17e3..c53c27590 100644 --- a/beetsplug/scrub.py +++ b/beetsplug/scrub.py @@ -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: diff --git a/beetsplug/spotify.py b/beetsplug/spotify.py index d0e319c08..5e83f2c50 100644 --- a/beetsplug/spotify.py +++ b/beetsplug/spotify.py @@ -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 diff --git a/test/lyrics_sources.py b/test/lyrics_sources.py index f96d6ce97..73f473be5 100644 --- a/test/lyrics_sources.py +++ b/test/lyrics_sources.py @@ -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: