Rename settings that have dirs or file to _PATH and _FILE

This commit is contained in:
Thomas Adamcik 2010-10-31 23:44:45 +01:00
parent 3661800563
commit c513d0f6e7
13 changed files with 43 additions and 39 deletions

0
bin/mopidy Normal file → Executable file
View File

View File

@ -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'

View File

@ -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!

View File

@ -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`

View File

@ -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()

View File

@ -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)

View File

@ -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)

View File

@ -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.
#:

View File

@ -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():

View File

@ -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()

View File

@ -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()

View File

@ -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)

View File

@ -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()