Commit 5c2d563e authored by Romain Bignon's avatar Romain Bignon

edit_backend: rewrite to not require module_name useless parameter

parent 8f032d2e
......@@ -128,7 +128,7 @@ class BackendsConfig(object):
config = self._read_config()
return name in config.sections()
def add_backend(self, backend_name, module_name, params, edit=False):
def add_backend(self, backend_name, module_name, params):
"""
Add a backend to config.
......@@ -140,7 +140,6 @@ class BackendsConfig(object):
if not backend_name:
raise ValueError(u'Please give a name to the configured backend.')
config = self._read_config()
if not edit:
try:
config.add_section(backend_name)
except DuplicateSectionError:
......@@ -151,9 +150,22 @@ class BackendsConfig(object):
self._write_config(config)
def edit_backend(self, backend_name, module_name, params):
"""Edit a backend from config."""
return self.add_backend(backend_name, module_name, params, True)
def edit_backend(self, backend_name, params):
"""
Edit a backend from config.
:param backend_name: name of the backend in config
:param params: params to change
:type params: :class:`dict`
"""
config = self._read_config()
if not config.has_section(backend_name):
raise KeyError(u'Configured backend "%s" not found' % backend_name)
for key, value in params.items():
config.set(backend_name, key, value)
self._write_config(config)
def get_backend(self, backend_name):
"""
......
......@@ -248,7 +248,6 @@ class BackendCfg(QDialog):
self.is_enabling += 1
backend_name = item.text(0)
module_name = item.text(1)
if item.checkState(0) == Qt.Checked:
self.to_load.add(backend_name)
enabled = 'true'
......@@ -260,7 +259,7 @@ class BackendCfg(QDialog):
pass
enabled = 'false'
self.weboob.backends_config.edit_backend(backend_name, module_name, {'_enabled': enabled})
self.weboob.backends_config.edit_backend(backend_name, {'_enabled': enabled})
@Slot(QTreeWidgetItem, int)
def backendClicked(self, item, col):
......
......@@ -199,7 +199,10 @@ class BackendConfig(ValuesDict):
if params is not None:
dump.update(params)
self.weboob.backends_config.add_backend(self.instname, self.modname, dump, edit)
if edit:
self.weboob.backends_config.edit_backend(self.instname, dump)
else:
self.weboob.backends_config.add_backend(self.instname, self.modname, dump)
class Module(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment