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