Further whitespace fiddling

Most commonly, this sticks with:

    log.debug(
        'some long message here'
    )

instead of placing the closing ) at the end of the string literal.
This commit is contained in:
Adrian Sampson 2016-02-28 14:48:10 -08:00
parent 1478ba734f
commit d53019f9db
12 changed files with 94 additions and 56 deletions

View file

@ -828,7 +828,9 @@ class Item(LibModel):
log.warning(
u'Fell back to default replacements when naming '
u'file {}. Configure replacements to avoid lengthening '
u'the filename.', subpath)
u'the filename.',
subpath
)
if fragment:
return subpath

View file

@ -1144,7 +1144,10 @@ def _configure(options):
log.warning(
u'Warning: configuration uses "{0}" which is deprecated'
u' in favor of "{1}" now that it affects all commands. '
u'See changelog & documentation.'.format(old_key, new_key))
u'See changelog & documentation.',
old_key,
new_key,
)
config[new_key].set(config[old_key])
config_path = config.user_config_path()

View file

@ -56,54 +56,54 @@ class DuplicatesPlugin(BeetsPlugin):
self._command.parser.add_option(
u'-c', u'--count', dest='count',
action='store_true',
help=u'show duplicate counts')
help=u'show duplicate counts',
)
self._command.parser.add_option(
u'-C', u'--checksum', dest='checksum',
action='store', metavar='PROG',
help=u'report duplicates based on arbitrary command')
help=u'report duplicates based on arbitrary command',
)
self._command.parser.add_option(
u'-d', u'--delete', dest='delete',
action='store_true',
help=u'delete items from library and disk')
help=u'delete items from library and disk',
)
self._command.parser.add_option(
u'-F', u'--full', dest='full',
action='store_true',
help=u'show all versions of duplicate tracks or albums')
help=u'show all versions of duplicate tracks or albums',
)
self._command.parser.add_option(
u'-s', u'--strict', dest='strict',
action='store_true',
help=u'report duplicates only if all attributes are set')
help=u'report duplicates only if all attributes are set',
)
self._command.parser.add_option(
u'-k', u'--keys', dest='keys',
action='callback', metavar='KEY1 KEY2',
callback=vararg_callback,
help=u'report duplicates based on keys')
help=u'report duplicates based on keys',
)
self._command.parser.add_option(
u'-M', u'--merge', dest='merge',
action='store_true',
help=u'merge duplicate items')
help=u'merge duplicate items',
)
self._command.parser.add_option(
u'-m', u'--move', dest='move',
action='store', metavar='DEST',
help=u'move items to dest')
help=u'move items to dest',
)
self._command.parser.add_option(
u'-o', u'--copy', dest='copy',
action='store', metavar='DEST',
help=u'copy items to dest')
help=u'copy items to dest',
)
self._command.parser.add_option(
u'-t', u'--tag', dest='tag',
action='store',
help=u'tag matched items with \'k=v\' attribute')
help=u'tag matched items with \'k=v\' attribute',
)
self._command.parser.add_all_common_options()
def commands(self):
@ -186,7 +186,8 @@ class DuplicatesPlugin(BeetsPlugin):
k, v = tag.split('=')
except:
raise UserError(
u'%s: can\'t parse k=v tag: %s' % (PLUGIN, tag))
u"{}: can't parse k=v tag: {}".format(PLUGIN, tag)
)
setattr(item, k, v)
item.store()

View file

@ -85,16 +85,20 @@ class EmbedCoverArtPlugin(BeetsPlugin):
# Extract command.
extract_cmd = ui.Subcommand(
'extractart',
help=u'extract an image from file metadata')
help=u'extract an image from file metadata',
)
extract_cmd.parser.add_option(
u'-o', dest='outpath',
help=u'image output file')
help=u'image output file',
)
extract_cmd.parser.add_option(
u'-n', dest='filename',
help=u'image filename to create for all matched albums')
help=u'image filename to create for all matched albums',
)
extract_cmd.parser.add_option(
'-a', dest='associate', action='store_true',
help='associate the extracted images with the album')
help='associate the extracted images with the album',
)
def extract_func(lib, opts, args):
if opts.outpath:
@ -119,7 +123,8 @@ class EmbedCoverArtPlugin(BeetsPlugin):
# Clear command.
clear_cmd = ui.Subcommand(
'clearart',
help=u'remove images from file metadata')
help=u'remove images from file metadata',
)
def clear_func(lib, opts, args):
art.clear(self._log, lib, decargs(args))

View file

@ -119,7 +119,8 @@ class EmbyUpdate(BeetsPlugin):
token = get_token(host, port, headers, auth_data)
if not token:
self._log.warning(
u'Could not get token for user {0}'.format(username))
u'Could not get token for user {0}', username
)
return
# Recreate headers with a token.

View file

@ -292,7 +292,8 @@ class Wikipedia(ArtSource):
if ' .' in cover_filename and \
'.' not in cover_filename.split(' .')[-1]:
self._log.debug(
u'wikipedia: dbpedia provided incomplete cover_filename')
u'wikipedia: dbpedia provided incomplete cover_filename'
)
lpart, rpart = cover_filename.rsplit(' .', 1)
# Query all the images in the page
@ -320,7 +321,8 @@ class Wikipedia(ArtSource):
break
except (ValueError, KeyError):
self._log.debug(
u'wikipedia: failed to retrieve a cover_filename')
u'wikipedia: failed to retrieve a cover_filename'
)
return
# Find the absolute url of the cover art on Wikipedia
@ -493,7 +495,8 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin):
cmd.parser.add_option(
u'-f', u'--force', dest='force',
action='store_true', default=False,
help=u're-download art when already present')
help=u're-download art when already present'
)
def func(lib, opts, args):
self.batch_fetch_art(lib, lib.albums(ui.decargs(args)), opts.force)

View file

@ -144,17 +144,21 @@ class InfoPlugin(BeetsPlugin):
cmd.func = self.run
cmd.parser.add_option(
u'-l', u'--library', action='store_true',
help=u'show library fields instead of tags')
help=u'show library fields instead of tags',
)
cmd.parser.add_option(
u'-s', u'--summarize', action='store_true',
help=u'summarize the tags of all files')
help=u'summarize the tags of all files',
)
cmd.parser.add_option(
u'-i', u'--include-keys', default=[],
action='append', dest='included_keys',
help=u'comma separated list of keys to show')
help=u'comma separated list of keys to show',
)
cmd.parser.add_option(
u'-k', u'--keys-only', action='store_true',
help=u'show only the keys')
help=u'show only the keys',
)
cmd.parser.add_format_option(target='item')
return [cmd]

View file

@ -239,25 +239,29 @@ class LastGenrePlugin(plugins.BeetsPlugin):
"""Return the album genre for this Item or Album.
"""
return self._last_lookup(
u'album', LASTFM.get_album, obj.albumartist, obj.album)
u'album', LASTFM.get_album, obj.albumartist, obj.album
)
def fetch_album_artist_genre(self, obj):
"""Return the album artist genre for this Item or Album.
"""
return self._last_lookup(
u'artist', LASTFM.get_artist, obj.albumartist)
u'artist', LASTFM.get_artist, obj.albumartist
)
def fetch_artist_genre(self, item):
"""Returns the track artist genre for this Item.
"""
return self._last_lookup(
u'artist', LASTFM.get_artist, item.artist)
u'artist', LASTFM.get_artist, item.artist
)
def fetch_track_genre(self, obj):
"""Returns the track genre for this Item.
"""
return self._last_lookup(
u'track', LASTFM.get_track, obj.artist, obj.title)
u'track', LASTFM.get_track, obj.artist, obj.title
)
def _get_genre(self, obj):
"""Get the genre string for an Album or Item object based on

View file

@ -578,11 +578,13 @@ class LyricsPlugin(plugins.BeetsPlugin):
cmd.parser.add_option(
u'-p', u'--print', dest='printlyr',
action='store_true', default=False,
help=u'print lyrics to console')
help=u'print lyrics to console',
)
cmd.parser.add_option(
u'-f', u'--force', dest='force_refetch',
action='store_true', default=False,
help=u'always re-download lyrics')
help=u'always re-download lyrics',
)
def func(lib, opts, args):
# The "write to files" option corresponds to the

View file

@ -107,6 +107,7 @@ class MusicBrainzCollectionPlugin(BeetsPlugin):
# Submit to MusicBrainz.
self._log.info(
u'Updating MusicBrainz collection {0}...', collection_id)
u'Updating MusicBrainz collection {0}...', collection_id
)
submit_albums(collection_id, album_ids)
self._log.info(u'...MusicBrainz collection updated.')

View file

@ -204,7 +204,8 @@ class Bs1770gainBackend(Backend):
# Invoke the command.
self._log.debug(
u'executing {0}', u' '.join(map(displayable_path, args)))
u'executing {0}', u' '.join(map(displayable_path, args))
)
output = call(args)
self._log.debug(u'analysis finished: {0}', output)
@ -274,7 +275,8 @@ class CommandBackend(Backend):
pass
if not self.command:
raise FatalReplayGainError(
u'no replaygain command found: install mp3gain or aacgain')
u'no replaygain command found: install mp3gain or aacgain'
)
self.noclip = config['noclip'].get(bool)
target_level = config['targetlevel'].as_number()
@ -395,7 +397,8 @@ class GStreamerBackend(Backend):
if self._src is None or self._decbin is None or self._conv is None \
or self._res is None or self._rg is None:
raise FatalGstreamerPluginReplayGainError(
u"Failed to load required GStreamer plugins")
u"Failed to load required GStreamer plugins"
)
# We check which files need gain ourselves, so all files given
# to rganalsys should have their gain computed, even if it
@ -441,13 +444,15 @@ class GStreamerBackend(Backend):
import gi
except ImportError:
raise FatalReplayGainError(
u"Failed to load GStreamer: python-gi not found")
u"Failed to load GStreamer: python-gi not found"
)
try:
gi.require_version('Gst', '1.0')
except ValueError as e:
raise FatalReplayGainError(
u"Failed to load GStreamer 1.0: {0}".format(e))
u"Failed to load GStreamer 1.0: {0}".format(e)
)
from gi.repository import GObject, Gst, GLib
# Calling GObject.threads_init() is not needed for
@ -534,7 +539,8 @@ class GStreamerBackend(Backend):
f = self._src.get_property("location")
# A GStreamer error, either an unsupported format or a bug.
self._error = ReplayGainError(
u"Error {0!r} - {1!r} on file {2!r}".format(err, debug, f))
u"Error {0!r} - {1!r} on file {2!r}".format(err, debug, f)
)
def _on_tag(self, bus, message):
tags = message.parse_tag()
@ -657,7 +663,8 @@ class AudioToolsBackend(Backend):
import audiotools.replaygain
except ImportError:
raise FatalReplayGainError(
u"Failed to load audiotools: audiotools not found")
u"Failed to load audiotools: audiotools not found"
)
self._mod_audiotools = audiotools
self._mod_replaygain = audiotools.replaygain
@ -674,10 +681,12 @@ class AudioToolsBackend(Backend):
audiofile = self._mod_audiotools.open(item.path)
except IOError:
raise ReplayGainError(
u"File {} was not found".format(item.path))
u"File {} was not found".format(item.path)
)
except self._mod_audiotools.UnsupportedFile:
raise ReplayGainError(
u"Unsupported file type {}".format(item.format))
u"Unsupported file type {}".format(item.format)
)
return audiofile
@ -902,7 +911,8 @@ class ReplayGainPlugin(BeetsPlugin):
track_gains = self.backend_instance.compute_track_gain([item])
if len(track_gains) != 1:
raise ReplayGainError(
u"ReplayGain backend failed for track {0}".format(item))
u"ReplayGain backend failed for track {0}".format(item)
)
self.store_track_gain(item, track_gains[0])
if write:

View file

@ -47,8 +47,9 @@ class SmartPlaylistPlugin(BeetsPlugin):
def commands(self):
spl_update = ui.Subcommand(
'splupdate',
help=u'update the smart playlists. Playlist '
u'names may be passed as arguments.')
help=u'update the smart playlists. Playlist names may be '
u'passed as arguments.'
)
spl_update.func = self.update_cmd
return [spl_update]
@ -66,7 +67,8 @@ class SmartPlaylistPlugin(BeetsPlugin):
if not playlists:
raise ui.UserError(
u'No playlist matching any of {0} found'.format(
[name for name, _, _ in self._unmatched_playlists]))
[name for name, _, _ in self._unmatched_playlists])
)
self._matched_playlists = playlists
self._unmatched_playlists -= playlists