~gabriel1984sibiu/anki/anki

« back to all changes in this revision

Viewing changes to aqt/addons.py

  • Committer: Damien Elmes
  • Date: 2017-08-31 04:41:00 UTC
  • Revision ID: git-v1:2689c7cfe1d3efdc1333c886933870d8dca81ac5
setConfigAction() and writeConfig() should work in submodules

Show diffs side-by-side

added added

removed removed

Lines of Context:
206
206
        else:
207
207
            return ""
208
208
 
 
209
    def addonFromModule(self, module):
 
210
        return module.split(".")[0]
 
211
 
 
212
    def configAction(self, addon):
 
213
        return self._configButtonActions.get(addon)
 
214
 
 
215
    # Add-on Config API
 
216
    ######################################################################
 
217
 
209
218
    def getConfig(self, module):
210
 
        addon = module.split(".")[0]
 
219
        addon = self.addonFromModule(module)
211
220
        # get default config
212
221
        config = self.addonConfigDefaults(addon)
213
222
        if config is None:
218
227
        config.update(userConf)
219
228
        return config
220
229
 
221
 
    def configAction(self, addon):
222
 
        return self._configButtonActions.get(addon)
223
 
 
224
 
    def setConfigAction(self, addon, fn):
 
230
    def setConfigAction(self, module, fn):
 
231
        addon = self.addonFromModule(module)
225
232
        self._configButtonActions[addon] = fn
226
233
 
227
 
    def writeConfig(self, addon, conf):
 
234
    def writeConfig(self, module, conf):
 
235
        addon = self.addonFromModule(module)
228
236
        meta = self.addonMeta(addon)
229
237
        meta['config'] = conf
230
238
        self.writeAddonMeta(addon, meta)