Browse Source

Get plugin options in PluginBase

To reduce the boilerplate code needed for each plugin, the PluginBase
class now pulls out the plugin's options from the configuration object.
They get stored under the reasonably obvious name of ``options``.
Clara Hobbs 8 years ago
parent
commit
c9e02f7e02
2 changed files with 2 additions and 2 deletions
  1. 1
    0
      kayleevc/plugins/pluginbase.py
  2. 1
    2
      kayleevc/plugins/shell.py

+ 1
- 0
kayleevc/plugins/pluginbase.py View File

29
         super().__init__()
29
         super().__init__()
30
         self.config = config
30
         self.config = config
31
         self.name = name
31
         self.name = name
32
+        self.options = config.options.plugins[name]
32
         self.corpus_strings = set()
33
         self.corpus_strings = set()
33
 
34
 
34
     def recognizer_finished(self, recognizer, text):
35
     def recognizer_finished(self, recognizer, text):

+ 1
- 2
kayleevc/plugins/shell.py View File

13
 
13
 
14
     def __init__(self, config, name):
14
     def __init__(self, config, name):
15
         super().__init__(config, name)
15
         super().__init__(config, name)
16
-        self.options = vars(self.config.options)
17
         self.number_parser = NumberParser()
16
         self.number_parser = NumberParser()
18
-        self.commands = self.options['plugins'][name]
17
+        self.commands = self.options
19
 
18
 
20
         for voice_cmd in self.commands.keys():
19
         for voice_cmd in self.commands.keys():
21
             self.corpus_strings.add(voice_cmd.strip().replace('%d', ''))
20
             self.corpus_strings.add(voice_cmd.strip().replace('%d', ''))

Loading…
Cancel
Save