projects
/
mdk.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ec649ea
)
API to remove a config setting
author
Frederic Massart
<fred@moodle.com>
Fri, 12 Oct 2012 11:29:12 +0000
(19:29 +0800)
committer
Frederic Massart
<fred@moodle.com>
Fri, 12 Oct 2012 11:29:12 +0000
(19:29 +0800)
lib/config.py
patch
|
blob
|
history
diff --git
a/lib/config.py
b/lib/config.py
index
7974d3e
..
c4f901f
100644
(file)
--- 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: