Skip to content

Commit 53ebf97

Browse files
committed
outline of ideas for new plugin approach
1 parent a2007b5 commit 53ebf97

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎paths_cli/commands/pathsampling.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ def pathsampling_main(output_storage, scheme, init_conds, n_steps):
4040
CLI = pathsampling
4141
SECTION = "Simulation"
4242
REQUIRES_OPS = (1, 0)
43+
44+
# pathsampling_plugin = paths_cli.CommandPlugin(command=pathsampling,
45+
# section="Simulation",
46+
# requires_ops=(1, 0))

‎paths_cli/plugin_management.py‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,45 @@
77
"OPSPlugin", ['name', 'location', 'func', 'section', 'plugin_type']
88
)
99

10+
11+
class Plugin(object):
12+
"""Generic OPS plugin object"""
13+
def __init__(self, requires_ops, requires_cli):
14+
self.requires_ops = requires_ops
15+
self.requires_cli = requires_cli
16+
17+
18+
class CommandPlugin(Plugin):
19+
"""Plugin for subcommands to the OPS CLI"""
20+
def __init__(self, command, section, requires_ops=(1, 0),
21+
requires_cli=(0, 1)):
22+
self.command = command
23+
self.section = section
24+
super().__init__(requires_ops, requires_cli)
25+
26+
@property
27+
def name(self):
28+
return self.command.name
29+
30+
31+
class ParserPlugin(Plugin):
32+
"""Plugin to add a new Parser (top-level stage in YAML parsing"""
33+
def __init__(self, parser, requires_ops=(1,0), requires_cli=(0,3)):
34+
self.parser = parser
35+
super().__init__(requires_ops, requires_cli)
36+
37+
38+
class InstanceBuilderPlugin(Plugin):
39+
"""
40+
Plugin to add a new object type (InstanceBuilder) to YAML parsing.
41+
"""
42+
def __init__(self, yaml_name, instance_builder, requires_ops=(1,0),
43+
requires_cli=(0,3)):
44+
self.yaml_name = yaml_name
45+
self.instance_builder = instance_builder
46+
super().__init__(requires_ops, requires_cli)
47+
48+
1049
class CLIPluginLoader(object):
1150
"""Abstract object for CLI plugins
1251

0 commit comments

Comments
 (0)