"""
import ConfigParser as configparser
+import logging
from ..config import Setting
from ..util.pluggable import IsSubclass, construct_graph
('convfilt', True),
('cut', True),
# ('fclamp', True),
-# ('fit', True),
# ('flatfilts-rolf', True),
('flatfilt', True),
# ('jumpstat', True),
-# ('macro', True),
# ('massanalysis', True),
# ('multidistance', True),
# ('multifit', True),
# ('pcluster', True),
+ ('polymer_fit', True),
# ('procplots', True),
# ('review', True),
# ('showconvoluted', True),
# ('superimpose', True),
# ('tccd', True),
-# ('tutorial', True),
+ ('tutorial', True),
('vclamp', True),
]
"""List of plugin modules and whether they should be included by
"""
BUILTIN_MODULES = [
+ 'command_stack',
'config',
'curve',
'debug',
+ 'engine',
'license',
'note',
'playlist',
"""A pluggable collection of Hooke commands.
Fulfills the same role for Hooke that a software package does for
- an operating system.
+ an operating system: contains a chunk of related commands and
+ routines. Command configuration also happens on the `Plugin`
+ level, with per-plugin sections in the configuration file.
"""
def __init__(self, name):
self.name = name
"""
return list(self._commands)
+
class Builtin (Plugin):
"""A required collection of Hooke commands.
"""
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
+ This is useful if, for example, you want to define arguments with
+ configurable default values.
+
+ Conversion is 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,
+ type=argument.type, count=argument.count,
help=argument._help)
+
# Construct plugin dependency graph and load plugin instances.
PLUGIN_GRAPH = construct_graph(
return settings
def load_graph(graph, config, include_section):
+ enabled = {}
items = []
for node in graph:
item = node.data
include = config.getboolean(include_section, item.name)
except configparser.NoOptionError:
include = True # non-optional include (e.g. a Builtin)
+ enabled[item.name] = include
if include == True:
- try:
- item.config = dict(config.items(item.setting_section))
- except configparser.NoSectionError:
- pass
+ for dependency in node:
+ if enabled.get(dependency.data.name, None) != True:
+ log = logging.getLogger('hooke')
+ log.warn(
+ 'could not setup plugin %s. unsatisfied dependency on %s.'
+ % (item.name, dependency.data.name))
+ enabled[item.name] = False
+ continue
items.append(item)
return items