1
# -*- coding: utf-8 -*-
5
TOKEN_RE = re.compile("(\$\(.*?\))", re.UNICODE)
13
for className in PLUGINS:
14
instance = eval(className)()
15
self.plugins[instance.get_id()] = instance
16
self.actionMap[instance.get_action()] = instance.get_id()
18
def get_action_list(self):
20
Gets a list of strings, each describing the action of a plugin e.g. "Current Date/Time".
22
return self.actionMap.keys()
24
def get_token(self, action, parentWindow):
25
pluginId = self.actionMap[action]
26
return self.plugins[pluginId].get_token(parentWindow)
28
def process_expansion(self, expansion, buffer):
30
Tokenise the given expansion, and dispatch the tokens to the relevant plugins for replacement.
31
Then return the finalised expansion.
33
tokens = TOKEN_RE.split(expansion.string)
37
if TOKEN_RE.match(token):
39
pluginId = token.split(' ', 1)[0][2:].lower()
41
finalString.append(self.plugins[pluginId].get_string(token, buffer))
42
expansion.backspaces += self.plugins[pluginId].get_backspace_count()
44
raise PluginError(str(e))
46
finalString.append(token)
48
expansion.string = ''.join(finalString)
51
class PluginError(Exception):
b'\\ No newline at end of file'