Add safeGetInt to BMConfigParser

This commit is contained in:
Peter Šurda 2017-01-14 23:18:06 +01:00
parent 02a7c59de8
commit bcc7692e14
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -27,6 +27,14 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
return False
return False
def safeGetInt(self, section, field):
if self.has_option(section, field):
try:
return self.getint(section, field)
except ValueError:
return 0
return 0
def safeGet(self, section, option, default = None):
if self.has_option(section, option):
return self.get(section, option)