Fix timeformat in configparser
- allow both raw (new) and non-raw (old) style timeformat for backwards compatibility
This commit is contained in:
parent
df18f7b042
commit
0dde976dec
|
@ -1,15 +1,20 @@
|
||||||
from ConfigParser import SafeConfigParser, ConfigParser
|
import ConfigParser
|
||||||
|
|
||||||
class BMConfigParser(SafeConfigParser):
|
class BMConfigParser(ConfigParser.SafeConfigParser):
|
||||||
def set(self, section, option, value=None):
|
def set(self, section, option, value=None):
|
||||||
if self._optcre is self.OPTCRE or value:
|
if self._optcre is self.OPTCRE or value:
|
||||||
if not isinstance(value, basestring):
|
if not isinstance(value, basestring):
|
||||||
raise TypeError("option values must be strings")
|
raise TypeError("option values must be strings")
|
||||||
return ConfigParser.set(self, section, option, value)
|
return ConfigParser.ConfigParser.set(self, section, option, value)
|
||||||
|
|
||||||
def get(self, section, option, raw=False, vars=None):
|
def get(self, section, option, raw=False, vars=None):
|
||||||
return ConfigParser.get(self, section, option, True, vars)
|
if section == "bitmessagesettings" and option == "timeformat":
|
||||||
|
try:
|
||||||
|
return ConfigParser.ConfigParser.get(self, section, option, raw, vars)
|
||||||
|
except ConfigParser.InterpolationError:
|
||||||
|
return ConfigParser.ConfigParser.get(self, section, option, True, vars)
|
||||||
|
return ConfigParser.ConfigParser.get(self, section, option, True, vars)
|
||||||
|
|
||||||
def items(self, section, raw=False, vars=None):
|
def items(self, section, raw=False, vars=None):
|
||||||
return ConfigParser.items(self, section, True, vars)
|
return ConfigParser.ConfigParser.items(self, section, True, vars)
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user