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