core: Deprecate remaining methods that used kwargs

This commit is contained in:
Thomas Adamcik 2015-04-16 00:23:28 +02:00
parent e265f5d673
commit 2828432008
5 changed files with 24 additions and 19 deletions

View File

@ -10,8 +10,12 @@ v1.1.0 (UNRELEASED)
Core API
--------
- Calling :meth:`mopidy.core.library.LibraryController.search`` with ``kwargs``
as the query is no longer supported (PR: :issue:`1090`)
- Calling the following methods with ``kwargs`` is being deprecated.
(PR: :issue:`1090`)
- :meth:`mopidy.core.library.LibraryController.search``
- :meth:`mopidy.core.library.PlaylistsController.filter``
- :meth:`mopidy.core.library.TracklistController.filter``
- :meth:`mopidy.core.library.TracklistController.remove``
- Updated core controllers to handle backend exceptions in all calls that rely
on multiple backends. (Issue: :issue:`667`)

View File

@ -263,21 +263,17 @@ class LibraryController(object):
# Returns results matching 'a' in any backend
search({'any': ['a']})
search(any=['a'])
# Returns results matching artist 'xyz' in any backend
search({'artist': ['xyz']})
search(artist=['xyz'])
# Returns results matching 'a' and 'b' and artist 'xyz' in any
# backend
search({'any': ['a', 'b'], 'artist': ['xyz']})
search(any=['a', 'b'], artist=['xyz'])
# Returns results matching 'a' if within the given URI roots
# "file:///media/music" and "spotify:"
search({'any': ['a']}, uris=['file:///media/music', 'spotify:'])
search(any=['a'], uris=['file:///media/music', 'spotify:'])
:param query: one or more queries to search for
:type query: dict

View File

@ -156,15 +156,12 @@ class PlaylistsController(object):
# Returns track with name 'a'
filter({'name': 'a'})
filter(name='a')
# Returns track with URI 'xyz'
filter({'uri': 'xyz'})
filter(uri='xyz')
# Returns track with name 'a' and URI 'xyz'
filter({'name': 'a', 'uri': 'xyz'})
filter(name='a', uri='xyz')
:param criteria: one or more criteria to match by
:type criteria: dict
@ -179,8 +176,7 @@ class PlaylistsController(object):
validation.check_query(
criteria, validation.PLAYLIST_FIELDS, list_values=False)
# TODO: stop using self playlists
matches = self.playlists
matches = self.playlists # TODO: stop using self playlists
for (key, value) in criteria.iteritems():
matches = filter(lambda p: getattr(p, key) == value, matches)
return matches

View File

@ -398,34 +398,34 @@ class TracklistController(object):
# Returns tracks with TLIDs 1, 2, 3, or 4 (tracklist ID)
filter({'tlid': [1, 2, 3, 4]})
filter(tlid=[1, 2, 3, 4])
# Returns track with IDs 1, 5, or 7
filter({'id': [1, 5, 7]})
filter(id=[1, 5, 7])
# Returns track with URIs 'xyz' or 'abc'
filter({'uri': ['xyz', 'abc']})
filter(uri=['xyz', 'abc'])
# Returns tracks with ID 1 and URI 'xyz'
filter({'id': [1], 'uri': ['xyz']})
filter(id=[1], uri=['xyz'])
# Returns track with a matching ID (1, 3 or 6) and a matching URI
# ('xyz' or 'abc')
filter({'id': [1, 3, 6], 'uri': ['xyz', 'abc']})
filter(id=[1, 3, 6], uri=['xyz', 'abc'])
:param criteria: on or more criteria to match by
:type criteria: dict, of (string, list) pairs
:rtype: list of :class:`mopidy.models.TlTrack`
.. deprecated:: 1.1
Providing the criteria via ``kwargs`` is no longer supported.
"""
if kwargs:
deprecation.warn('core.tracklist.filter:kwargs_criteria')
criteria = criteria or kwargs
tlids = criteria.pop('tlid', [])
validation.check_query(criteria, validation.TRACKLIST_FIELDS)
validation.check_instances(tlids, int)
# TODO: deprecate kwargs
# TODO: id=[1, 2, 3] filtering can't possibly be working
matches = self._tl_tracks
@ -481,9 +481,14 @@ class TracklistController(object):
:param criteria: on or more criteria to match by
:type criteria: dict
:rtype: list of :class:`mopidy.models.TlTrack` that was removed
.. deprecated:: 1.1
Providing the criteria via ``kwargs`` is no longer supported.
"""
# TODO: deprecate kwargs
tl_tracks = self.filter(criteria, **kwargs)
if kwargs:
deprecation.warn('core.tracklist.remove:kwargs_criteria')
tl_tracks = self.filter(criteria or kwargs)
for tl_track in tl_tracks:
position = self._tl_tracks.index(tl_track)
del self._tl_tracks[position]

View File

@ -40,6 +40,10 @@ _MESSAGES = {
'tracklist.add() "tracks" argument is deprecated',
'core.tracklist.add:uri_arg':
'tracklist.add() "uri" argument is deprecated',
'core.tracklist.filter:kwargs_criteria':
'tracklist.filter() with "kwargs" as criteria is deprecated',
'core.tracklist.remove:kwargs_criteria':
'tracklist.remove() with "kwargs" as criteria is deprecated',
'models.immutable.copy':
'ImmutableObject.copy() is deprecated, use ImmutableObject.replace()',