py3: Use list comprehensions instead of filter()

This is just a stylistic change, and is not strictly required for Python 3
compat.
This commit is contained in:
Stein Magnus Jodal 2014-12-07 20:14:53 +01:00
parent 1d26c2d63c
commit 95df66865e
3 changed files with 7 additions and 7 deletions

View File

@ -44,7 +44,7 @@ class DummyLibraryProvider(backend.LibraryProvider):
return self.dummy_find_exact_result
def lookup(self, uri):
return filter(lambda t: uri == t.uri, self.dummy_library)
return [t for t in self.dummy_library if uri == t.uri]
def refresh(self, uri=None):
pass

View File

@ -334,10 +334,10 @@ class TracklistController(object):
# Fail hard if anyone is using the <0.17 calling style
raise ValueError('Filter values must be iterable: %r' % values)
if key == 'tlid':
matches = filter(lambda ct: ct.tlid in values, matches)
matches = [ct for ct in matches if ct.tlid in values]
else:
matches = filter(
lambda ct: getattr(ct.track, key) in values, matches)
matches = [
ct for ct in matches if getattr(ct.track, key) in values]
return matches
def move(self, start, end, to_position):

View File

@ -59,13 +59,13 @@ def track_to_mpd_format(track, position=None):
if track.album is not None and track.album.artists:
artists = artists_to_mpd_format(track.album.artists)
result.append(('AlbumArtist', artists))
artists = filter(
lambda a: a.musicbrainz_id is not None, track.album.artists)
artists = [
a for a in track.album.artists if a.musicbrainz_id is not None]
if artists:
result.append(
('MUSICBRAINZ_ALBUMARTISTID', artists[0].musicbrainz_id))
if track.artists:
artists = filter(lambda a: a.musicbrainz_id is not None, track.artists)
artists = [a for a in track.artists if a.musicbrainz_id is not None]
if artists:
result.append(('MUSICBRAINZ_ARTISTID', artists[0].musicbrainz_id))