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 `note` module provides :class:`NotePlugin` the associated
20 :class:`hooke.command.Command`\s for annotating several Hooke classes
21 (:mod:`hooke.playlist.Playlist`, :mod:`hooke.curve.Curve`, ...).
24 from ..command import Command, Argument, Failure
25 from ..plugin import Builtin
26 from ..plugin.curve import current_curve_callback
29 class NotePlugin (Builtin):
31 super(NotePlugin, self).__init__(name='note')
33 SetNoteCommand(self), GetNoteCommand(self)]
36 class SetNoteCommand (Command):
37 """Set the note on one of several Hooke objects.
39 def __init__(self, plugin):
40 super(SetNoteCommand, self).__init__(
44 name='target', type='object',
45 callback=current_curve_callback,
47 Target object for the note. Defaults to the current curve.
50 name='note', type='string', optional=False,
55 help=self.__doc__, plugin=plugin)
57 def _run(self, hooke, inqueue, outqueue, params):
58 params['target'].info['note'] = params['note']
61 class GetNoteCommand (Command):
62 """Retrieve the note from one of several Hooke objects.
64 def __init__(self, plugin):
65 super(GetNoteCommand, self).__init__(
69 name='target', type='object',
70 callback=current_curve_callback,
72 Target object for the note. Defaults to the current curve.
75 help=self.__doc__, plugin=plugin)
77 def _run(self, hooke, inqueue, outqueue, params):
78 outqueue.put(params['target'].info['note'])