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 7 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,6 +29,7 @@ class PluginBase(GObject.Object):
29 29
         super().__init__()
30 30
         self.config = config
31 31
         self.name = name
32
+        self.options = config.options.plugins[name]
32 33
         self.corpus_strings = set()
33 34
 
34 35
     def recognizer_finished(self, recognizer, text):

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

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

Loading…
Cancel
Save