setConfigAction() and writeConfig() should work in submodules

This commit is contained in:
Damien Elmes 2017-08-31 14:41:00 +10:00
parent 7b93d8423f
commit 2689c7cfe1

View File

@ -206,8 +206,17 @@ When loading '%(name)s':
else: else:
return "" return ""
def addonFromModule(self, module):
return module.split(".")[0]
def configAction(self, addon):
return self._configButtonActions.get(addon)
# Add-on Config API
######################################################################
def getConfig(self, module): def getConfig(self, module):
addon = module.split(".")[0] addon = self.addonFromModule(module)
# get default config # get default config
config = self.addonConfigDefaults(addon) config = self.addonConfigDefaults(addon)
if config is None: if config is None:
@ -218,13 +227,12 @@ When loading '%(name)s':
config.update(userConf) config.update(userConf)
return config return config
def configAction(self, addon): def setConfigAction(self, module, fn):
return self._configButtonActions.get(addon) addon = self.addonFromModule(module)
def setConfigAction(self, addon, fn):
self._configButtonActions[addon] = fn self._configButtonActions[addon] = fn
def writeConfig(self, addon, conf): def writeConfig(self, module, conf):
addon = self.addonFromModule(module)
meta = self.addonMeta(addon) meta = self.addonMeta(addon)
meta['config'] = conf meta['config'] = conf
self.writeAddonMeta(addon, meta) self.writeAddonMeta(addon, meta)