12de8d23d575f1d7721b369ba03cc819764bcb75
[htsworkflow.git] / bcmagic / plugin.py
1 BCM_PLUGINS = {
2     #'cmd_move_sample': bcm_cmds.cmd_move_sample
3 }
4
5 _SEARCH_FUNCTIONS = {}
6
7
8 def bcm_plugin_processor(keyword, text, bcm_mode):
9     """
10     Fixme should be made generic plugable, but am hard coding values for proof
11     of concept.
12     """
13     d = {}
14
15     if bcm_mode not in BCM_PLUGINS:
16         d['mode'] = 'Error'
17         d['status'] = 'bcm_mode plugin called "%s" was not found' % (bcm_mode)
18         return d
19
20     return BCM_PLUGINS[bcm_mode](keyword, text, bcm_mode)
21
22
23 def register_search_plugin(label, search_function):
24     """
25     Registers a group label and search_function
26
27     search_function(search_string) --> (text_display, obj_url)
28     """
29
30     if label in _SEARCH_FUNCTIONS:
31         msg = "search function for label (%s) already registered." % (label)
32         raise ValueError(msg)
33
34     _SEARCH_FUNCTIONS[label] = search_function