Pārlūkot izejas kodu

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 gadus atpakaļ
vecāks
revīzija
c9e02f7e02
2 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  1. 1
    0
      kayleevc/plugins/pluginbase.py
  2. 1
    2
      kayleevc/plugins/shell.py

+ 1
- 0
kayleevc/plugins/pluginbase.py Parādīt failu

@@ -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 Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt