Fix Pylint warnings
This commit is contained in:
parent
cca1c0e234
commit
67acd9f719
@ -12,7 +12,7 @@ def get_mpd_protocol_version():
|
||||
|
||||
class MopidyException(Exception):
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
self._message = message
|
||||
|
||||
@property
|
||||
def message(self):
|
||||
|
||||
@ -60,6 +60,9 @@ class DespotifyLibraryController(BaseLibraryController):
|
||||
track = self.backend.spotify.lookup(uri.encode(ENCODING))
|
||||
return DespotifyTranslator.to_mopidy_track(track)
|
||||
|
||||
def refresh(self, uri=None):
|
||||
pass # TODO
|
||||
|
||||
def search(self, **query):
|
||||
spotify_query = []
|
||||
for (field, values) in query.iteritems():
|
||||
@ -106,6 +109,9 @@ class DespotifyPlaybackController(BasePlaybackController):
|
||||
logger.error(e)
|
||||
return False
|
||||
|
||||
def _seek(self, time_position):
|
||||
pass # TODO
|
||||
|
||||
def _stop(self):
|
||||
try:
|
||||
self.backend.spotify.stop()
|
||||
@ -116,6 +122,15 @@ class DespotifyPlaybackController(BasePlaybackController):
|
||||
|
||||
|
||||
class DespotifyStoredPlaylistsController(BaseStoredPlaylistsController):
|
||||
def create(self, name):
|
||||
pass # TODO
|
||||
|
||||
def delete(self, playlist):
|
||||
pass # TODO
|
||||
|
||||
def lookup(self, uri):
|
||||
pass # TODO
|
||||
|
||||
def refresh(self):
|
||||
logger.info(u'Caching stored playlists')
|
||||
playlists = []
|
||||
@ -127,6 +142,12 @@ class DespotifyStoredPlaylistsController(BaseStoredPlaylistsController):
|
||||
u', '.join([u'<%s>' % p.name for p in self.playlists]))
|
||||
logger.info(u'Done caching stored playlists')
|
||||
|
||||
def rename(self, playlist, new_name):
|
||||
pass # TODO
|
||||
|
||||
def save(self, playlist):
|
||||
pass # TODO
|
||||
|
||||
|
||||
class DespotifyTranslator(object):
|
||||
@classmethod
|
||||
|
||||
@ -19,21 +19,28 @@ class DummyBackend(BaseBackend):
|
||||
self.stored_playlists = DummyStoredPlaylistsController(backend=self)
|
||||
self.uri_handlers = [u'dummy:']
|
||||
|
||||
|
||||
class DummyCurrentPlaylistController(BaseCurrentPlaylistController):
|
||||
pass
|
||||
|
||||
|
||||
class DummyLibraryController(BaseLibraryController):
|
||||
_library = []
|
||||
|
||||
def find_exact(self, **query):
|
||||
return Playlist()
|
||||
|
||||
def lookup(self, uri):
|
||||
matches = filter(lambda t: uri == t.uri, self._library)
|
||||
if matches:
|
||||
return matches[0]
|
||||
|
||||
def refresh(self, uri=None):
|
||||
pass
|
||||
|
||||
def search(self, **query):
|
||||
return Playlist()
|
||||
|
||||
find_exact = search
|
||||
|
||||
class DummyPlaybackController(BasePlaybackController):
|
||||
def _next(self, track):
|
||||
@ -51,6 +58,33 @@ class DummyPlaybackController(BasePlaybackController):
|
||||
def _resume(self):
|
||||
return True
|
||||
|
||||
def _seek(self, time_position):
|
||||
pass
|
||||
|
||||
def _stop(self):
|
||||
return True
|
||||
|
||||
|
||||
class DummyStoredPlaylistsController(BaseStoredPlaylistsController):
|
||||
def search(self, query):
|
||||
return [Playlist(name=query)]
|
||||
_playlists = []
|
||||
|
||||
def create(self, name):
|
||||
playlist = Playlist(name=name)
|
||||
self._playlists.append(playlist)
|
||||
return playlist
|
||||
|
||||
def delete(self, playlist):
|
||||
self._playlists.remove(playlist)
|
||||
|
||||
def lookup(self, uri):
|
||||
return filter(lambda p: p.uri == uri, self._playlists)
|
||||
|
||||
def refresh(self):
|
||||
pass
|
||||
|
||||
def rename(self, playlist, new_name):
|
||||
self._playlists[self._playlists.index(playlist)] = \
|
||||
playlist.with_(name=new_name)
|
||||
|
||||
def save(self, playlist):
|
||||
self._playlists.append(playlist)
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import gobject
|
||||
gobject.threads_init()
|
||||
# FIXME make sure we don't get hit by
|
||||
# http://jameswestby.net/weblog/tech/14-caution-python-multiprocessing-and-glib-dont-mix.html
|
||||
# http://jameswestby.net/
|
||||
# weblog/tech/14-caution-python-multiprocessing-and-glib-dont-mix.html
|
||||
|
||||
import pygst
|
||||
pygst.require('0.10')
|
||||
@ -71,9 +72,7 @@ class GStreamerPlaybackController(BasePlaybackController):
|
||||
|
||||
def _set_state(self, state):
|
||||
self._bin.set_state(state)
|
||||
|
||||
result, new, old = self._bin.get_state()
|
||||
|
||||
(_, new, _) = self._bin.get_state()
|
||||
return new == state
|
||||
|
||||
def _message(self, bus, message):
|
||||
@ -131,6 +130,9 @@ class GStreamerStoredPlaylistsController(BaseStoredPlaylistsController):
|
||||
self._folder = os.path.expanduser(settings.LOCAL_PLAYLIST_FOLDER)
|
||||
self.refresh()
|
||||
|
||||
def lookup(self, uri):
|
||||
pass # TODO
|
||||
|
||||
def refresh(self):
|
||||
playlists = []
|
||||
|
||||
@ -285,7 +287,7 @@ class GStreamerLibraryController(BaseLibraryController):
|
||||
return Playlist(tracks=result_tracks)
|
||||
|
||||
def _validate_query(self, query):
|
||||
for (field, values) in query.iteritems():
|
||||
for (_, values) in query.iteritems():
|
||||
if not values:
|
||||
raise LookupError('Missing query')
|
||||
for value in values:
|
||||
|
||||
@ -321,7 +321,7 @@ class MpdFrontend(object):
|
||||
cp_tracks = self.backend.current_playlist.cp_tracks[start:end]
|
||||
if not cp_tracks:
|
||||
raise MpdArgError(u'Bad song index', command=u'delete')
|
||||
for (cpid, track) in cp_tracks:
|
||||
for (cpid, _) in cp_tracks:
|
||||
self.backend.current_playlist.remove(cpid=cpid)
|
||||
|
||||
@handle_pattern(r'^delete "(?P<songpos>\d+)"$')
|
||||
@ -329,7 +329,7 @@ class MpdFrontend(object):
|
||||
"""See :meth:`_current_playlist_delete_range`"""
|
||||
try:
|
||||
songpos = int(songpos)
|
||||
(cpid, track) = self.backend.current_playlist.cp_tracks[songpos]
|
||||
(cpid, _) = self.backend.current_playlist.cp_tracks[songpos]
|
||||
self.backend.current_playlist.remove(cpid=cpid)
|
||||
except IndexError:
|
||||
raise MpdArgError(u'Bad song index', command=u'delete')
|
||||
@ -552,7 +552,7 @@ class MpdFrontend(object):
|
||||
# XXX Naive implementation that returns all tracks as changed
|
||||
if int(version) != self.backend.current_playlist.version:
|
||||
result = []
|
||||
for (position, (cpid, track)) in enumerate(
|
||||
for (position, (cpid, _)) in enumerate(
|
||||
self.backend.current_playlist.cp_tracks):
|
||||
result.append((u'cpos', position))
|
||||
result.append((u'Id', cpid))
|
||||
@ -630,7 +630,8 @@ class MpdFrontend(object):
|
||||
return [('songs', 0), ('playtime', 0)] # TODO
|
||||
|
||||
@handle_pattern(r'^find '
|
||||
r'(?P<mpd_query>("?([Aa]lbum|[Aa]rtist|[Ff]ilename|[Tt]itle|[Aa]ny)"? "[^"]+"\s?)+)$')
|
||||
r'(?P<mpd_query>("?([Aa]lbum|[Aa]rtist|[Ff]ilename|[Tt]itle|[Aa]ny)"?'
|
||||
' "[^"]+"\s?)+)$')
|
||||
def _music_db_find(self, mpd_query):
|
||||
"""
|
||||
*musicpd.org, music database section:*
|
||||
@ -655,7 +656,8 @@ class MpdFrontend(object):
|
||||
return self.backend.library.find_exact(**query).mpd_format()
|
||||
|
||||
@handle_pattern(r'^findadd '
|
||||
r'(?P<query>("?([Aa]lbum|[Aa]rtist|[Ff]ilename|[Tt]itle|[Aa]ny)"? "[^"]+"\s?)+)$')
|
||||
r'(?P<query>("?([Aa]lbum|[Aa]rtist|[Ff]ilename|[Tt]itle|[Aa]ny)"? '
|
||||
'"[^"]+"\s?)+)$')
|
||||
def _music_db_findadd(self, query):
|
||||
"""
|
||||
*musicpd.org, music database section:*
|
||||
@ -666,14 +668,15 @@ class MpdFrontend(object):
|
||||
current playlist. ``TYPE`` can be any tag supported by MPD.
|
||||
``WHAT`` is what to find.
|
||||
"""
|
||||
result = self._music_db_find(query)
|
||||
# TODO Add result to current playlist
|
||||
#return result
|
||||
#result = self._music_db_find(query)
|
||||
|
||||
@handle_pattern(r'^list (?P<field>[Aa]rtist)$')
|
||||
@handle_pattern(r'^list "(?P<field>[Aa]rtist)"$')
|
||||
@handle_pattern(r'^list (?P<field>album( artist)?)( "(?P<artist>[^"]+)")*$')
|
||||
@handle_pattern(r'^list "(?P<field>album(" "artist)?)"( "(?P<artist>[^"]+)")*$')
|
||||
@handle_pattern(r'^list (?P<field>album( artist)?)'
|
||||
'( "(?P<artist>[^"]+)")*$')
|
||||
@handle_pattern(r'^list "(?P<field>album(" "artist)?)"'
|
||||
'( "(?P<artist>[^"]+)")*$')
|
||||
def _music_db_list(self, field, artist=None):
|
||||
"""
|
||||
*musicpd.org, music database section:*
|
||||
@ -793,7 +796,8 @@ class MpdFrontend(object):
|
||||
return self._music_db_update(uri, rescan_unmodified_files=True)
|
||||
|
||||
@handle_pattern(r'^search '
|
||||
r'(?P<mpd_query>("?([Aa]lbum|[Aa]rtist|[Ff]ilename|[Tt]itle|[Aa]ny)"? "[^"]+"\s?)+)$')
|
||||
r'(?P<mpd_query>("?([Aa]lbum|[Aa]rtist|[Ff]ilename|[Tt]itle|[Aa]ny)"?'
|
||||
' "[^"]+"\s?)+)$')
|
||||
def _music_db_search(self, mpd_query):
|
||||
"""
|
||||
*musicpd.org, music database section:*
|
||||
|
||||
@ -58,7 +58,7 @@ def tracks_to_mpd_format(tracks, start=0, end=None, cpids=None):
|
||||
end = len(tracks)
|
||||
tracks = tracks[start:end]
|
||||
positions = range(start, end)
|
||||
cpids = cpids and cpids[start:end] or [None for t in tracks]
|
||||
cpids = cpids and cpids[start:end] or [None for _ in tracks]
|
||||
assert len(tracks) == len(positions) == len(cpids)
|
||||
result = []
|
||||
for track, position, cpid in zip(tracks, positions, cpids):
|
||||
|
||||
@ -26,7 +26,8 @@ class AlsaMixer(BaseMixer):
|
||||
return control
|
||||
else:
|
||||
logger.debug(u'Mixer control not found, skipping: %s', control)
|
||||
logger.warning(u'No working mixer controls found. Tried: %s', candidates)
|
||||
logger.warning(u'No working mixer controls found. Tried: %s',
|
||||
candidates)
|
||||
|
||||
def _get_mixer_control_candidates(self):
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user