Merge branch 'release/v0.19.x' into develop

This commit is contained in:
Stein Magnus Jodal 2014-08-29 21:28:58 +02:00
commit fc94d0789e
4 changed files with 18 additions and 17 deletions

View File

@ -42,9 +42,9 @@ Bug fix release.
and docs to match how the core use the backend's browse method. (Fixes:
:issue:`833`)
- Local library API: Add :attr:`mopidy.local.ROOT_DIRECTORY_URI` constant for
use by implementors of :method:`mopidy.local.Library.browse`. (Related to:
:issue:`833`)
- Local library API: Add :attr:`mopidy.local.Library.ROOT_DIRECTORY_URI`
constant for use by implementors of :method:`mopidy.local.Library.browse`.
(Related to: :issue:`833`)
v0.19.3 (2014-08-03)

View File

@ -46,15 +46,6 @@ class Extension(ext.Extension):
return LocalCommand()
ROOT_DIRECTORY_URI = 'local:directory'
"""
URI of the local backend's root directory.
This constant should be used by libraries implementing the
:meth:`Library.browse` method.
"""
class Library(object):
"""
Local library interface.
@ -67,6 +58,14 @@ class Library(object):
:param config: Config dictionary
"""
ROOT_DIRECTORY_URI = 'local:directory'
"""
URI of the local backend's root directory.
This constant should be used by libraries implementing the
:meth:`Library.browse` method.
"""
#: Name of the local library implementation, must be overriden.
name = None
@ -78,7 +77,7 @@ class Library(object):
Browse directories and tracks at the given URI.
The URI for the root directory is a constant available at
:attr:`ROOT_DIRECTORY_URI`.
:attr:`Library.ROOT_DIRECTORY_URI`.
:param string path: URI to browse.
:rtype: List of :class:`~mopidy.models.Ref` tracks and directories.

View File

@ -61,7 +61,8 @@ class _BrowseCache(object):
splitpath_re = re.compile(r'([^/]+)')
def __init__(self, uris):
self._cache = {local.ROOT_DIRECTORY_URI: collections.OrderedDict()}
self._cache = {
local.Library.ROOT_DIRECTORY_URI: collections.OrderedDict()}
for track_uri in uris:
path = translator.local_track_uri_to_path(track_uri, b'/')
@ -96,10 +97,11 @@ class _BrowseCache(object):
else:
# Loop completed, so final child needs to be added to root.
if child:
self._cache[local.ROOT_DIRECTORY_URI][child.uri] = child
self._cache[
local.Library.ROOT_DIRECTORY_URI][child.uri] = child
# If no parent was set we belong in the root.
if not parent_uri:
parent_uri = local.ROOT_DIRECTORY_URI
parent_uri = local.Library.ROOT_DIRECTORY_URI
self._cache[parent_uri][track_uri] = track_ref

View File

@ -11,7 +11,7 @@ class LocalLibraryProvider(backend.LibraryProvider):
"""Proxy library that delegates work to our active local library."""
root_directory = models.Ref.directory(
uri=local.ROOT_DIRECTORY_URI, name='Local media')
uri=local.Library.ROOT_DIRECTORY_URI, name='Local media')
def __init__(self, backend, library):
super(LocalLibraryProvider, self).__init__(backend)