From 01707af23555d809a2f581d23989a667400d99f5 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Fri, 12 Oct 2012 19:29:12 +0800 Subject: [PATCH] API to remove a config setting --- lib/config.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/config.py b/lib/config.py index 7974d3e..c4f901f 100644 --- a/lib/config.py +++ b/lib/config.py @@ -73,6 +73,26 @@ class Conf(object): except: raise Exception('Could not load config file %s' % fn) + def remove(self, name): + """Remove a setting""" + name = unicode(name).split('.') + count = len(name) + data = self.data + for i in range(count): + n = name[i] + if i == count -1: + try: + del data[n] + except: + pass + break + else: + try: + data = data[n] + except: + break + self.save() + def save(self): """Save the settings to the config file""" try: -- 2.11.0