From f9f6f9394dbdeec8a858e9ab82089d16a6893a98 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 31 Oct 2012 15:25:39 +0100 Subject: [PATCH] Remove stored_playlists.rename() (#217) --- docs/changes.rst | 3 +++ mopidy/backends/base.py | 8 -------- mopidy/backends/local/stored_playlists.py | 13 ------------- mopidy/core/stored_playlists.py | 13 ------------- tests/backends/base/stored_playlists.py | 10 ---------- 5 files changed, 3 insertions(+), 44 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index 285af6b3..9c2bea62 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -67,6 +67,9 @@ backends: playlist. The returned playlist may differ from the saved playlist, and should thus be used instead of the playlist passed to ``save()``. + - :meth:`mopidy.core.StoredPlaylistsController.rename` has been removed, + since renaming can be done with ``save()``. + **Changes** - Made the :mod:`NAD mixer ` responsive to interrupts diff --git a/mopidy/backends/base.py b/mopidy/backends/base.py index 7ae2c3dc..e4c40a92 100644 --- a/mopidy/backends/base.py +++ b/mopidy/backends/base.py @@ -204,14 +204,6 @@ class BaseStoredPlaylistsProvider(object): """ raise NotImplementedError - def rename(self, playlist, new_name): - """ - See :meth:`mopidy.core.StoredPlaylistsController.rename`. - - *MUST be implemented by subclass.* - """ - raise NotImplementedError - def save(self, playlist): """ See :meth:`mopidy.core.StoredPlaylistsController.save`. diff --git a/mopidy/backends/local/stored_playlists.py b/mopidy/backends/local/stored_playlists.py index 621d37bf..6d12dd46 100644 --- a/mopidy/backends/local/stored_playlists.py +++ b/mopidy/backends/local/stored_playlists.py @@ -64,19 +64,6 @@ class LocalStoredPlaylistsProvider(base.BaseStoredPlaylistsProvider): self.playlists = playlists - def rename(self, playlist, name): - if playlist not in self._playlists: - return - - src = os.path.join(self._folder, playlist.name + '.m3u') - dst = os.path.join(self._folder, name + '.m3u') - - renamed = playlist.copy(name=name) - index = self._playlists.index(playlist) - self._playlists[index] = renamed - - shutil.move(src, dst) - def save(self, playlist): assert playlist.uri, 'Cannot save playlist without URI' diff --git a/mopidy/core/stored_playlists.py b/mopidy/core/stored_playlists.py index 8f87db58..af88d86b 100644 --- a/mopidy/core/stored_playlists.py +++ b/mopidy/core/stored_playlists.py @@ -119,19 +119,6 @@ class StoredPlaylistsController(object): backend = self.backends.by_uri_scheme[uri_scheme] backend.stored_playlists.refresh().get() - def rename(self, playlist, new_name): - """ - Rename playlist. - - :param playlist: the playlist - :type playlist: :class:`mopidy.models.Playlist` - :param new_name: the new name - :type new_name: string - """ - # TODO Support multiple backends - return self.backends[0].stored_playlists.rename( - playlist, new_name).get() - def save(self, playlist): """ Save the playlist to the set of stored playlists. diff --git a/tests/backends/base/stored_playlists.py b/tests/backends/base/stored_playlists.py index 83c243f3..ba907b13 100644 --- a/tests/backends/base/stored_playlists.py +++ b/tests/backends/base/stored_playlists.py @@ -103,16 +103,6 @@ class StoredPlaylistsControllerTest(object): def test_refresh(self): pass - def test_rename(self): - playlist = self.stored.create('test') - self.stored.rename(playlist, 'test2') - self.stored.get(name='test2') - - def test_rename_unknown_playlist(self): - self.stored.rename(Playlist(), 'test2') - test = lambda: self.stored.get(name='test2') - self.assertRaises(LookupError, test) - def test_save_replaces_stored_playlist_with_updated_playlist(self): playlist1 = self.stored.create('test1') self.assertIn(playlist1, self.stored.playlists)