From c513d0f6e7ea053628b240e185a572669b645b27 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Sun, 31 Oct 2010 23:44:45 +0100 Subject: [PATCH] Rename settings that have dirs or file to _PATH and _FILE --- bin/mopidy | 0 bin/mopidy-scan | 4 ++-- docs/settings.rst | 6 +++--- mopidy/backends/libspotify/__init__.py | 2 +- mopidy/backends/libspotify/session_manager.py | 4 ++-- mopidy/backends/local/__init__.py | 12 ++++++------ mopidy/frontends/mpd/translator.py | 4 ++-- mopidy/settings.py | 14 +++++++------- mopidy/utils/settings.py | 4 ++++ tests/backends/base/stored_playlists.py | 10 +++++----- tests/backends/local/library_test.py | 4 ++-- tests/backends/local/stored_playlists_test.py | 12 ++++++------ tests/frontends/mpd/serializer_test.py | 6 +++--- 13 files changed, 43 insertions(+), 39 deletions(-) mode change 100644 => 100755 bin/mopidy diff --git a/bin/mopidy b/bin/mopidy old mode 100644 new mode 100755 diff --git a/bin/mopidy-scan b/bin/mopidy-scan index 8534372c..1865f317 100755 --- a/bin/mopidy-scan +++ b/bin/mopidy-scan @@ -17,9 +17,9 @@ if __name__ == '__main__': def debug(uri, error): print >> sys.stderr, 'Failed %s: %s' % (uri, error) - print >> sys.stderr, 'Scanning %s' % settings.LOCAL_MUSIC_FOLDER + print >> sys.stderr, 'Scanning %s' % settings.LOCAL_MUSIC_PATH - scanner = Scanner(settings.LOCAL_MUSIC_FOLDER, store, debug) + scanner = Scanner(settings.LOCAL_MUSIC_PATH, store, debug) scanner.start() print >> sys.stderr, 'Done' diff --git a/docs/settings.rst b/docs/settings.rst index a7638b4e..41507a4a 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -47,12 +47,12 @@ Generating a tag cache Previously the local storage backend relied purely on ``tag_cache`` files generated by the original MPD server. To remedy this the command :command:`mopidy-scan` has been created. The program will scan your current -:attr:`mopidy.settings.LOCAL_MUSIC_FOLDER` and build a MPD compatible +:attr:`mopidy.settings.LOCAL_MUSIC_PATH` and build a MPD compatible ``tag_cache``. To make a ``tag_cache`` of your local music available for Mopidy: -#. Ensure that :attr:`mopidy.settings.LOCAL_MUSIC_FOLDER` points to where your +#. Ensure that :attr:`mopidy.settings.LOCAL_MUSIC_PATH` points to where your music is located. Check the current setting by running:: mopidy --list-settings @@ -64,7 +64,7 @@ To make a ``tag_cache`` of your local music available for Mopidy: mopidy-scan > tag_cache #. Move the ``tag_cache`` file to the location - :attr:`mopidy.settings.LOCAL_TAG_CACHE` is set to, or change the setting to + :attr:`mopidy.settings.LOCAL_TAG_CACHE_FILE` is set to, or change the setting to point to where your ``tag_cache`` file is. #. Start Mopidy, find the music library in a client, and play some local music! diff --git a/mopidy/backends/libspotify/__init__.py b/mopidy/backends/libspotify/__init__.py index 223d9968..75739d66 100644 --- a/mopidy/backends/libspotify/__init__.py +++ b/mopidy/backends/libspotify/__init__.py @@ -18,7 +18,7 @@ class LibspotifyBackend(BaseBackend): **Settings:** - - :attr:`mopidy.settings.SPOTIFY_LIB_CACHE` + - :attr:`mopidy.settings.SPOTIFY_CACHE_PATH` - :attr:`mopidy.settings.SPOTIFY_USERNAME` - :attr:`mopidy.settings.SPOTIFY_PASSWORD` diff --git a/mopidy/backends/libspotify/session_manager.py b/mopidy/backends/libspotify/session_manager.py index 45841350..3e11fc6f 100644 --- a/mopidy/backends/libspotify/session_manager.py +++ b/mopidy/backends/libspotify/session_manager.py @@ -15,8 +15,8 @@ logger = logging.getLogger('mopidy.backends.libspotify.session_manager') # LibspotifySessionManager: Too many ancestors (9/7) class LibspotifySessionManager(SpotifySessionManager, BaseThread): - cache_location = os.path.expanduser(settings.SPOTIFY_LIB_CACHE) - settings_location = os.path.expanduser(settings.SPOTIFY_LIB_CACHE) + cache_location = os.path.expanduser(settings.SPOTIFY_CACHE_PATH) + settings_location = os.path.expanduser(settings.SPOTIFY_CACHE_PATH) appkey_file = os.path.join(os.path.dirname(__file__), 'spotify_appkey.key') user_agent = 'Mopidy %s' % get_version() diff --git a/mopidy/backends/local/__init__.py b/mopidy/backends/local/__init__.py index efcc3bbd..01dcf1df 100644 --- a/mopidy/backends/local/__init__.py +++ b/mopidy/backends/local/__init__.py @@ -23,9 +23,9 @@ class LocalBackend(BaseBackend): **Settings:** - - :attr:`mopidy.settings.LOCAL_MUSIC_FOLDER` - - :attr:`mopidy.settings.LOCAL_PLAYLIST_FOLDER` - - :attr:`mopidy.settings.LOCAL_TAG_CACHE` + - :attr:`mopidy.settings.LOCAL_MUSIC_PATH` + - :attr:`mopidy.settings.LOCAL_PLAYLIST_PATH` + - :attr:`mopidy.settings.LOCAL_TAG_CACHE_FILE` """ def __init__(self, *args, **kwargs): @@ -66,7 +66,7 @@ class LocalPlaybackController(BasePlaybackController): class LocalStoredPlaylistsController(BaseStoredPlaylistsController): def __init__(self, *args): super(LocalStoredPlaylistsController, self).__init__(*args) - self._folder = os.path.expanduser(settings.LOCAL_PLAYLIST_FOLDER) + self._folder = os.path.expanduser(settings.LOCAL_PLAYLIST_PATH) self.refresh() def lookup(self, uri): @@ -143,8 +143,8 @@ class LocalLibraryController(BaseLibraryController): self.refresh() def refresh(self, uri=None): - tag_cache = os.path.expanduser(settings.LOCAL_TAG_CACHE) - music_folder = os.path.expanduser(settings.LOCAL_MUSIC_FOLDER) + tag_cache = os.path.expanduser(settings.LOCAL_TAG_CACHE_FILE) + music_folder = os.path.expanduser(settings.LOCAL_MUSIC_PATH) tracks = parse_mpd_tag_cache(tag_cache, music_folder) diff --git a/mopidy/frontends/mpd/translator.py b/mopidy/frontends/mpd/translator.py index 2b1adf50..c7f5605a 100644 --- a/mopidy/frontends/mpd/translator.py +++ b/mopidy/frontends/mpd/translator.py @@ -129,7 +129,7 @@ def tracks_to_tag_cache_format(tracks): def _add_to_tag_cache(result, folders, files): for path, entry in folders.items(): name = os.path.split(path)[1] - music_folder = os.path.expanduser(settings.LOCAL_MUSIC_FOLDER) + music_folder = os.path.expanduser(settings.LOCAL_MUSIC_PATH) mtime = get_mtime(os.path.join(music_folder, path)) result.append(('directory', path)) result.append(('mtime', mtime)) @@ -150,7 +150,7 @@ def tracks_to_directory_tree(tracks): path = u'' current = directories - local_folder = os.path.expanduser(settings.LOCAL_MUSIC_FOLDER) + local_folder = os.path.expanduser(settings.LOCAL_MUSIC_PATH) track_path = uri_to_path(track.uri) track_path = re.sub('^' + re.escape(local_folder), '', track_path) track_dir = os.path.dirname(track_path) diff --git a/mopidy/settings.py b/mopidy/settings.py index c9d7b9fc..4f60ee99 100644 --- a/mopidy/settings.py +++ b/mopidy/settings.py @@ -77,8 +77,8 @@ LASTFM_PASSWORD = u'' #: #: Default:: #: -#: LOCAL_MUSIC_FOLDER = u'~/music' -LOCAL_MUSIC_FOLDER = u'~/music' +#: LOCAL_MUSIC_PATH = u'~/music' +LOCAL_MUSIC_PATH = u'~/music' #: Path to playlist folder with m3u files for local music. #: @@ -86,8 +86,8 @@ LOCAL_MUSIC_FOLDER = u'~/music' #: #: Default:: #: -#: LOCAL_PLAYLIST_FOLDER = u'~/.mopidy/playlists' -LOCAL_PLAYLIST_FOLDER = u'~/.mopidy/playlists' +#: LOCAL_PLAYLIST_PATH = u'~/.mopidy/playlists' +LOCAL_PLAYLIST_PATH = u'~/.mopidy/playlists' #: Path to tag cache for local music. #: @@ -95,8 +95,8 @@ LOCAL_PLAYLIST_FOLDER = u'~/.mopidy/playlists' #: #: Default:: #: -#: LOCAL_TAG_CACHE = u'~/.mopidy/tag_cache' -LOCAL_TAG_CACHE = u'~/.mopidy/tag_cache' +#: LOCAL_TAG_CACHE_FILE = u'~/.mopidy/tag_cache' +LOCAL_TAG_CACHE_FILE = u'~/.mopidy/tag_cache' #: Sound mixer to use. See :mod:`mopidy.mixers` for all available mixers. #: @@ -172,7 +172,7 @@ MPD_SERVER_PORT = 6600 #: Path to the libspotify cache. #: #: Used by :mod:`mopidy.backends.libspotify`. -SPOTIFY_LIB_CACHE = u'~/.mopidy/libspotify_cache' +SPOTIFY_CACHE_PATH = u'~/.mopidy/libspotify_cache' #: Your Spotify Premium username. #: diff --git a/mopidy/utils/settings.py b/mopidy/utils/settings.py index 3145d278..2ec0f716 100644 --- a/mopidy/utils/settings.py +++ b/mopidy/utils/settings.py @@ -97,10 +97,14 @@ def validate_settings(defaults, settings): 'DUMP_LOG_FILENAME': 'DEBUG_LOG_FILENAME', 'DUMP_LOG_FORMAT': 'DEBUG_LOG_FORMAT', 'FRONTEND': 'FRONTENDS', + 'LOCAL_MUSIC_FOLDER': 'LOCAL_MUSIC_PATH', + 'LOCAL_PLAYLIST_FOLDER': 'LOCAL_PLAYLIST_PATH', + 'LOCAL_TAG_CACHE': 'LOCAL_TAG_CACHE_FILE', 'SERVER': None, 'SERVER_HOSTNAME': 'MPD_SERVER_HOSTNAME', 'SERVER_PORT': 'MPD_SERVER_PORT', 'SPOTIFY_LIB_APPKEY': None, + 'SPOTIFY_LIB_CACHE': 'SPOTIFY_CACHE_PATH', } for setting, value in settings.iteritems(): diff --git a/tests/backends/base/stored_playlists.py b/tests/backends/base/stored_playlists.py index ef5806ef..5bcd322c 100644 --- a/tests/backends/base/stored_playlists.py +++ b/tests/backends/base/stored_playlists.py @@ -10,9 +10,9 @@ from tests import SkipTest, data_folder class BaseStoredPlaylistsControllerTest(object): def setUp(self): - settings.LOCAL_PLAYLIST_FOLDER = tempfile.mkdtemp() - settings.LOCAL_TAG_CACHE = data_folder('library_tag_cache') - settings.LOCAL_MUSIC_FOLDER = data_folder('') + settings.LOCAL_PLAYLIST_PATH = tempfile.mkdtemp() + settings.LOCAL_TAG_CACHE_FILE = data_folder('library_tag_cache') + settings.LOCAL_MUSIC_PATH = data_folder('') self.backend = self.backend_class(mixer_class=DummyMixer) self.stored = self.backend.stored_playlists @@ -20,8 +20,8 @@ class BaseStoredPlaylistsControllerTest(object): def tearDown(self): self.backend.destroy() - if os.path.exists(settings.LOCAL_PLAYLIST_FOLDER): - shutil.rmtree(settings.LOCAL_PLAYLIST_FOLDER) + if os.path.exists(settings.LOCAL_PLAYLIST_PATH): + shutil.rmtree(settings.LOCAL_PLAYLIST_PATH) settings.runtime.clear() diff --git a/tests/backends/local/library_test.py b/tests/backends/local/library_test.py index c0605ef2..34465d09 100644 --- a/tests/backends/local/library_test.py +++ b/tests/backends/local/library_test.py @@ -17,8 +17,8 @@ class LocalLibraryControllerTest(BaseLibraryControllerTest, unittest.TestCase): backend_class = LocalBackend def setUp(self): - settings.LOCAL_TAG_CACHE = data_folder('library_tag_cache') - settings.LOCAL_MUSIC_FOLDER = data_folder('') + settings.LOCAL_TAG_CACHE_FILE = data_folder('library_tag_cache') + settings.LOCAL_MUSIC_PATH = data_folder('') super(LocalLibraryControllerTest, self).setUp() diff --git a/tests/backends/local/stored_playlists_test.py b/tests/backends/local/stored_playlists_test.py index bb03f997..4db9e1e2 100644 --- a/tests/backends/local/stored_playlists_test.py +++ b/tests/backends/local/stored_playlists_test.py @@ -25,13 +25,13 @@ class LocalStoredPlaylistsControllerTest(BaseStoredPlaylistsControllerTest, backend_class = LocalBackend def test_created_playlist_is_persisted(self): - path = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test.m3u') + path = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test.m3u') self.assert_(not os.path.exists(path)) self.stored.create('test') self.assert_(os.path.exists(path)) def test_saved_playlist_is_persisted(self): - path = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test2.m3u') + path = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test2.m3u') self.assert_(not os.path.exists(path)) self.stored.save(Playlist(name='test2')) self.assert_(os.path.exists(path)) @@ -39,13 +39,13 @@ class LocalStoredPlaylistsControllerTest(BaseStoredPlaylistsControllerTest, def test_deleted_playlist_get_removed(self): playlist = self.stored.create('test') self.stored.delete(playlist) - path = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test.m3u') + path = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test.m3u') self.assert_(not os.path.exists(path)) def test_renamed_playlist_gets_moved(self): playlist = self.stored.create('test') - file1 = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test.m3u') - file2 = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test2.m3u') + file1 = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test.m3u') + file2 = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test2.m3u') self.assert_(not os.path.exists(file2)) self.stored.rename(playlist, 'test2') self.assert_(not os.path.exists(file1)) @@ -55,7 +55,7 @@ class LocalStoredPlaylistsControllerTest(BaseStoredPlaylistsControllerTest, track = Track(uri=generate_song(1)) uri = track.uri[len('file://'):] playlist = Playlist(tracks=[track], name='test') - path = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test.m3u') + path = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test.m3u') self.stored.save(playlist) diff --git a/tests/frontends/mpd/serializer_test.py b/tests/frontends/mpd/serializer_test.py index 8e8a5d21..db0dabf4 100644 --- a/tests/frontends/mpd/serializer_test.py +++ b/tests/frontends/mpd/serializer_test.py @@ -11,7 +11,7 @@ from tests import data_folder, SkipTest class TrackMpdFormatTest(unittest.TestCase): def setUp(self): - settings.LOCAL_MUSIC_FOLDER = '/dir/subdir' + settings.LOCAL_MUSIC_PATH = '/dir/subdir' mtime.set_fake_time(1234567) def tearDown(self): @@ -104,7 +104,7 @@ class PlaylistMpdFormatTest(unittest.TestCase): class TracksToTagCacheFormatTest(unittest.TestCase): def setUp(self): - settings.LOCAL_MUSIC_FOLDER = '/dir/subdir' + settings.LOCAL_MUSIC_PATH = '/dir/subdir' mtime.set_fake_time(1234567) def tearDown(self): @@ -279,7 +279,7 @@ class TracksToTagCacheFormatTest(unittest.TestCase): class TracksToDirectoryTreeTest(unittest.TestCase): def setUp(self): - settings.LOCAL_MUSIC_FOLDER = '/root/' + settings.LOCAL_MUSIC_PATH = '/root/' def tearDown(self): settings.runtime.clear()