Change uri_handlers to uri_schemes on backends

This commit is contained in:
Stein Magnus Jodal 2011-06-20 19:28:58 +03:00
parent f29a0247fb
commit 622a99ad3b
9 changed files with 15 additions and 12 deletions

View File

@ -10,7 +10,9 @@ v0.6.0 (in development)
**Changes**
- None yet
- Replace :attr:`mopidy.backends.base.Backend.uri_handlers` with
:attr:`mopidy.backends.base.Backend.uri_schemes`, which just takes the part
up to the colon of an URI, and not any prefix.
v0.5.0 (2011-06-15)

View File

@ -25,5 +25,5 @@ class Backend(object):
#: :class:`mopidy.backends.base.StoredPlaylistsController`.
stored_playlists = None
#: List of URI prefixes this backend can handle.
uri_handlers = []
#: List of URI schemes this backend can handle.
uri_schemes = []

View File

@ -32,7 +32,7 @@ class DummyBackend(ThreadingActor, Backend):
self.stored_playlists = StoredPlaylistsController(backend=self,
provider=stored_playlists_provider)
self.uri_handlers = [u'dummy:']
self.uri_schemes = [u'dummy']
class DummyLibraryProvider(BaseLibraryProvider):

View File

@ -52,7 +52,7 @@ class LocalBackend(ThreadingActor, Backend):
self.stored_playlists = StoredPlaylistsController(backend=self,
provider=stored_playlists_provider)
self.uri_handlers = [u'file://']
self.uri_schemes = [u'file']
self.gstreamer = None

View File

@ -67,7 +67,7 @@ class SpotifyBackend(ThreadingActor, Backend):
self.stored_playlists = StoredPlaylistsController(backend=self,
provider=stored_playlists_provider)
self.uri_handlers = [u'spotify:', u'http://open.spotify.com/']
self.uri_schemes = [u'spotify']
self.gstreamer = None
self.spotify = None

View File

@ -19,8 +19,8 @@ def add(context, uri):
"""
if not uri:
return
for handler_prefix in context.backend.uri_handlers.get():
if uri.startswith(handler_prefix):
for uri_scheme in context.backend.uri_schemes.get():
if uri.startswith(uri_scheme):
track = context.backend.library.lookup(uri).get()
if track is not None:
context.backend.current_playlist.add(track)

View File

@ -95,4 +95,5 @@ def urlhandlers(context):
Gets a list of available URL handlers.
"""
return [(u'handler', uri) for uri in context.backend.uri_handlers.get()]
return [(u'handler', uri_scheme)
for uri_scheme in context.backend.uri_schemes.get()]

View File

@ -36,8 +36,8 @@ class LocalPlaybackControllerTest(PlaybackControllerTest, unittest.TestCase):
track = Track(uri=uri, length=4464)
self.backend.current_playlist.add(track)
def test_uri_handler(self):
self.assert_('file://' in self.backend.uri_handlers)
def test_uri_scheme(self):
self.assertIn('file', self.backend.uri_schemes)
def test_play_mp3(self):
self.add_track('blank.mp3')

View File

@ -76,4 +76,4 @@ class ReflectionHandlerTest(unittest.TestCase):
def test_urlhandlers(self):
result = self.dispatcher.handle_request(u'urlhandlers')
self.assert_(u'OK' in result)
self.assert_(u'handler: dummy:' in result)
self.assert_(u'handler: dummy' in result)