From: Frederic Massart Date: Fri, 12 Oct 2012 11:29:12 +0000 (+0800) Subject: API to remove a config setting X-Git-Tag: v0.1~12 X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=01707af23555d809a2f581d23989a667400d99f5;p=mdk.git API to remove a config setting --- 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: