('cut', True),
# ('fit', True),
# ('flatfilts-rolf', True),
-# ('flatfilts', True),
+ ('flatfilt', True),
# ('generalclamp', True),
# ('generaltccd', True),
# ('generalvclamp', True),
self.name = name
self.setting_section = '%s plugin' % self.name
self.config = {}
+ self._commands = []
def dependencies(self):
- """Return a list of :class:`Plugin`\s we require."""
+ """Return a list of names of :class:`Plugin`\s we require."""
return []
def default_settings(self):
"""
return []
+ def _setup_commands(self):
+ """Perform internal setup on stored commands.
+
+ Currently:
+
+ * Adds a `plugin` attribute to each command so they can access
+ the plugin configuration with `.plugin.config`.
+ """
+ for command in self._commands:
+ command.plugin = self
+
def commands(self):
"""Return a list of :class:`hooke.command.Command`\s provided.
"""
- return []
+ return list(self._commands)
class Builtin (Plugin):
"""A required collection of Hooke commands.
class ConfigPlugin (Builtin):
def __init__(self):
super(ConfigPlugin, self).__init__(name='config')
-
- def commands(self):
- return [GetCommand(), SetCommand(), PrintCommand()]
+ self._commands = [GetCommand(), SetCommand(), PrintCommand()]
+ self._setup_commands()
# Define common or complicated arguments
class CurvePlugin (Builtin):
def __init__(self):
super(CurvePlugin, self).__init__(name='curve')
-
- def commands(self):
- return [InfoCommand(), ExportCommand(),
- DifferenceCommand(), DerivativeCommand(),
- PowerSpectrumCommand()]
+ self._commands = [
+ InfoCommand(), ExportCommand(),
+ DifferenceCommand(), DerivativeCommand(),
+ PowerSpectrumCommand()]
+ self._setup_commands()
# Define common or complicated arguments
class CutPlugin (Plugin):
def __init__(self):
super(CutPlugin, self).__init__(name='cut')
-
- def commands(self):
- return [CutCommand()]
+ self._commands = [CutCommand()]
+ self._setup_commands()
# Define common or complicated arguments
class DebugPlugin (Builtin):
def __init__(self):
super(DebugPlugin, self).__init__(name='debug')
-
- def commands(self):
- return [VersionCommand(), DebugCommand()]
+ self._commands = [VersionCommand(), DebugCommand()]
+ self._setup_commands()
class VersionCommand (Command):
class MultifitPlugin (Plugin):
def __init__(self):
super(MultifitPlugin, self).__init__(name='multifit')
+ self._commands = [MultifitCommand()]
+ self._setup_commands()
- def commands(self):
- return [MultifitCommand()]
class MultifitCommand (Command):
"""Presents curves for interactive manual analysis.
class NotePlugin (Builtin):
def __init__(self):
super(NotePlugin, self).__init__(name='note')
-
- def commands(self):
- return [AddNoteCommand(), ClearNoteCommand(), GetNoteCommand()]
-
- def dependencies(self):
- return [
- 'playlist', # for current_playlist_callback
- ]
+ self._commands = [
+ AddNoteCommand(), ClearNoteCommand(), GetNoteCommand()]
+ self._setup_commands()
class AddNoteCommand (Command):
class PlaylistPlugin (Builtin):
def __init__(self):
super(PlaylistPlugin, self).__init__(name='playlist')
-
- def commands(self):
- return [NextCommand(), PreviousCommand(), JumpCommand(),
- IndexCommand(), CurveListCommand(),
- SaveCommand(), LoadCommand(),
- AddCommand(), AddGlobCommand(),
- RemoveCommand(), FilterCommand(), NoteFilterCommand()]
+ self._commands = [
+ NextCommand(), PreviousCommand(), JumpCommand(),
+ IndexCommand(), CurveListCommand(),
+ SaveCommand(), LoadCommand(),
+ AddCommand(), AddGlobCommand(),
+ RemoveCommand(), FilterCommand(), NoteFilterCommand()]
+ self._setup_commands()
# Define common or complicated arguments
class SystemPlugin (Builtin):
def __init__(self):
super(SystemPlugin, self).__init__(name='system')
-
- def commands(self):
- return [ListDirectoryCommand(), GetWorkingDirectoryCommand(),
- ChangeDirectoryCommand(), SystemCommand()]
+ self._commands = [
+ ListDirectoryCommand(), GetWorkingDirectoryCommand(),
+ ChangeDirectoryCommand(), SystemCommand()]
+ self._setup_commands()
class ListDirectoryCommand (Command):