2 """The plugin module provides optional submodules that add new Hooke
5 All of the science happens in here.
10 from ..config import Setting
11 from ..util.graph import Node, Graph
18 ('flatfilts-rolf', True),
20 ('generalclamp', True),
21 ('generaltccd', True),
22 ('generalvclamp', True),
25 ('massanalysis', True),
26 ('multidistance', True),
31 ('showconvoluted', True),
32 ('superimpose', True),
36 """List of plugin modules and whether they should be included by
41 """The pluggable collection of Hooke commands.
43 Fulfills the same role for Hooke that a software package does for
48 def dependencies(self):
49 """Return a list of Plugins we require."""
52 def default_settings(self):
53 """Return a list of hooke.config.Settings() for any
54 configurable module settings."""
58 """Return a list of Commands provided."""
62 """(name,instance) :class:`dict` of all possible :class:`Plugin`\s.
66 for plugin_modname,value in PLUGIN_MODULES:
67 this_mod = __import__(__name__, fromlist=[plugin_modname])
68 plugin_mod = getattr(this_mod, plugin_modname)
69 for objname in dir(plugin_mod):
70 obj = getattr(plugin_mod, objname)
71 if type(obj) == Plugin:
72 obj.module_name = plugin_modname
75 PLUGIN_GRAPH = Graph([Node(
76 [PLUGINS[name] for name in p.dependencies()]
78 PLUGIN_GRAPH.topological_sort()
81 def default_settings(self):
83 'plugins', help='Enable/disable default plugins.')]
84 for pnode in PLUGIN_GRAPH:
85 settings.append(Setting(p.name, str(PLUGIN_MODULES[p.module_name][1])))
86 for pnode in PLUGIN_GRAPH:
88 settings.extend(plugin.default_settings())
91 class Command (object):