From a8daba2a7521e525ea85c6422aa4ecdc0cf7457b Mon Sep 17 00:00:00 2001 From: e5e4eaeacd39c5cfba4d7c852c48277ae50331e6 Date: Sat, 23 Aug 2014 09:26:34 +1000 Subject: [PATCH 1/6] Clean up of logging messages as described here All logging now prefers the ' (single quote) over the " (double quote) https://github.com/sampsyo/beets/wiki/Hacking --- .gitignore | 1 + .hgignore | 1 + beets/autotag/match.py | 38 ++++++++++++++++----------------- beets/autotag/mb.py | 8 +++---- beets/importer.py | 35 ++++++++++++++++-------------- beets/library.py | 2 +- beets/plugins.py | 6 +++--- beets/ui/__init__.py | 4 ++-- beets/ui/commands.py | 20 ++++++++--------- beetsplug/beatport.py | 8 +++---- beetsplug/bpd/__init__.py | 6 +++--- beetsplug/bpm.py | 8 +++---- beetsplug/chroma.py | 33 ++++++++++++++-------------- beetsplug/discogs.py | 10 ++++----- beetsplug/duplicates.py | 20 ++++++++--------- beetsplug/echonest_tempo.py | 12 +++++------ beetsplug/embedart.py | 16 +++++++------- beetsplug/ihate.py | 6 +++--- beetsplug/importadded.py | 11 +++++----- beetsplug/inline.py | 6 +++--- beetsplug/lastgenre/__init__.py | 9 ++++---- beetsplug/lyrics.py | 32 +++++++++++++-------------- beetsplug/missing.py | 2 +- beetsplug/replaygain.py | 10 ++++----- beetsplug/rewrite.py | 2 +- beetsplug/scrub.py | 9 ++++---- beetsplug/spotify.py | 36 +++++++++++++++---------------- test/lyrics_sources.py | 2 +- 28 files changed, 177 insertions(+), 176 deletions(-) diff --git a/.gitignore b/.gitignore index 2f3df66af..71ae7fb81 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ .svn .tox .coverage +.idea # file patterns diff --git a/.hgignore b/.hgignore index a500e2d9e..33acb4da3 100644 --- a/.hgignore +++ b/.hgignore @@ -4,3 +4,4 @@ ^MANIFEST$ ^docs/_build/ ^\.tox/ +^\.idea/ diff --git a/beets/autotag/match.py b/beets/autotag/match.py index a01915256..d90e870e3 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -288,16 +288,16 @@ def match_by_id(items): # Is there a consensus on the MB album ID? albumids = [item.mb_albumid for item in items if item.mb_albumid] if not albumids: - log.debug('No album IDs found.') + log.debug(u'No album IDs found.') return None # If all album IDs are equal, look up the album. if bool(reduce(lambda x, y: x if x == y else (), albumids)): albumid = albumids[0] - log.debug('Searching for discovered album ID: ' + albumid) + log.debug(u'Searching for discovered album ID: {0}'.format(albumid)) return hooks.album_for_mbid(albumid) else: - log.debug('No album ID consensus.') + log.debug(u'No album ID consensus.') def _recommendation(results): @@ -357,17 +357,17 @@ def _add_candidate(items, results, info): checking the track count, ordering the items, checking for duplicates, and calculating the distance. """ - log.debug('Candidate: %s - %s' % (info.artist, info.album)) + log.debug(u'Candidate: {0} - {1}'.format(info.artist, info.album)) # Don't duplicate. if info.album_id in results: - log.debug('Duplicate.') + log.debug(u'Duplicate.') return # Discard matches without required tags. for req_tag in config['match']['required'].as_str_seq(): if getattr(info, req_tag) is None: - log.debug('Ignored. Missing required tag: %s' % req_tag) + log.debug(u'Ignored. Missing required tag: {0}'.format(req_tag)) return # Find mapping between the items and the track info. @@ -380,10 +380,10 @@ def _add_candidate(items, results, info): penalties = [key for _, key in dist] for penalty in config['match']['ignored'].as_str_seq(): if penalty in penalties: - log.debug('Ignored. Penalty: %s' % penalty) + log.debug(u'Ignored. Penalty: {0}'.format(penalty)) return - log.debug('Success. Distance: %f' % dist) + log.debug(u'Success. Distance: {02.2f}'.format(dist)) results[info.album_id] = hooks.AlbumMatch(dist, info, mapping, extra_items, extra_tracks) @@ -404,7 +404,7 @@ def tag_album(items, search_artist=None, search_album=None, likelies, consensus = current_metadata(items) cur_artist = likelies['artist'] cur_album = likelies['album'] - log.debug('Tagging %s - %s' % (cur_artist, cur_album)) + log.debug(u'Tagging {0} - {1}'.format((cur_artist, cur_album))) # The output result (distance, AlbumInfo) tuples (keyed by MB album # ID). @@ -412,7 +412,7 @@ def tag_album(items, search_artist=None, search_album=None, # Search by explicit ID. if search_id is not None: - log.debug('Searching for album ID: ' + search_id) + log.debug(u'Searching for album ID: {0}'.format(search_id)) search_cands = hooks.albums_for_id(search_id) # Use existing metadata or text search. @@ -422,32 +422,32 @@ def tag_album(items, search_artist=None, search_album=None, if id_info: _add_candidate(items, candidates, id_info) rec = _recommendation(candidates.values()) - log.debug('Album ID match recommendation is ' + str(rec)) + log.debug(u'Album ID match recommendation is {0}'.format(str(rec))) if candidates and not config['import']['timid']: # If we have a very good MBID match, return immediately. # Otherwise, this match will compete against metadata-based # matches. if rec == Recommendation.strong: - log.debug('ID match.') + log.debug(u'ID match.') return cur_artist, cur_album, candidates.values(), rec # Search terms. 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: %s - %s' % (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 (search_artist.lower() in VA_ARTISTS) or any(item.comp for item in items)) - log.debug(u'Album might be VA: %s' % str(va_likely)) + log.debug(u'Album might be VA: {0}'.format(str(va_likely))) # Get the results from the data sources. search_cands = hooks.album_candidates(items, search_artist, search_album, va_likely) - log.debug(u'Evaluating %i candidates.' % len(search_cands)) + log.debug(u'Evaluating {0} candidates.'.format(len(search_cands))) for info in search_cands: _add_candidate(items, candidates, info) @@ -472,7 +472,7 @@ def tag_item(item, search_artist=None, search_title=None, # First, try matching by MusicBrainz ID. trackid = search_id or item.mb_trackid if trackid: - log.debug('Searching for track ID: ' + trackid) + log.debug(u'Searching for track ID: {0}'.format(trackid)) for track_info in hooks.tracks_for_id(trackid): dist = track_distance(item, track_info, incl_artist=True) candidates[track_info.track_id] = \ @@ -480,7 +480,7 @@ def tag_item(item, search_artist=None, search_title=None, # If this is a good match, then don't keep searching. rec = _recommendation(candidates.values()) if rec == Recommendation.strong and not config['import']['timid']: - log.debug('Track ID match.') + log.debug(u'Track ID match.') return candidates.values(), rec # If we're searching by ID, don't proceed. @@ -493,7 +493,7 @@ 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: %s - %s' % (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): @@ -501,7 +501,7 @@ def tag_item(item, search_artist=None, search_title=None, candidates[track_info.track_id] = hooks.TrackMatch(dist, track_info) # Sort by distance and return with recommendation. - log.debug('Found %i candidates.' % len(candidates)) + log.debug(u'Found {0} candidates.'.format(len(candidates))) candidates = sorted(candidates.itervalues()) rec = _recommendation(candidates) return candidates, rec diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 508a5a43a..d7afbc52b 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -372,13 +372,13 @@ def album_for_id(releaseid): """ albumid = _parse_id(releaseid) if not albumid: - log.debug('Invalid MBID (%s).' % (releaseid)) + log.debug(u'Invalid MBID ({0}).'.format(releaseid)) return try: res = musicbrainzngs.get_release_by_id(albumid, RELEASE_INCLUDES) except musicbrainzngs.ResponseError: - log.debug('Album ID match failed.') + log.debug(u'Album ID match failed.') return None except musicbrainzngs.MusicBrainzError as exc: raise MusicBrainzAPIError(exc, 'get release by ID', albumid, @@ -392,12 +392,12 @@ def track_for_id(releaseid): """ trackid = _parse_id(releaseid) if not trackid: - log.debug('Invalid MBID (%s).' % (releaseid)) + log.debug(u'Invalid MBID ({0}).'.format(releaseid)) return try: res = musicbrainzngs.get_recording_by_id(trackid, TRACK_INCLUDES) except musicbrainzngs.ResponseError: - log.debug('Track ID match failed.') + log.debug(u'Track ID match failed.') return None except musicbrainzngs.MusicBrainzError as exc: raise MusicBrainzAPIError(exc, 'get recording by ID', trackid, diff --git a/beets/importer.py b/beets/importer.py index 76c90dbea..7444ae849 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -75,7 +75,7 @@ def _save_state(state): with open(config['statefile'].as_filename(), 'w') as f: pickle.dump(state, f) except IOError as exc: - log.error(u'state file could not be written: %s' % unicode(exc)) + log.error(u'state file could not be written: {0}'.format(exc)) # Utilities for reading and writing the beets progress file, which @@ -333,7 +333,8 @@ class ImportSession(object): # Either accept immediately or prompt for input to decide. if self.want_resume is True or \ self.should_resume(toppath): - log.warn('Resuming interrupted import of %s' % toppath) + log.warn(u'Resuming interrupted import of {0}'.format( + util.displayable_path(toppath))) self._is_resuming[toppath] = True else: # Clear progress; we're starting from the top. @@ -440,13 +441,13 @@ class ImportTask(object): def remove_duplicates(self, lib): duplicate_items = self.duplicate_items(lib) - log.debug('removing %i old duplicated items' % - len(duplicate_items)) + log.debug(u'removing {0} old duplicated items' + .format(len(duplicate_items))) for item in duplicate_items: item.remove() if lib.directory in util.ancestry(item.path): - log.debug(u'deleting duplicate %s' % - util.displayable_path(item.path)) + log.debug(u'deleting duplicate {0}' + .format(util.displayable_path(item.path))) util.remove(item.path) util.prune_dirs(os.path.dirname(item.path), lib.directory) @@ -628,11 +629,13 @@ class ImportTask(object): )) self.replaced_items[item] = dup_items for dup_item in dup_items: - log.debug('replacing item %i: %s' % - (dup_item.id, displayable_path(item.path))) + log.debug(u'replacing item {0}: {1}' + .format((dup_item.id, + displayable_path(item.path)))) dup_item.remove() - log.debug('%i of %i items replaced' % (len(self.replaced_items), - len(self.imported_items()))) + log.debug(u'{0} of {1} items replaced' + .format((len(self.replaced_items), + len(self.imported_items())))) def choose_match(self, session): """Ask the session which match should apply and apply it. @@ -870,17 +873,17 @@ def read_tasks(session): archive_task = None if ArchiveImportTask.is_archive(syspath(toppath)): if not (session.config['move'] or session.config['copy']): - log.warn("Archive importing requires either " + log.warn(u"Archive importing requires either " "'copy' or 'move' to be enabled.") continue - log.debug('extracting archive {0}' + log.debug(u'extracting archive {0}' .format(displayable_path(toppath))) archive_task = ArchiveImportTask(toppath) try: archive_task.extract() except Exception as exc: - log.error('extraction failed: {0}'.format(exc)) + log.error(u'extraction failed: {0}'.format(exc)) continue # Continue reading albums from the extracted directory. @@ -970,8 +973,8 @@ def query_tasks(session): else: # Search for albums. for album in session.lib.albums(session.query): - log.debug('yielding album %i: %s - %s' % - (album.id, album.albumartist, album.album)) + log.debug(u'yielding album {0}: {1} - {2}' + .format((album.id, album.albumartist, album.album))) items = list(album.items()) # Clear IDs from re-tagged items so they appear "fresh" when @@ -996,7 +999,7 @@ def lookup_candidates(session, task): return plugins.send('import_task_start', session=session, task=task) - log.debug('Looking up: %s' % displayable_path(task.paths)) + log.debug(u'Looking up: {0}'.format(displayable_path(task.paths))) task.lookup_candidates() diff --git a/beets/library.py b/beets/library.py index d3a41f2bd..4dbaa767b 100644 --- a/beets/library.py +++ b/beets/library.py @@ -781,7 +781,7 @@ class Album(LibModel): return new_art = util.unique_path(new_art) - log.debug('moving album art %s to %s' % (old_art, new_art)) + log.debug(u'moving album art {0} to {1}'.format(old_art, new_art)) if copy: util.copy(old_art, new_art) else: diff --git a/beets/plugins.py b/beets/plugins.py index 3dca22a97..68ddd0658 100755 --- a/beets/plugins.py +++ b/beets/plugins.py @@ -194,7 +194,7 @@ def load_plugins(names=()): except ImportError as exc: # Again, this is hacky: if exc.args[0].endswith(' ' + name): - log.warn('** plugin %s not found' % name) + log.warn(u'** plugin {0} not found'.format(name)) else: raise else: @@ -204,7 +204,7 @@ def load_plugins(names=()): _classes.add(obj) except: - log.warn('** error loading plugin %s' % name) + log.warn(u'** error loading plugin {0}'.format(name)) log.warn(traceback.format_exc()) @@ -371,7 +371,7 @@ def send(event, **arguments): Returns a list of return values from the handlers. """ - log.debug('Sending event: %s' % event) + log.debug(u'Sending event: {0}'.format(event)) for handler in event_handlers()[event]: # Don't break legacy plugins if we want to pass more arguments argspec = inspect.getargspec(handler).args diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 1e64cd89c..1a1adfbe3 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -900,10 +900,10 @@ def _configure(args): config_path = config.user_config_path() if os.path.isfile(config_path): - log.debug('user configuration: {0}'.format( + log.debug(u'user configuration: {0}'.format( util.displayable_path(config_path))) else: - log.debug('no user configuration found at {0}'.format( + log.debug(u'no user configuration found at {0}'.format( util.displayable_path(config_path))) # Add builtin subcommands diff --git a/beets/ui/commands.py b/beets/ui/commands.py index a7720464e..c7afac4d8 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -776,12 +776,12 @@ class TerminalImportSession(importer.ImportSession): """Decide what to do when a new album or item seems similar to one that's already in the library. """ - log.warn("This %s is already in the library!" % - ("album" if task.is_album else "item")) + log.warn(u"This {0} is already in the library!" + .format("album" if task.is_album else "item")) if config['import']['quiet']: # In quiet mode, don't prompt -- just skip. - log.info('Skipping.') + log.info(u'Skipping.') sel = 's' else: # Print some detail about the existing and new items so the @@ -1022,8 +1022,8 @@ def update_items(lib, query, album, move, pretend): # Did the item change since last checked? if item.current_mtime() <= item.mtime: - log.debug(u'skipping %s because mtime is up to date (%i)' % - (displayable_path(item.path), item.mtime)) + log.debug(u'skipping {0} because mtime is up to date ({1})' + .format(displayable_path(item.path), item.mtime)) continue # Read new data. @@ -1073,7 +1073,7 @@ def update_items(lib, query, album, move, pretend): continue album = lib.get_album(album_id) if not album: # Empty albums have already been removed. - log.debug('emptied album %i' % album_id) + log.debug(u'emptied album {0}'.format(album_id)) continue first_item = album.items().get() @@ -1084,7 +1084,7 @@ def update_items(lib, query, album, move, pretend): # Move album art (and any inconsistent items). if move and lib.directory in ancestry(first_item.path): - log.debug('moving album %i' % album_id) + log.debug(u'moving album {0}'.format(album_id)) album.move() @@ -1290,7 +1290,7 @@ 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('moving object %s' % cur_path) + log.debug(u'moving object {0}'.format(displayable_path(cur_path))) obj.move() obj.store() @@ -1376,9 +1376,9 @@ def move_items(lib, dest, query, copy, album): action = 'Copying' if copy else 'Moving' entity = 'album' if album else 'item' - log.info('%s %i %ss.' % (action, len(objs), entity)) + log.info('{0} {1} {2}s.'.format(action, len(objs), entity)) for obj in objs: - log.debug('moving: %s' % obj.path) + log.debug(u'moving: {0}'.format(displayable_pathobj.path))) obj.move(copy, basedir=dest) obj.store() diff --git a/beetsplug/beatport.py b/beetsplug/beatport.py index 86193a971..b83aef2f7 100644 --- a/beetsplug/beatport.py +++ b/beetsplug/beatport.py @@ -194,7 +194,7 @@ class BeatportPlugin(BeetsPlugin): try: return self._get_releases(query) except BeatportAPIError as e: - log.debug('Beatport API Error: %s (query: %s)' % (e, query)) + log.debug(u'Beatport API Error: {0} (query: {1})'.format(e, query)) return [] def item_candidates(self, item, artist, title): @@ -205,14 +205,14 @@ class BeatportPlugin(BeetsPlugin): try: return self._get_tracks(query) except BeatportAPIError as e: - log.debug('Beatport API Error: %s (query: %s)' % (e, query)) + log.debug(u'Beatport API Error: {0} (query: {1})'.format(e, query)) return [] def album_for_id(self, release_id): """Fetches a release by its Beatport ID and returns an AlbumInfo object or None if the release is not found. """ - log.debug('Searching Beatport for release %s' % str(release_id)) + log.debug(u'Searching Beatport for release {0}'.format(release_id)) match = re.search(r'(^|beatport\.com/release/.+/)(\d+)$', release_id) if not match: return None @@ -224,7 +224,7 @@ class BeatportPlugin(BeetsPlugin): """Fetches a track by its Beatport ID and returns a TrackInfo object or None if the track is not found. """ - log.debug('Searching Beatport for track %s' % str(track_id)) + log.debug(u'Searching Beatport for track {0}'.format(str(track_id))) match = re.search(r'(^|beatport\.com/track/.+/)(\d+)$', track_id) if not match: return None diff --git a/beetsplug/bpd/__init__.py b/beetsplug/bpd/__init__.py index 8b565d9dc..5218cb9fc 100644 --- a/beetsplug/bpd/__init__.py +++ b/beetsplug/bpd/__init__.py @@ -1160,9 +1160,9 @@ class BPDPlugin(BeetsPlugin): try: Server(lib, host, port, password).run() except NoGstreamerError: - global_log.error('Gstreamer Python bindings not found.') - global_log.error('Install "python-gst0.10", "py27-gst-python", ' - 'or similar package to use BPD.') + global_log.error(u'Gstreamer Python bindings not found.') + global_log.error(u'Install "python-gst0.10", "py27-gst-python", ' + u'or similar package to use BPD.') def commands(self): cmd = beets.ui.Subcommand( diff --git a/beetsplug/bpm.py b/beetsplug/bpm.py index 977d59dcc..d895ec5be 100644 --- a/beetsplug/bpm.py +++ b/beetsplug/bpm.py @@ -73,15 +73,15 @@ class BPMPlugin(BeetsPlugin): item = items[0] if item['bpm']: - log.info('Found bpm {0}'.format(item['bpm'])) + log.info(u'Found bpm {0}'.format(item['bpm'])) if not overwrite: return - log.info('Press Enter {0} times to the rhythm or Ctrl-D \ -to exit'.format(self.config['max_strokes'].get(int))) + log.info(u'Press Enter {0} times to the rhythm or Ctrl-D ' + u'to exit'.format(self.config['max_strokes'].get(int))) new_bpm = bpm(self.config['max_strokes'].get(int)) item['bpm'] = int(new_bpm) if write: item.try_write() item.store() - log.info('Added new bpm {0}'.format(item['bpm'])) + log.info(u'Added new bpm {0}'.format(item['bpm'])) diff --git a/beetsplug/chroma.py b/beetsplug/chroma.py index b5b8b1be3..ed6b02686 100644 --- a/beetsplug/chroma.py +++ b/beetsplug/chroma.py @@ -53,32 +53,32 @@ def acoustid_match(path): try: duration, fp = acoustid.fingerprint_file(util.syspath(path)) except acoustid.FingerprintGenerationError as exc: - log.error('fingerprinting of %s failed: %s' % - (repr(path), str(exc))) + log.error(u'fingerprinting of {0} failed: {1}' + .format(displayable_path(repr(path)), str(exc))) return None _fingerprints[path] = fp try: res = acoustid.lookup(API_KEY, fp, duration, meta='recordings releases') except acoustid.AcoustidError as exc: - log.debug('fingerprint matching %s failed: %s' % - (repr(path), str(exc))) + log.debug(u'fingerprint matching {0} failed: {1}' + .format(displayable_path(repr(path)), str(exc))) return None - log.debug('chroma: fingerprinted %s' % repr(path)) + log.debug(u'chroma: fingerprinted {0}'.format(displayable_path(repr(path)))) # Ensure the response is usable and parse it. if res['status'] != 'ok' or not res.get('results'): - log.debug('chroma: no match found') + log.debug(u'chroma: no match found') return None result = res['results'][0] # Best match. if result['score'] < SCORE_THRESH: - log.debug('chroma: no results above threshold') + log.debug(u'chroma: no results above threshold') return None _acoustids[path] = result['id'] # Get recording and releases from the result. if not result.get('recordings'): - log.debug('chroma: no recordings found') + log.debug(u'chroma: no recordings found') return None recording_ids = [] release_ids = [] @@ -87,7 +87,7 @@ def acoustid_match(path): if 'releases' in recording: release_ids += [rel['id'] for rel in recording['releases']] - log.debug('chroma: matched recordings {0}'.format(recording_ids)) + log.debug(u'chroma: matched recordings {0}'.format(recording_ids)) _matches[path] = recording_ids, release_ids @@ -141,7 +141,7 @@ class AcoustidPlugin(plugins.BeetsPlugin): if album: albums.append(album) - log.debug('acoustid album candidates: %i' % len(albums)) + log.debug(u'acoustid album candidates: {0}'.format(len(albums))) return albums def item_candidates(self, item, artist, title): @@ -154,7 +154,7 @@ class AcoustidPlugin(plugins.BeetsPlugin): track = hooks.track_for_mbid(recording_id) if track: tracks.append(track) - log.debug('acoustid item candidates: {0}'.format(len(tracks))) + log.debug(u'acoustid item candidates: {0}'.format(len(tracks))) return tracks def commands(self): @@ -216,7 +216,7 @@ def submit_items(userkey, items, chunksize=64): def submit_chunk(): """Submit the current accumulated fingerprint data.""" - log.info('submitting {0} fingerprints'.format(len(data))) + log.info(u'submitting {0} fingerprints'.format(len(data))) try: acoustid.submit(API_KEY, userkey, data) except acoustid.AcoustidError as exc: @@ -233,7 +233,7 @@ def submit_items(userkey, items, chunksize=64): } if item.mb_trackid: item_data['mbid'] = item.mb_trackid - log.debug('submitting MBID') + log.debug(u'submitting MBID') else: item_data.update({ 'track': item.title, @@ -244,7 +244,7 @@ def submit_items(userkey, items, chunksize=64): 'trackno': item.track, 'discno': item.disc, }) - log.debug('submitting textual metadata') + log.debug(u'submitting textual metadata') data.append(item_data) # If we have enough data, submit a chunk. @@ -294,6 +294,5 @@ def fingerprint_item(item, write=False): item.store() return item.acoustid_fingerprint except acoustid.FingerprintGenerationError as exc: - log.info( - 'fingerprint generation failed: {0}'.format(exc) - ) + log.info(u'fingerprint generation failed: {0}' + .format(exc)) diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index d33991144..ad09e8826 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -62,14 +62,14 @@ class DiscogsPlugin(BeetsPlugin): try: return self.get_albums(query) except DiscogsAPIError as e: - log.debug('Discogs API Error: %s (query: %s' % (e, query)) + log.debug(u'Discogs API Error: {0} (query: {1})'.format(e, query)) return [] def album_for_id(self, album_id): """Fetches an album by its Discogs ID and returns an AlbumInfo object or None if the album is not found. """ - log.debug('Searching discogs for release %s' % str(album_id)) + log.debug(u'Searching Discogs for release {0}'.format(str(album_id))) # Discogs-IDs are simple integers. We only look for those at the end # of an input string as to avoid confusion with other metadata plugins. # An optional bracket can follow the integer, as this is how discogs @@ -84,8 +84,8 @@ class DiscogsPlugin(BeetsPlugin): getattr(result, 'title') except DiscogsAPIError as e: if e.message != '404 Not Found': - log.debug('Discogs API Error: %s (query: %s)' - % (e, result._uri)) + log.debug(u'Discogs API Error: {0} (query: {1})' + .format(e, result._uri)) return None return self.get_album_info(result) @@ -232,7 +232,7 @@ class DiscogsPlugin(BeetsPlugin): if match: medium, index = match.groups() else: - log.debug('Invalid discogs position: %s' % position) + log.debug(u'Invalid Discogs position: {0}'.format(position)) medium = index = None return medium or None, index or None diff --git a/beetsplug/duplicates.py b/beetsplug/duplicates.py index 195cd1d16..fe0f8ac00 100644 --- a/beetsplug/duplicates.py +++ b/beetsplug/duplicates.py @@ -56,20 +56,20 @@ def _checksum(item, prog): key = args[0] checksum = getattr(item, key, False) if not checksum: - log.debug('%s: key %s on item %s not cached: computing checksum', - PLUGIN, key, displayable_path(item.path)) + log.debug(u'{0}: key {1} on item {2} not cached: computing checksum' + .format(PLUGIN, key, displayable_path(item.path))) try: checksum = command_output(args) setattr(item, key, checksum) item.store() - log.debug('%s: computed checksum for %s using %s', - PLUGIN, item.title, key) + log.debug(u'{)}: computed checksum for {1} using {2}' + .format(PLUGIN, item.title, key)) except subprocess.CalledProcessError as e: - log.debug('%s: failed to checksum %s: %s', - PLUGIN, displayable_path(item.path), e) + log.debug(u'{0}: failed to checksum {1}: {2}' + .format(PLUGIN, displayable_path(item.path), e)) else: - log.debug('%s: key %s on item %s cached: not computing checksum', - PLUGIN, key, displayable_path(item.path)) + log.debug(u'{0}: key {1} on item {2} cached: not computing checksum' + .format(PLUGIN, key, displayable_path(item.path))) return key, checksum @@ -86,8 +86,8 @@ def _group_by(objs, keys): key = '\001'.join(values) counts[key].append(obj) else: - log.debug('%s: all keys %s on item %s are null: skipping', - PLUGIN, str(keys), displayable_path(obj.path)) + log.debug(u'{0}: all keys {1} on item {2} are null: skipping' + .format(PLUGIN, str(keys), displayable_path(obj.path))) return counts diff --git a/beetsplug/echonest_tempo.py b/beetsplug/echonest_tempo.py index dea57c879..764594c3e 100644 --- a/beetsplug/echonest_tempo.py +++ b/beetsplug/echonest_tempo.py @@ -40,19 +40,19 @@ def fetch_item_tempo(lib, loglevel, item, write): """ # Skip if the item already has the tempo field. if item.bpm: - log.log(loglevel, u'bpm already present: %s - %s' % - (item.artist, item.title)) + log.log(loglevel, u'bpm already present: {0} - {1}' + .format(item.artist, item.title)) return # Fetch tempo. tempo = get_tempo(item.artist, item.title, item.length) if not tempo: - log.log(loglevel, u'tempo not found: %s - %s' % - (item.artist, item.title)) + log.log(loglevel, u'tempo not found: {0} - {1}' + .format(item.artist, item.title)) return - log.log(loglevel, u'fetched tempo: %s - %s' % - (item.artist, item.title)) + log.log(loglevel, u'fetched tempo: {0} - {1}' + .format(item.artist, item.title)) item.bpm = int(tempo) if write: item.try_write() diff --git a/beetsplug/embedart.py b/beetsplug/embedart.py index 46e10a61d..dfdabf5ef 100644 --- a/beetsplug/embedart.py +++ b/beetsplug/embedart.py @@ -40,8 +40,8 @@ class EmbedCoverArtPlugin(BeetsPlugin): if self.config['maxwidth'].get(int) and \ not ArtResizer.shared.local: self.config['maxwidth'] = 0 - log.warn("embedart: ImageMagick or PIL not found; " - "'maxwidth' option ignored") + log.warn(u"embedart: ImageMagick or PIL not found; " + u"'maxwidth' option ignored") def commands(self): # Embed command. @@ -145,7 +145,7 @@ def _mediafile_image(image_path, maxwidth=None): def extract(lib, outpath, query): item = lib.items(query).get() if not item: - log.error('No item matches query.') + log.error(u'No item matches query.') return # Extract the art. @@ -159,14 +159,14 @@ def extract(lib, outpath, query): art = mf.art if not art: - log.error('No album art present in %s - %s.' % - (item.artist, item.title)) + log.error(u'No album art present in {0} - {1}.' + .format(item.artist, item.title)) return # Add an extension to the filename. ext = imghdr.what(None, h=art) if not ext: - log.error('Unknown image type.') + log.error(u'Unknown image type.') return outpath += '.' + ext @@ -179,9 +179,9 @@ def extract(lib, outpath, query): # 'clearart' command. def clear(lib, query): - log.info('Clearing album art from items:') + log.info(u'Clearing album art from items:') for item in lib.items(query): - log.info(u'%s - %s' % (item.artist, item.title)) + log.info(u'{0} - {1}'.format(item.artist, item.title)) try: mf = mediafile.MediaFile(syspath(item.path), config['id3v23'].get(bool)) diff --git a/beetsplug/ihate.py b/beetsplug/ihate.py index 3cd6ace41..2c4785be8 100644 --- a/beetsplug/ihate.py +++ b/beetsplug/ihate.py @@ -70,7 +70,7 @@ class IHatePlugin(BeetsPlugin): if task.choice_flag == action.APPLY: if skip_queries or warn_queries: - self._log.debug('[ihate] processing your hate') + self._log.debug(u'[ihate] processing your hate') if self.do_i_hate_this(task, skip_queries): task.choice_flag = action.SKIP self._log.info(u'[ihate] skipped: {0}' @@ -80,6 +80,6 @@ class IHatePlugin(BeetsPlugin): self._log.info(u'[ihate] you maybe hate this: {0}' .format(summary(task))) else: - self._log.debug('[ihate] nothing to do') + self._log.debug(u'[ihate] nothing to do') else: - self._log.debug('[ihate] user made a decision, nothing to do') + self._log.debug(u'[ihate] user made a decision, nothing to do') diff --git a/beetsplug/importadded.py b/beetsplug/importadded.py index 539853859..23267b27a 100644 --- a/beetsplug/importadded.py +++ b/beetsplug/importadded.py @@ -44,8 +44,8 @@ def write_item_mtime(item, mtime): item's file. """ if mtime is None: - log.warn("No mtime to be preserved for item " - + util.displayable_path(item.path)) + log.warn(u"No mtime to be preserved for item {0}" + .format(util.displayable_path(item.path))) return # The file's mtime on disk must be in sync with the item's mtime @@ -64,10 +64,9 @@ def record_import_mtime(item, source, destination): mtime = os.stat(util.syspath(source)).st_mtime item_mtime[destination] = mtime - log.debug('Recorded mtime %s for item "%s" imported from "%s"', - 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/inline.py b/beetsplug/inline.py index b0142a934..33c24b777 100644 --- a/beetsplug/inline.py +++ b/beetsplug/inline.py @@ -64,7 +64,7 @@ def compile_inline(python_code, album): try: func = _compile_func(python_code) except SyntaxError: - log.error(u'syntax error in inline field definition:\n%s' % + log.error(u'syntax error in inline field definition:\n{0}', traceback.format_exc()) return else: @@ -112,14 +112,14 @@ class InlinePlugin(BeetsPlugin): # Item fields. for key, view in itertools.chain(config['item_fields'].items(), config['pathfields'].items()): - log.debug(u'inline: adding item field %s' % key) + log.debug(u'inline: adding item field {0}'.format(key)) func = compile_inline(view.get(unicode), False) if func is not None: self.template_fields[key] = func # Album fields. for key, view in config['album_fields'].items(): - log.debug(u'inline: adding album field %s' % key) + log.debug(u'inline: adding album field {0}'.format(key)) func = compile_inline(view.get(unicode), True) if func is not None: self.album_template_fields[key] = func diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index eba6c6cab..a361bda53 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -66,7 +66,7 @@ def _tags_for(obj, min_weight=None): else: res = obj.get_top_tags() except PYLAST_EXCEPTIONS as exc: - log.debug(u'last.fm error: %s' % unicode(exc)) + log.debug(u'last.fm error: {0}'.format(exc)) return [] # Filter by weight (optionally). @@ -368,10 +368,9 @@ class LastGenrePlugin(plugins.BeetsPlugin): if 'track' in self.sources: item.genre, src = self._get_genre(item) item.store() - log.info( - u'genre for track {0} - {1} ({2}): {3}'. format( - item.artist, item.title, src, item.genre - ) + log.info(u'genre for track {0} - {1} ({2}): {3}' + .format(item.artist, item.title, src, + item.genre) ) if write: diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 5d44a35f3..d3170c703 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -244,7 +244,7 @@ def slugify(text): text = unicodedata.normalize('NFKD', text).encode('ascii', 'ignore') text = unicode(re.sub('[-\s]+', ' ', text)) except UnicodeDecodeError: - log.exception("Failing to normalize '%s'" % (text)) + log.exception(u"Failing to normalize '{0}'".format(text)) return text @@ -327,7 +327,7 @@ def is_lyrics(text, artist=None): badTriggersOcc = [] nbLines = text.count('\n') if nbLines <= 1: - log.debug("Ignoring too short lyrics '%s'" % text) + log.debug(u"Ignoring too short lyrics '{0}'".format(text)) return 0 elif nbLines < 5: badTriggersOcc.append('too_short') @@ -345,7 +345,7 @@ def is_lyrics(text, artist=None): text, re.I)) if badTriggersOcc: - log.debug('Bad triggers detected: %s' % badTriggersOcc) + log.debug(u'Bad triggers detected: {0}'.format(badTriggersOcc)) return len(badTriggersOcc) < 2 @@ -374,8 +374,8 @@ def scrape_lyrics_from_url(url): tag.name = 'p' # keep tag contents except Exception, e: - log.debug('Error %s when replacing containing marker by p marker' % e, - exc_info=True) + log.debug('Error {0} when replacing containing marker by p marker' + .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 @@ -417,7 +417,7 @@ def fetch_google(artist, title): data = json.load(data) if 'error' in data: reason = data['error']['errors'][0]['reason'] - log.debug(u'google lyrics backend error: %s' % reason) + log.debug(u'google lyrics backend error: {0}'.format(reason)) return if 'items' in data.keys(): @@ -433,7 +433,7 @@ def fetch_google(artist, title): lyrics = sanitize_lyrics(lyrics) if is_lyrics(lyrics, artist): - log.debug(u'got lyrics from %s' % item['displayLink']) + log.debug(u'got lyrics from {0}'.format(item['displayLink'])) return lyrics @@ -496,8 +496,8 @@ class LyricsPlugin(BeetsPlugin): # Skip if the item already has lyrics. if not force and item.lyrics: - log.log(loglevel, u'lyrics already present: %s - %s' % - (item.artist, item.title)) + log.log(loglevel, u'lyrics already present: {0} - {1}' + .format((item.artist, item.title))) return artist = remove_ft_artist_suffix(item.artist) @@ -522,15 +522,15 @@ class LyricsPlugin(BeetsPlugin): lyrics = lyrics_title if not lyrics: - log.log(loglevel, u'lyrics not found: %s - %s' % - (artist, title)) + log.log(loglevel, u'lyrics not found: {0} - {1}' + .format(artist, title)) if fallback: lyrics = fallback else: return else: - log.log(loglevel, u'fetched lyrics : %s - %s' % - (artist, title)) + log.log(loglevel, u'fetched lyrics : {0} - {1}' + .format(artist, title)) item.lyrics = lyrics @@ -553,7 +553,7 @@ class LyricsPlugin(BeetsPlugin): if lyrics: if isinstance(lyrics, str): lyrics = lyrics.decode('utf8', 'ignore') - log.debug(u'got lyrics from backend: {0}'.format( - backend.__name__ - )) + log.debug(u'got lyrics from backend: {0}' + .format(backend.__name__) + ) return lyrics.strip() diff --git a/beetsplug/missing.py b/beetsplug/missing.py index 48ac11b67..addc0ae28 100644 --- a/beetsplug/missing.py +++ b/beetsplug/missing.py @@ -43,7 +43,7 @@ def _missing(album): for track_info in getattr(album_info, 'tracks', []): if track_info.track_id not in item_mbids: item = _item(track_info, album_info, album.id) - log.debug('{0}: track {1} in album {2}' + log.debug(u'{0}: track {1} in album {2}' .format(PLUGIN, track_info.track_id, album_info.album_id)) diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index b93e13b33..9da717c62 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -135,7 +135,7 @@ class CommandBackend(Backend): supported_items = filter(self.format_supported, album.items()) if len(supported_items) != len(album.items()): - log.debug('replaygain: tracks are of unsupported format') + log.debug(u'replaygain: tracks are of unsupported format') return AlbumGain(None, []) output = self.compute_gain(supported_items, True) @@ -577,12 +577,12 @@ class ReplayGainPlugin(BeetsPlugin): in the item, nothing is done. """ if not self.track_requires_gain(item): - log.info(u'Skipping track {0} - {1}'.format(item.artist, - item.title)) + log.info(u'Skipping track {0} - {1}' + .format(item.artist,item.title)) return - log.info(u'analyzing {0} - {1}'.format(item.artist, - item.title)) + log.info(u'analyzing {0} - {1}' + .format(item.artist,item.title)) try: track_gains = self.backend_instance.compute_track_gain([item]) diff --git a/beetsplug/rewrite.py b/beetsplug/rewrite.py index 44fd3753e..55b705492 100644 --- a/beetsplug/rewrite.py +++ b/beetsplug/rewrite.py @@ -59,7 +59,7 @@ class RewritePlugin(BeetsPlugin): if fieldname not in library.Item._fields: raise ui.UserError("invalid field name (%s) in rewriter" % fieldname) - log.debug(u'adding template field %s' % key) + log.debug(u'adding template field {0}'.format(key)) pattern = re.compile(pattern.lower()) rules[fieldname].append((pattern, value)) if fieldname == 'artist': diff --git a/beetsplug/scrub.py b/beetsplug/scrub.py index af1a77370..a407c17e3 100644 --- a/beetsplug/scrub.py +++ b/beetsplug/scrub.py @@ -64,7 +64,7 @@ class ScrubPlugin(BeetsPlugin): # Walk through matching files and remove tags. for item in lib.items(ui.decargs(args)): - log.info(u'scrubbing: %s' % 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: @@ -80,7 +80,7 @@ class ScrubPlugin(BeetsPlugin): log.debug(u'writing new tags after scrub') item.try_write() if art: - log.info('restoring art') + log.info(u'restoring art') mf = mediafile.MediaFile(item.path) mf.art = art mf.save() @@ -132,8 +132,7 @@ def _scrub(path): f.save() except IOError as exc: log.error(u'could not scrub {0}: {1}'.format( - util.displayable_path(path), - exc, + util.displayable_path(path), exc, )) @@ -141,5 +140,5 @@ def _scrub(path): @ScrubPlugin.listen('write') def write_item(path): if not scrubbing and config['scrub']['auto']: - log.debug(u'auto-scrubbing %s' % util.displayable_path(path)) + log.debug(u'auto-scrubbing {0}'.format(util.displayable_path(path))) _scrub(path) diff --git a/beetsplug/spotify.py b/beetsplug/spotify.py index 59fe687a6..d0e319c08 100644 --- a/beetsplug/spotify.py +++ b/beetsplug/spotify.py @@ -63,7 +63,7 @@ class SpotifyPlugin(BeetsPlugin): self.config['show_failures'].set(True) if self.config['mode'].get() not in ['list', 'open']: - log.warn(self.config['mode'].get() + " is not a valid mode") + log.warn(u'{0} is not a valid mode'.format(self.config['mode'].get())) return False self.opts = opts @@ -77,10 +77,10 @@ class SpotifyPlugin(BeetsPlugin): items = lib.items(query) if not items: - log.debug("Your beets query returned no items, skipping spotify") + log.debug(u'Your beets query returned no items, skipping spotify') return - log.info("Processing " + str(len(items)) + " tracks...") + log.info(u'Processing {0} tracks...'.format(len(items))) for item in items: @@ -112,7 +112,7 @@ class SpotifyPlugin(BeetsPlugin): try: r.raise_for_status() except HTTPError as e: - log.debug("URL returned a " + e.response.status_code + "error") + log.debug(u'URL returned a {0} error'.format(e.response.status_code)) failures.append(search_url) continue @@ -128,34 +128,34 @@ class SpotifyPlugin(BeetsPlugin): # Simplest, take the first result chosen_result = None if len(r_data) == 1 or self.config['tiebreak'].get() == "first": - log.debug("Spotify track(s) found, count: " + str(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( - "Most popular track chosen, count: " + str(len(r_data)) + log.debug(u'Most popular track chosen, count: {0}' + .format(len(r_data)) ) chosen_result = max(r_data, key=lambda x: x['popularity']) if chosen_result: results.append(chosen_result) else: - log.debug("No spotify track found: " + search_url) + log.debug(u'No spotify track found: {0}'.format(search_url)) failures.append(search_url) failure_count = len(failures) if failure_count > 0: if self.config['show_failures'].get(): - log.info("{0} track(s) did not match a Spotify ID:".format( - failure_count - )) + log.info(u'{0} track(s) did not match a Spotify ID:' + .format(failure_count) + ) for track in failures: - log.info("track:" + track) - log.info("") + log.info(u'track: {0}'.format(track)) + log.info(u'') # Is this necesssary else: - log.warn( - str(failure_count) + " track(s) did not match " - "a Spotify ID; use --show-failures to display\n" + log.warn(u'{0} track(s) did not match a Spotify ID;\n' + u'use --show-failures to display' + .format(failure_count) ) return results @@ -164,7 +164,7 @@ class SpotifyPlugin(BeetsPlugin): if results: ids = map(lambda x: x['id'], results) if self.config['mode'].get() == "open": - log.info("Attempting to open Spotify with playlist") + log.info(u'Attempting to open Spotify with playlist') spotify_url = self.playlist_partial + ",".join(ids) webbrowser.open(spotify_url) @@ -172,4 +172,4 @@ class SpotifyPlugin(BeetsPlugin): for item in ids: print(unicode.encode(self.open_url + item)) else: - log.warn("No Spotify tracks found from beets query") + log.warn(u'No Spotify tracks found from beets query') diff --git a/test/lyrics_sources.py b/test/lyrics_sources.py index 58be4eb4d..f96d6ce97 100644 --- a/test/lyrics_sources.py +++ b/test/lyrics_sources.py @@ -164,7 +164,7 @@ 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('Source %s actually return valid lyrics!' % 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: From 89c5448ef5f5376059f3be1afa45643afa0c8183 Mon Sep 17 00:00:00 2001 From: e5e4eaeacd39c5cfba4d7c852c48277ae50331e6 Date: Sat, 23 Aug 2014 11:26:44 +1000 Subject: [PATCH 2/6] 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: From b5f60c52d409e7f5679675365a93c4b92a931b69 Mon Sep 17 00:00:00 2001 From: e5e4eaeacd39c5cfba4d7c852c48277ae50331e6 Date: Sat, 23 Aug 2014 11:48:26 +1000 Subject: [PATCH 3/6] Fix Travis errors I was over zealous on the brackets for formatting --- beets/autotag/match.py | 2 +- beets/importer.py | 13 ++++++------- beetsplug/lyrics.py | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 6022ee607..94fb3352c 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -404,7 +404,7 @@ def tag_album(items, search_artist=None, search_album=None, likelies, consensus = current_metadata(items) cur_artist = likelies['artist'] cur_album = likelies['album'] - log.debug(u'Tagging {0} - {1}'.format((cur_artist, cur_album))) + log.debug(u'Tagging {0} - {1}'.format(cur_artist, cur_album)) # The output result (distance, AlbumInfo) tuples (keyed by MB album # ID). diff --git a/beets/importer.py b/beets/importer.py index 7444ae849..a758f35eb 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -630,12 +630,12 @@ class ImportTask(object): self.replaced_items[item] = dup_items for dup_item in dup_items: log.debug(u'replacing item {0}: {1}' - .format((dup_item.id, - displayable_path(item.path)))) + .format(dup_item.id, + displayable_path(item.path))) dup_item.remove() log.debug(u'{0} of {1} items replaced' - .format((len(self.replaced_items), - len(self.imported_items())))) + .format(len(self.replaced_items), + len(self.imported_items()))) def choose_match(self, session): """Ask the session which match should apply and apply it. @@ -904,8 +904,7 @@ def read_tasks(session): item = library.Item.from_path(toppath) except mediafile.UnreadableFileError: log.warn(u'unreadable file: {0}'.format( - util.displayable_path(toppath) - )) + util.displayable_path(toppath))) continue if session.config['singletons']: yield SingletonImportTask(toppath, item) @@ -974,7 +973,7 @@ def query_tasks(session): # Search for albums. for album in session.lib.albums(session.query): log.debug(u'yielding album {0}: {1} - {2}' - .format((album.id, album.albumartist, album.album))) + .format(album.id, album.albumartist, album.album)) items = list(album.items()) # Clear IDs from re-tagged items so they appear "fresh" when diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 027657a2b..88687693b 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -497,7 +497,7 @@ class LyricsPlugin(BeetsPlugin): # Skip if the item already has lyrics. if not force and item.lyrics: log.log(loglevel, u'lyrics already present: {0} - {1}' - .format((item.artist, item.title))) + .format(item.artist, item.title)) return artist = remove_ft_artist_suffix(item.artist) From cbb7aaf56be09e3b9deb29c2fc65c94d35217d39 Mon Sep 17 00:00:00 2001 From: e5e4eaeacd39c5cfba4d7c852c48277ae50331e6 Date: Sat, 23 Aug 2014 11:56:11 +1000 Subject: [PATCH 4/6] Oh the formatting --- beets/autotag/match.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 94fb3352c..8c29475e6 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -383,7 +383,7 @@ def _add_candidate(items, results, info): log.debug(u'Ignored. Penalty: {0}'.format(penalty)) return - log.debug(u'Success. Distance: {02.2f}'.format(dist)) + log.debug(u'Success. Distance: {0:2.2f}'.format(dist)) results[info.album_id] = hooks.AlbumMatch(dist, info, mapping, extra_items, extra_tracks) From 5fe012f27a667e80c2d2d6d4d96449c1bbef9af0 Mon Sep 17 00:00:00 2001 From: e5e4eaeacd39c5cfba4d7c852c48277ae50331e6 Date: Sat, 23 Aug 2014 12:02:30 +1000 Subject: [PATCH 5/6] Just go back to basics --- beets/autotag/match.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 8c29475e6..40c0a991b 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -383,7 +383,7 @@ def _add_candidate(items, results, info): log.debug(u'Ignored. Penalty: {0}'.format(penalty)) return - log.debug(u'Success. Distance: {0:2.2f}'.format(dist)) + log.debug(u'Success. Distance: {0}'.format(dist)) results[info.album_id] = hooks.AlbumMatch(dist, info, mapping, extra_items, extra_tracks) From 5f5ee40172ef0c076d0f7fae8f8422623d50a0e8 Mon Sep 17 00:00:00 2001 From: e5e4eaeacd39c5cfba4d7c852c48277ae50331e6 Date: Sat, 23 Aug 2014 12:17:24 +1000 Subject: [PATCH 6/6] displayable_path clean up error --- beets/ui/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index caefdc2a1..38d84b1e9 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1387,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(util.displayable_pathobj.path)) + log.debug(u'moving: {0}'.format(util.displayable_path(obj.path))) obj.move(copy, basedir=dest) obj.store()