Bläddra i källkod

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 år sedan
förälder
incheckning
c9e02f7e02
2 ändrade filer med 2 tillägg och 2 borttagningar
  1. 1
    0
      kayleevc/plugins/pluginbase.py
  2. 1
    2
      kayleevc/plugins/shell.py

+ 1
- 0
kayleevc/plugins/pluginbase.py Visa fil

@@ -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 Visa fil

@@ -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', ''))

Laddar…
Avbryt
Spara