core: Update tracklist docstrings

This commit is contained in:
Stein Magnus Jodal 2012-11-16 11:40:09 +01:00
parent fff70c46a6
commit cbc08f398c

View File

@ -33,7 +33,7 @@ class TracklistController(object):
@property
def tracks(self):
"""
List of :class:`mopidy.models.Track` in the current playlist.
List of :class:`mopidy.models.Track` in the tracklist.
Read-only.
"""
@ -42,15 +42,15 @@ class TracklistController(object):
@property
def length(self):
"""
Length of the current playlist.
Length of the tracklist.
"""
return len(self._tl_tracks)
@property
def version(self):
"""
The current playlist version. Integer which is increased every time the
current playlist is changed. Is not reset before Mopidy is restarted.
The tracklist version. Integer which is increased every time the
tracklist is changed. Is not reset before Mopidy is restarted.
"""
return self._version
@ -62,20 +62,19 @@ class TracklistController(object):
def add(self, track, at_position=None, increase_version=True):
"""
Add the track to the end of, or at the given position in the current
playlist.
Add the track to the end of, or at the given position in the tracklist.
:param track: track to add
:type track: :class:`mopidy.models.Track`
:param at_position: position in current playlist to add track
:param at_position: position in tracklist to add track
:type at_position: int or :class:`None`
:param increase_version: if the playlist version should be increased
:param increase_version: if the tracklist version should be increased
:type increase_version: :class:`True` or :class:`False`
:rtype: two-tuple of (TLID integer, :class:`mopidy.models.Track`) that
was added to the current playlist playlist
was added to the tracklist
"""
assert at_position <= len(self._tl_tracks), \
'at_position can not be greater than playlist length'
'at_position can not be greater than tracklist length'
tl_track = TlTrack(self.tlid, track)
if at_position is not None:
self._tl_tracks.insert(at_position, tl_track)
@ -88,7 +87,7 @@ class TracklistController(object):
def append(self, tracks):
"""
Append the given tracks to the current playlist.
Append the given tracks to the tracklist.
:param tracks: tracks to append
:type tracks: list of :class:`mopidy.models.Track`
@ -104,20 +103,19 @@ class TracklistController(object):
return tl_tracks
def clear(self):
"""Clear the current playlist."""
"""Clear the tracklist."""
self._tl_tracks = []
self.version += 1
def get(self, **criteria):
"""
Get track by given criterias from current playlist.
Get track by given criterias from tracklist.
Raises :exc:`LookupError` if a unique match is not found.
Examples::
get(tlid=7) # Returns track with TLID 7
# (current playlist ID)
get(tlid=7) # Returns track with TLID 7 (tracklist ID)
get(id=1) # Returns track with ID 1
get(uri='xyz') # Returns track with URI 'xyz'
get(id=1, uri='xyz') # Returns track with ID 1 and URI 'xyz'
@ -145,7 +143,7 @@ class TracklistController(object):
def index(self, tl_track):
"""
Get index of the given (TLID integer, :class:`mopidy.models.Track`)
two-tuple in the current playlist.
two-tuple in the tracklist.
Raises :exc:`ValueError` if not found.
@ -174,10 +172,10 @@ class TracklistController(object):
assert start < end, 'start must be smaller than end'
assert start >= 0, 'start must be at least zero'
assert end <= len(tl_tracks), \
'end can not be larger than playlist length'
'end can not be larger than tracklist length'
assert to_position >= 0, 'to_position must be at least zero'
assert to_position <= len(tl_tracks), \
'to_position can not be larger than playlist length'
'to_position can not be larger than tracklist length'
new_tl_tracks = tl_tracks[:start] + tl_tracks[end:]
for tl_track in tl_tracks[start:end]:
@ -188,7 +186,7 @@ class TracklistController(object):
def remove(self, **criteria):
"""
Remove the track from the current playlist.
Remove the track from the tracklist.
Uses :meth:`get()` to lookup the track to remove.
@ -202,7 +200,7 @@ class TracklistController(object):
def shuffle(self, start=None, end=None):
"""
Shuffles the entire playlist. If ``start`` and ``end`` is given only
Shuffles the entire tracklist. If ``start`` and ``end`` is given only
shuffles the slice ``[start:end]``.
:param start: position of first track to shuffle
@ -220,7 +218,7 @@ class TracklistController(object):
if end is not None:
assert end <= len(tl_tracks), 'end can not be larger than ' + \
'playlist length'
'tracklist length'
before = tl_tracks[:start or 0]
shuffled = tl_tracks[start:end]
@ -231,8 +229,8 @@ class TracklistController(object):
def slice(self, start, end):
"""
Returns a slice of the current playlist, limited by the given
start and end positions.
Returns a slice of the tracklist, limited by the given start and end
positions.
:param start: position of first track to include in slice
:type start: int