core: Rename list_distinct to get_distinct
This commit is contained in:
parent
5fd2afa7ca
commit
8cc9c9bbc0
@ -36,7 +36,7 @@ v0.20.0 (UNRELEASED)
|
|||||||
- When seeking in paused state, do not change to playing state. (Fixed
|
- When seeking in paused state, do not change to playing state. (Fixed
|
||||||
:issue:`939`)
|
:issue:`939`)
|
||||||
|
|
||||||
- Add :meth:`mopidy.core.LibraryController.list_distinct` for getting unique
|
- Add :meth:`mopidy.core.LibraryController.get_distinct` for getting unique
|
||||||
values for a given field. (Fixes: :issue:`913`)
|
values for a given field. (Fixes: :issue:`913`)
|
||||||
|
|
||||||
**Commands**
|
**Commands**
|
||||||
@ -102,7 +102,7 @@ v0.20.0 (UNRELEASED)
|
|||||||
:confval:`mpd/command_blacklist`.
|
:confval:`mpd/command_blacklist`.
|
||||||
|
|
||||||
- Switch the ``list`` command over to using
|
- Switch the ``list`` command over to using
|
||||||
:meth:`mopidy.core.LibraryController.list_distinct`. (Fixes: :issue:`913`)
|
:meth:`mopidy.core.LibraryController.get_distinct`. (Fixes: :issue:`913`)
|
||||||
|
|
||||||
**HTTP frontend**
|
**HTTP frontend**
|
||||||
|
|
||||||
|
|||||||
@ -92,9 +92,9 @@ class LibraryProvider(object):
|
|||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def list_distinct(self, field, query=None):
|
def get_distinct(self, field, query=None):
|
||||||
"""
|
"""
|
||||||
See :meth:`mopidy.core.LibraryController.list_distinct`.
|
See :meth:`mopidy.core.LibraryController.get_distinct`.
|
||||||
|
|
||||||
*MAY be implemented by subclass.*
|
*MAY be implemented by subclass.*
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,7 @@ class LibraryController(object):
|
|||||||
return []
|
return []
|
||||||
return backend.library.browse(uri).get()
|
return backend.library.browse(uri).get()
|
||||||
|
|
||||||
def list_distinct(self, field, query=None):
|
def get_distinct(self, field, query=None):
|
||||||
"""
|
"""
|
||||||
List distinct values for a given field from the library.
|
List distinct values for a given field from the library.
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class LibraryController(object):
|
|||||||
:method:`search` for details about the query format.
|
:method:`search` for details about the query format.
|
||||||
:rtype: set of values corresponding to the requested field type.
|
:rtype: set of values corresponding to the requested field type.
|
||||||
"""
|
"""
|
||||||
futures = [b.library.list_distinct(field, query)
|
futures = [b.library.get_distinct(field, query)
|
||||||
for b in self.backends.with_library.values()]
|
for b in self.backends.with_library.values()]
|
||||||
result = set()
|
result = set()
|
||||||
for r in pykka.get_all(futures):
|
for r in pykka.get_all(futures):
|
||||||
|
|||||||
@ -89,7 +89,7 @@ class Library(object):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def list_distinct(self, field, query=None):
|
def get_distinct(self, field, query=None):
|
||||||
"""
|
"""
|
||||||
List distinct values for a given field from the library.
|
List distinct values for a given field from the library.
|
||||||
|
|
||||||
|
|||||||
@ -155,7 +155,7 @@ class JsonLibrary(local.Library):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def list_distinct(self, field, query=None):
|
def get_distinct(self, field, query=None):
|
||||||
if field == 'artist':
|
if field == 'artist':
|
||||||
def distinct(track):
|
def distinct(track):
|
||||||
return {a.name for a in track.artists}
|
return {a.name for a in track.artists}
|
||||||
|
|||||||
@ -23,10 +23,10 @@ class LocalLibraryProvider(backend.LibraryProvider):
|
|||||||
return []
|
return []
|
||||||
return self._library.browse(uri)
|
return self._library.browse(uri)
|
||||||
|
|
||||||
def list_distinct(self, field, query=None):
|
def get_distinct(self, field, query=None):
|
||||||
if not self._library:
|
if not self._library:
|
||||||
return set()
|
return set()
|
||||||
return self._library.list_distinct(field, query)
|
return self._library.get_distinct(field, query)
|
||||||
|
|
||||||
def refresh(self, uri=None):
|
def refresh(self, uri=None):
|
||||||
if not self._library:
|
if not self._library:
|
||||||
|
|||||||
@ -277,7 +277,7 @@ def list_(context, *args):
|
|||||||
return
|
return
|
||||||
|
|
||||||
name = _LIST_NAME_MAPPING[field]
|
name = _LIST_NAME_MAPPING[field]
|
||||||
result = context.core.library.list_distinct(field, query)
|
result = context.core.library.get_distinct(field, query)
|
||||||
return [(name, value) for value in result.get()]
|
return [(name, value) for value in result.get()]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ class DummyLibraryProvider(backend.LibraryProvider):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(DummyLibraryProvider, self).__init__(*args, **kwargs)
|
super(DummyLibraryProvider, self).__init__(*args, **kwargs)
|
||||||
self.dummy_library = []
|
self.dummy_library = []
|
||||||
self.dummy_list_distinct_result = {}
|
self.dummy_get_distinct_result = {}
|
||||||
self.dummy_browse_result = {}
|
self.dummy_browse_result = {}
|
||||||
self.dummy_find_exact_result = SearchResult()
|
self.dummy_find_exact_result = SearchResult()
|
||||||
self.dummy_search_result = SearchResult()
|
self.dummy_search_result = SearchResult()
|
||||||
@ -41,8 +41,8 @@ class DummyLibraryProvider(backend.LibraryProvider):
|
|||||||
def browse(self, path):
|
def browse(self, path):
|
||||||
return self.dummy_browse_result.get(path, [])
|
return self.dummy_browse_result.get(path, [])
|
||||||
|
|
||||||
def list_distinct(self, field, query=None):
|
def get_distinct(self, field, query=None):
|
||||||
return self.dummy_list_distinct_result.get(field, set())
|
return self.dummy_get_distinct_result.get(field, set())
|
||||||
|
|
||||||
def find_exact(self, **query):
|
def find_exact(self, **query):
|
||||||
return self.dummy_find_exact_result
|
return self.dummy_find_exact_result
|
||||||
|
|||||||
@ -613,7 +613,7 @@ class MusicDatabaseFindTest(protocol.BaseTestCase):
|
|||||||
|
|
||||||
class MusicDatabaseListTest(protocol.BaseTestCase):
|
class MusicDatabaseListTest(protocol.BaseTestCase):
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
self.backend.library.dummy_list_distinct_result = {
|
self.backend.library.dummy_get_distinct_result = {
|
||||||
'artist': set(['A Artist'])}
|
'artist': set(['A Artist'])}
|
||||||
self.send_request('list "artist" "artist" "foo"')
|
self.send_request('list "artist" "artist" "foo"')
|
||||||
|
|
||||||
@ -888,7 +888,7 @@ class MusicDatabaseListTest(protocol.BaseTestCase):
|
|||||||
self.assertInResponse('OK')
|
self.assertInResponse('OK')
|
||||||
|
|
||||||
def test_list_album_with_artist_name(self):
|
def test_list_album_with_artist_name(self):
|
||||||
self.backend.library.dummy_list_distinct_result = {
|
self.backend.library.dummy_get_distinct_result = {
|
||||||
'album': set(['foo'])}
|
'album': set(['foo'])}
|
||||||
|
|
||||||
self.send_request('list "album" "anartist"')
|
self.send_request('list "album" "anartist"')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user