Return use of BMConfigParser._temp dict,
also empty _temp in BMConfigParser._reset().
This commit is contained in:
parent
08099d4409
commit
161a0b2059
|
@ -36,6 +36,15 @@ class BMConfigParser(SafeConfigParser):
|
||||||
raise ValueError("Invalid value %s" % value)
|
raise ValueError("Invalid value %s" % value)
|
||||||
return SafeConfigParser.set(self, section, option, value)
|
return SafeConfigParser.set(self, section, option, value)
|
||||||
|
|
||||||
|
def get(self, section, option, **kwargs):
|
||||||
|
"""Try returning temporary value before using parent get()"""
|
||||||
|
try:
|
||||||
|
return self._temp[section][option]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
return SafeConfigParser.get(
|
||||||
|
self, section, option, **kwargs)
|
||||||
|
|
||||||
def setTemp(self, section, option, value=None):
|
def setTemp(self, section, option, value=None):
|
||||||
"""Temporary set option to value, not saving."""
|
"""Temporary set option to value, not saving."""
|
||||||
try:
|
try:
|
||||||
|
@ -91,8 +100,11 @@ class BMConfigParser(SafeConfigParser):
|
||||||
return SafeConfigParser.items(self, section, True, variables)
|
return SafeConfigParser.items(self, section, True, variables)
|
||||||
|
|
||||||
def _reset(self):
|
def _reset(self):
|
||||||
"""Reset current config. There doesn't appear to be a built in
|
"""
|
||||||
method for this"""
|
Reset current config.
|
||||||
|
There doesn't appear to be a built in method for this.
|
||||||
|
"""
|
||||||
|
self._temp = {}
|
||||||
sections = self.sections()
|
sections = self.sections()
|
||||||
for x in sections:
|
for x in sections:
|
||||||
self.remove_section(x)
|
self.remove_section(x)
|
||||||
|
|
Reference in New Issue
Block a user