[weboob] [PATCH 1/1] add enable and disable command to weboob-config

Michael Scherer misc at zarb.org
Sun May 8 16:13:50 CEST 2011


Signed-off-by: Michael Scherer <misc at zarb.org>
---
 weboob/applications/weboobcfg/weboobcfg.py |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/weboob/applications/weboobcfg/weboobcfg.py b/weboob/applications/weboobcfg/weboobcfg.py
index 1869c9d..df139b2 100644
--- a/weboob/applications/weboobcfg/weboobcfg.py
+++ b/weboob/applications/weboobcfg/weboobcfg.py
@@ -144,6 +144,31 @@ class WeboobCfg(ReplApplication):
             print >>sys.stderr, 'Backend instance "%s" does not exist' % instance_name
             return 1
 
+
+    def _do_toggle(self, name, state):
+        try:
+            bname, items = self.weboob.backends_config.get_backend(name)
+        except KeyError:
+            print >>sys.stderr, 'Backend instance "%s" does not exist' % name
+            return 1
+        self.weboob.backends_config.edit_backend(name, bname, {'_enabled': state})
+
+    def do_enable(self, name):
+        """
+        enable NAME
+
+        Enable a disabled backend
+        """
+        self._do_toggle(name, 1)
+
+    def do_disable(self, name):
+        """
+        disable NAME
+
+        Disable a backend
+        """
+        self._do_toggle(name, 0)
+
     def do_edit(self, line):
         """
         edit NAME
-- 
1.7.4.4




More information about the weboob mailing list