diff --git a/beetsplug/beatport.py b/beetsplug/beatport.py index 6990bd796..86193a971 100644 --- a/beetsplug/beatport.py +++ b/beetsplug/beatport.py @@ -96,9 +96,11 @@ class BeatportRelease(BeatportObject): artist_str = ", ".join(x[1] for x in self.artists) else: artist_str = "Various Artists" - return u"".format(artist_str, - self.name, - self.catalog_number) + return u"".format( + artist_str, + self.name, + self.catalog_number, + ) def __init__(self, data): BeatportObject.__init__(self, data) diff --git a/beetsplug/bench.py b/beetsplug/bench.py index 386c365ed..56695e7c4 100644 --- a/beetsplug/bench.py +++ b/beetsplug/bench.py @@ -95,7 +95,7 @@ class BenchmarkPlugin(BeetsPlugin): aunique_benchmark(lib, opts.profile) match_bench_cmd = ui.Subcommand('bench_match', - help='benchmark for track matching') + help='benchmark for track matching') match_bench_cmd.parser.add_option('-p', '--profile', action='store_true', default=False, help='performance profiling') diff --git a/beetsplug/bpd/__init__.py b/beetsplug/bpd/__init__.py index 488d56d44..8b565d9dc 100644 --- a/beetsplug/bpd/__init__.py +++ b/beetsplug/bpd/__init__.py @@ -98,12 +98,13 @@ class BPDError(Exception): """Returns a string to be used as the response code for the erring command. """ - return self.template.substitute({'resp': RESP_ERR, - 'code': self.code, - 'index': self.index, - 'cmd_name': self.cmd_name, - 'message': self.message - }) + return self.template.substitute({ + 'resp': RESP_ERR, + 'code': self.code, + 'index': self.index, + 'cmd_name': self.cmd_name, + 'message': self.message, + }) def make_bpd_error(s_code, s_message): @@ -301,13 +302,14 @@ class BaseServer(object): Gives a list of response-lines for: volume, repeat, random, playlist, playlistlength, and xfade. """ - yield (u'volume: ' + unicode(self.volume), - u'repeat: ' + unicode(int(self.repeat)), - u'random: ' + unicode(int(self.random)), - u'playlist: ' + unicode(self.playlist_version), - u'playlistlength: ' + unicode(len(self.playlist)), - u'xfade: ' + unicode(self.crossfade), - ) + yield ( + u'volume: ' + unicode(self.volume), + u'repeat: ' + unicode(int(self.repeat)), + u'random: ' + unicode(int(self.random)), + u'playlist: ' + unicode(self.playlist_version), + u'playlistlength: ' + unicode(len(self.playlist)), + u'xfade: ' + unicode(self.crossfade), + ) if self.current_index == -1: state = u'stop' @@ -765,13 +767,14 @@ class Server(BaseServer): # Metadata helper functions. def _item_info(self, item): - info_lines = [u'file: ' + item.destination(fragment=True), - u'Time: ' + unicode(int(item.length)), - u'Title: ' + item.title, - u'Artist: ' + item.artist, - u'Album: ' + item.album, - u'Genre: ' + item.genre, - ] + info_lines = [ + u'file: ' + item.destination(fragment=True), + u'Time: ' + unicode(int(item.length)), + u'Title: ' + item.title, + u'Artist: ' + item.artist, + u'Album: ' + item.album, + u'Genre: ' + item.genre, + ] track = unicode(item.track) if item.tracktotal: @@ -951,14 +954,15 @@ class Server(BaseServer): 'FROM items' artists, albums, songs, totaltime = tx.query(statement)[0] - yield (u'artists: ' + unicode(artists), - u'albums: ' + unicode(albums), - u'songs: ' + unicode(songs), - u'uptime: ' + unicode(int(time.time() - self.startup_time)), - u'playtime: ' + u'0', # Missing. - u'db_playtime: ' + unicode(int(totaltime)), - u'db_update: ' + unicode(int(self.updated_time)), - ) + yield ( + u'artists: ' + unicode(artists), + u'albums: ' + unicode(albums), + u'songs: ' + unicode(songs), + u'uptime: ' + unicode(int(time.time() - self.startup_time)), + u'playtime: ' + u'0', # Missing. + u'db_playtime: ' + unicode(int(totaltime)), + u'db_update: ' + unicode(int(self.updated_time)), + ) # Searching. @@ -1010,8 +1014,9 @@ class Server(BaseServer): for tag, value in zip(it, it): if tag.lower() == u'any': if any_query_type: - queries.append(any_query_type(value, - ITEM_KEYS_WRITABLE, query_type)) + queries.append(any_query_type(value, + ITEM_KEYS_WRITABLE, + query_type)) else: raise BPDError(ERROR_UNKNOWN, u'no such tagtype') else: @@ -1072,10 +1077,11 @@ class Server(BaseServer): def cmd_outputs(self, conn): """List the available outputs.""" - yield (u'outputid: 0', - u'outputname: gstreamer', - u'outputenabled: 1', - ) + yield ( + u'outputid: 0', + u'outputname: gstreamer', + u'outputenabled: 1', + ) def cmd_enableoutput(self, conn, output_id): output_id = cast_arg(int, output_id) @@ -1159,10 +1165,13 @@ class BPDPlugin(BeetsPlugin): 'or similar package to use BPD.') def commands(self): - cmd = beets.ui.Subcommand('bpd', - help='run an MPD-compatible music player server') - cmd.parser.add_option('-d', '--debug', action='store_true', - help='dump all MPD traffic to stdout') + cmd = beets.ui.Subcommand( + 'bpd', help='run an MPD-compatible music player server' + ) + cmd.parser.add_option( + '-d', '--debug', action='store_true', + help='dump all MPD traffic to stdout' + ) def func(lib, opts, args): host = args.pop(0) if args else self.config['host'].get(unicode) diff --git a/beetsplug/chroma.py b/beetsplug/chroma.py index a51148a8b..b7a1ec781 100644 --- a/beetsplug/chroma.py +++ b/beetsplug/chroma.py @@ -159,8 +159,10 @@ class AcoustidPlugin(plugins.BeetsPlugin): submit_items(apikey, lib.items(ui.decargs(args))) submit_cmd.func = submit_cmd_func - fingerprint_cmd = ui.Subcommand('fingerprint', - help='generate fingerprints for items without them') + fingerprint_cmd = ui.Subcommand( + 'fingerprint', + help='generate fingerprints for items without them' + ) def fingerprint_cmd_func(lib, opts, args): for item in lib.items(ui.decargs(args)): @@ -260,7 +262,7 @@ def fingerprint_item(item, write=False): elif item.acoustid_fingerprint: if write: log.info(u'{0}: fingerprint exists, skipping'.format( - util.displayable_path(item.path) + util.displayable_path(item.path) )) else: log.info(u'{0}: using existing fingerprint'.format( diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 73f3cc632..23f223662 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -130,7 +130,7 @@ def should_transcode(item): maxbr = config['convert']['max_bitrate'].get(int) format_name = config['convert']['format'].get(unicode) return format_name.lower() != item.format.lower() or \ - item.bitrate >= 1000 * maxbr + item.bitrate >= 1000 * maxbr def convert_item(dest_dir, keep_new, path_formats): @@ -215,14 +215,14 @@ def convert_on_import(lib, item): def convert_func(lib, opts, args): dest = opts.dest if opts.dest is not None else \ - config['convert']['dest'].get() + config['convert']['dest'].get() if not dest: raise ui.UserError('no convert destination set') dest = util.bytestring_path(dest) threads = opts.threads if opts.threads is not None else \ - config['convert']['threads'].get(int) + config['convert']['threads'].get(int) keep_new = opts.keep_new if not config['convert']['paths']: diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index d7639f83d..d33991144 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -75,7 +75,7 @@ class DiscogsPlugin(BeetsPlugin): # An optional bracket can follow the integer, as this is how discogs # displays the release ID on its webpage. match = re.search(r'(^|\[*r|discogs\.com/.+/release/)(\d+)($|\])', - album_id) + album_id) if not match: return None result = Release(match.group(2)) @@ -186,8 +186,9 @@ class DiscogsPlugin(BeetsPlugin): # is not sequential. For example, I, II, III, IV, V. Assume these # are the track index, not the medium. medium_is_index = track.medium and not track.medium_index and ( - len(track.medium) != 1 or - ord(track.medium) - 64 != medium_count + 1) + len(track.medium) != 1 or + ord(track.medium) - 64 != medium_count + 1 + ) if not medium_is_index and medium != track.medium: # Increment medium_count and reset index_count when medium diff --git a/beetsplug/echonest.py b/beetsplug/echonest.py index 2a96619da..6403c7b64 100644 --- a/beetsplug/echonest.py +++ b/beetsplug/echonest.py @@ -217,7 +217,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin): # Use the Echo Nest ID to look up the song. songs = self._echofun(pyechonest.song.profile, ids=enid, - buckets=['id:musicbrainz', 'audio_summary']) + buckets=['id:musicbrainz', 'audio_summary']) return self._flatten_song(self._pick_song(songs, item)) # "Search" (metadata-based) lookup. @@ -446,17 +446,18 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin): def commands(self): fetch_cmd = ui.Subcommand('echonest', - help='Fetch metadata from the EchoNest') - fetch_cmd.parser.add_option('-f', '--force', dest='force', - action='store_true', default=False, - help='(re-)download information from the EchoNest') + help='Fetch metadata from the EchoNest') + fetch_cmd.parser.add_option( + '-f', '--force', dest='force', action='store_true', default=False, + help='(re-)download information from the EchoNest' + ) def fetch_func(lib, opts, args): self.config.set_args(opts) write = config['import']['write'].get(bool) for item in lib.items(ui.decargs(args)): log.info(u'echonest: {0} - {1}'.format(item.artist, - item.title)) + item.title)) if self.config['force'] or self.requires_update(item): song = self.fetch_song(item) if song: @@ -465,11 +466,14 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin): fetch_cmd.func = fetch_func sim_cmd = ui.Subcommand('echosim', help='show related files') - sim_cmd.parser.add_option('-t', '--threshold', dest='threshold', - action='store', type='float', default=0.15, - help='Set difference threshold') - sim_cmd.parser.add_option('-f', '--format', action='store', - default='${difference}: ${path}', help='print with custom format') + sim_cmd.parser.add_option( + '-t', '--threshold', dest='threshold', action='store', + type='float', default=0.15, help='Set difference threshold' + ) + sim_cmd.parser.add_option( + '-f', '--format', action='store', default='${difference}: ${path}', + help='print with custom format' + ) def sim_func(lib, opts, args): self.config.set_args(opts) diff --git a/beetsplug/echonest_tempo.py b/beetsplug/echonest_tempo.py index db67a05ee..dea57c879 100644 --- a/beetsplug/echonest_tempo.py +++ b/beetsplug/echonest_tempo.py @@ -129,7 +129,7 @@ class EchoNestTempoPlugin(BeetsPlugin): }) pyechonest.config.ECHO_NEST_API_KEY = \ - self.config['apikey'].get(unicode) + self.config['apikey'].get(unicode) def commands(self): cmd = ui.Subcommand('tempo', help='fetch song tempo (bpm)') diff --git a/beetsplug/embedart.py b/beetsplug/embedart.py index 4b1aca067..085e63e16 100644 --- a/beetsplug/embedart.py +++ b/beetsplug/embedart.py @@ -73,10 +73,12 @@ class EmbedCoverArtPlugin(BeetsPlugin): def commands(self): # Embed command. - embed_cmd = ui.Subcommand('embedart', - help='embed image files into file metadata') - embed_cmd.parser.add_option('-f', '--file', metavar='PATH', - help='the image file to embed') + embed_cmd = ui.Subcommand( + 'embedart', help='embed image files into file metadata' + ) + embed_cmd.parser.add_option( + '-f', '--file', metavar='PATH', help='the image file to embed' + ) def embed_func(lib, opts, args): if opts.file: diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index ac87c57f2..1b47e07c3 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -291,8 +291,8 @@ class FetchArtPlugin(BeetsPlugin): path = self.art_paths.pop(task) album = session.lib.get_album(task.album_id) - src_removed = config['import']['delete'].get(bool) or \ - config['import']['move'].get(bool) + src_removed = (config['import']['delete'].get(bool) or + config['import']['move'].get(bool)) album.set_art(path, not src_removed) album.store() if src_removed: diff --git a/beetsplug/importfeeds.py b/beetsplug/importfeeds.py index ca1b69b87..893c3e99c 100644 --- a/beetsplug/importfeeds.py +++ b/beetsplug/importfeeds.py @@ -93,7 +93,7 @@ def _record_items(lib, basename, items): feedsdir = bytestring_path(config['importfeeds']['dir'].as_filename()) formats = config['importfeeds']['formats'].as_str_seq() relative_to = config['importfeeds']['relative_to'].get() \ - or config['importfeeds']['dir'].as_filename() + or config['importfeeds']['dir'].as_filename() relative_to = bytestring_path(relative_to) paths = [] diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index db79ee2c2..eea428dfa 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -341,13 +341,14 @@ class LastGenrePlugin(plugins.BeetsPlugin): def commands(self): lastgenre_cmd = ui.Subcommand('lastgenre', help='fetch genres') - lastgenre_cmd.parser.add_option('-f', '--force', dest='force', - action='store_true', - default=False, - help='re-download genre when already present') - lastgenre_cmd.parser.add_option('-s', '--source', dest='source', - type='string', - help='genre source: artist, album, or track') + lastgenre_cmd.parser.add_option( + '-f', '--force', dest='force', action='store_true', default=False, + help='re-download genre when already present' + ) + lastgenre_cmd.parser.add_option( + '-s', '--source', dest='source', type='string', + help='genre source: artist, album, or track' + ) def lastgenre_func(lib, opts, args): write = config['import']['write'].get(bool) @@ -366,8 +367,11 @@ 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: item.try_write() @@ -381,19 +385,22 @@ class LastGenrePlugin(plugins.BeetsPlugin): album = session.lib.get_album(task.album_id) 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/mbcollection.py b/beetsplug/mbcollection.py index e4d8d4e70..1abdfec51 100644 --- a/beetsplug/mbcollection.py +++ b/beetsplug/mbcollection.py @@ -77,7 +77,7 @@ def update_collection(lib, opts, args): print('...MusicBrainz collection updated.') update_mb_collection_cmd = Subcommand('mbupdate', - help='Update MusicBrainz collection') + help='Update MusicBrainz collection') update_mb_collection_cmd.func = update_collection diff --git a/beetsplug/mpdstats.py b/beetsplug/mpdstats.py index 451aafe1b..41a0e7d6a 100644 --- a/beetsplug/mpdstats.py +++ b/beetsplug/mpdstats.py @@ -298,7 +298,7 @@ class MPDStats(object): handler(status) else: log.debug(u'mpdstats: unhandled status "{0}"'. - format(status)) + format(status)) events = self.mpd.events() diff --git a/beetsplug/random.py b/beetsplug/random.py index 05b898390..f594bd73b 100644 --- a/beetsplug/random.py +++ b/beetsplug/random.py @@ -21,7 +21,6 @@ from beets.util.functemplate import Template import random from operator import attrgetter from itertools import groupby -import collections def random_item(lib, opts, args): @@ -72,15 +71,15 @@ def random_item(lib, opts, args): random_cmd = Subcommand('random', help='chose a random track or album') random_cmd.parser.add_option('-a', '--album', action='store_true', - help='choose an album instead of track') + help='choose an album instead of track') random_cmd.parser.add_option('-p', '--path', action='store_true', - help='print the path of the matched item') + help='print the path of the matched item') random_cmd.parser.add_option('-f', '--format', action='store', - help='print with custom format', default=None) + help='print with custom format', default=None) random_cmd.parser.add_option('-n', '--number', action='store', type="int", - help='number of objects to choose', default=1) + help='number of objects to choose', default=1) random_cmd.parser.add_option('-e', '--equal-chance', action='store_true', - help='each artist has the same chance') + help='each artist has the same chance') random_cmd.func = random_item diff --git a/beetsplug/smartplaylist.py b/beetsplug/smartplaylist.py index 065e99f63..118dc361b 100644 --- a/beetsplug/smartplaylist.py +++ b/beetsplug/smartplaylist.py @@ -104,7 +104,7 @@ class SmartPlaylistPlugin(BeetsPlugin): def update(lib, opts, args): update_playlists(lib) spl_update = ui.Subcommand('splupdate', - help='update the smart playlists') + help='update the smart playlists') spl_update.func = update return [spl_update] diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 2aa8c3359..cf45d8c48 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -82,8 +82,9 @@ def resource(name): return flask.jsonify(_rep(entities[0])) elif entities: return app.response_class( - json_generator(entities, root=name), - mimetype='application/json') + json_generator(entities, root=name), + mimetype='application/json' + ) else: return flask.abort(404) responder.__name__ = 'get_%s' % name @@ -97,8 +98,9 @@ def resource_query(name): def make_responder(query_func): def responder(queries): return app.response_class( - json_generator(query_func(queries), root='results'), - mimetype='application/json') + json_generator(query_func(queries), root='results'), + mimetype='application/json' + ) responder.__name__ = 'query_%s' % name return responder return make_responder @@ -111,8 +113,9 @@ def resource_list(name): def make_responder(list_all): def responder(): return app.response_class( - json_generator(list_all(), root=name), - mimetype='application/json') + json_generator(list_all(), root=name), + mimetype='application/json' + ) responder.__name__ = 'all_%s' % name return responder return make_responder