core: Add pending depraction for *_track methods

This commit is contained in:
Thomas Adamcik 2015-04-18 16:52:02 +02:00 committed by
parent a88d3cf613
commit 2e705cf8d4
2 changed files with 17 additions and 2 deletions

View File

@ -251,6 +251,7 @@ class TracklistController(object):
:type tl_track: :class:`mopidy.models.TlTrack` or :class:`None`
:rtype: :class:`mopidy.models.TlTrack` or :class:`None`
"""
deprecation.warn('core.tracklist.eot_track', pending=True)
tl_track is None or validation.check_instance(tl_track, TlTrack)
if self.get_single() and self.get_repeat():
return tl_track
@ -293,6 +294,7 @@ class TracklistController(object):
:type tl_track: :class:`mopidy.models.TlTrack` or :class:`None`
:rtype: :class:`mopidy.models.TlTrack` or :class:`None`
"""
deprecation.warn('core.tracklist.next_track', pending=True)
tl_track is None or validation.check_instance(tl_track, TlTrack)
if not self._tl_tracks:
@ -350,6 +352,7 @@ class TracklistController(object):
:type tl_track: :class:`mopidy.models.TlTrack` or :class:`None`
:rtype: :class:`mopidy.models.TlTrack` or :class:`None`
"""
deprecation.warn('core.tracklist.previous_track', pending=True)
tl_track is None or validation.check_instance(tl_track, TlTrack)
if self.get_repeat() or self.get_consume() or self.get_random():

View File

@ -45,13 +45,25 @@ _MESSAGES = {
'core.tracklist.remove:kwargs_criteria':
'tracklist.remove() with "kwargs" as criteria is deprecated',
'core.tracklist.eot_track':
'tracklist.eot_track() is deprecated, use tracklist.get_eot_tlid()',
'core.tracklist.next_track':
'tracklist.next_track() is deprecated, use tracklist.get_next_tlid()',
'core.tracklist.previous_track':
'tracklist.previous_track() is deprecated, use '
'tracklist.get_previous_tlid()',
'models.immutable.copy':
'ImmutableObject.copy() is deprecated, use ImmutableObject.replace()',
}
def warn(msg_id):
warnings.warn(_MESSAGES.get(msg_id, msg_id), DeprecationWarning)
def warn(msg_id, pending=False):
if pending:
category = PendingDeprecationWarning
else:
category = DeprecationWarning
warnings.warn(_MESSAGES.get(msg_id, msg_id), category)
@contextlib.contextmanager