X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=hooke%2Fplugin%2F__init__.py;h=4249730e52ab9a3ecb0e88e455c8057991ea9d54;hb=9eafddfcd6f8d2228af5fc3fee39f74867e7c159;hp=98862c684fb459cea872479b19fdd48fcdbc311b;hpb=5846fa85d1c090deddc9df50924f0ed5c28cdbda;p=hooke.git diff --git a/hooke/plugin/__init__.py b/hooke/plugin/__init__.py index 98862c6..4249730 100644 --- a/hooke/plugin/__init__.py +++ b/hooke/plugin/__init__.py @@ -1,3 +1,21 @@ +# Copyright (C) 2010 W. Trevor King +# +# This file is part of Hooke. +# +# Hooke is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation, either +# version 3 of the License, or (at your option) any later version. +# +# Hooke is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Hooke. If not, see +# . + """The `plugin` module provides optional submodules that add new Hooke commands. @@ -12,26 +30,25 @@ from ..util.pluggable import IsSubclass, construct_graph PLUGIN_MODULES = [ # ('autopeak', True), -# ('curvetools', True), + ('convfilt', True), ('cut', True), +# ('fclamp', True), # ('fit', True), # ('flatfilts-rolf', True), -# ('flatfilts', True), -# ('generalclamp', True), -# ('generaltccd', True), -# ('generalvclamp', True), + ('flatfilt', True), # ('jumpstat', True), # ('macro', True), # ('massanalysis', True), # ('multidistance', True), # ('multifit', True), # ('pcluster', True), -# ('peakspot', True), # ('procplots', True), # ('review', True), # ('showconvoluted', True), # ('superimpose', True), +# ('tccd', True), # ('tutorial', True), + ('vclamp', True), ] """List of plugin modules and whether they should be included by default. TODO: autodiscovery @@ -39,6 +56,7 @@ default. TODO: autodiscovery BUILTIN_MODULES = [ 'config', + 'curve', 'debug', 'note', 'playlist', @@ -64,9 +82,10 @@ class Plugin (object): 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): @@ -82,7 +101,7 @@ class Plugin (object): 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. @@ -92,6 +111,19 @@ class Builtin (Plugin): """ pass +# Plugin utility functions + +def argument_to_setting(section_name, argument): + """Convert an :class:`~hooke.command.Argument` to a + `~hooke.conf.Setting`. + + This is a lossy transition, because + :class:`~hooke.command.Argument`\s store more information than + `~hooke.conf.Setting`\s. + """ + return Setting(section_name, option=argument.name, value=argument.default, + help=argument._help) + # Construct plugin dependency graph and load plugin instances. PLUGIN_GRAPH = construct_graph(