1 # Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
3 # This file is part of Hooke.
5 # Hooke is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 # Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with Hooke. If not, see
17 # <http://www.gnu.org/licenses/>.
19 """The ``playlists`` module provides :class:`PlaylistsPlugin` and
20 several associated :class:`hooke.command.Command`\s for handling
21 lists of :class:`hooke.playlist.Playlist` classes.
24 from ..command import Command, Argument, Failure
25 from ..plugin import Builtin
28 class PlaylistsPlugin (Builtin):
30 super(PlaylistsPlugin, self).__init__(name='playlists')
32 NextCommand(self), PreviousCommand(self), JumpCommand(self),
33 IndexCommand(self), PlaylistListCommand(self)]
38 class NextCommand (Command):
39 """Move `hooke.playlists` to the next playlist.
41 def __init__(self, plugin):
42 super(NextCommand, self).__init__(
44 help=self.__doc__, plugin=plugin)
46 def _run(self, hooke, inqueue, outqueue, params):
47 hooke.playlists.next()
49 class PreviousCommand (Command):
50 """Move `hooke.playlists` to the previous playlist.
52 def __init__(self, plugin):
53 super(PreviousCommand, self).__init__(
54 name='previous playlist',
55 help=self.__doc__, plugin=plugin)
57 def _run(self, hooke, inqueue, outqueue, params):
58 hooke.playlists.previous()
60 class JumpCommand (Command):
61 """Move `hooke.playlists` to a given playlist.
63 def __init__(self, plugin):
64 super(JumpCommand, self).__init__(
65 name='jump to playlist',
67 Argument(name='index', type='int', optional=False, help="""
68 Index of target curve.
71 help=self.__doc__, plugin=plugin)
73 def _run(self, hooke, inqueue, outqueue, params):
74 hooke.playlists.jump(params['index'])
76 class IndexCommand (Command):
77 """Print the index of the current playlist.
79 The first playlist has index 0.
81 def __init__(self, plugin):
82 super(IndexCommand, self).__init__(
83 name='playlist index',
84 help=self.__doc__, plugin=plugin)
86 def _run(self, hooke, inqueue, outqueue, params):
87 outqueue.put(hooke.playlists.index())
89 class PlaylistListCommand (Command):
90 """Get the playlists in `hooke.playlists`.
92 def __init__(self, plugin):
93 super(PlaylistListCommand, self).__init__(
95 help=self.__doc__, plugin=plugin)
97 def _run(self, hooke, inqueue, outqueue, params):
98 outqueue.put(list(hooke.playlists))