This little patch allows Pythons ConfigParser.getboolean() to interpret TRUE, FALSE, YES, NO, ON and OFF instead just '0' and '1'. --drt@un.bewaff.net - http://c0re.jp/ --- ConfigParser.py Wed Oct 3 16:31:43 2001 +++ ConfigParser.py Wed Oct 3 16:33:18 2001 @@ -69,8 +69,9 @@ like get(), but convert value to a float getboolean(section, options) - like get(), but convert value to a boolean (currently defined as 0 or - 1, only) + like get(), but convert value to a boolean (currently case insensitive + defined as 0, FALSE, NO or OFF for 0 or 1, TRUE, YES, ON for 1). + Returns an int. remove_section(section) remove the given file section and all its options @@ -314,11 +315,12 @@ return self.__get(section, string.atof, option) def getboolean(self, section, option): - v = self.get(section, option) - val = int(v) - if val not in (0, 1): + states = {'1': 1, 'YES': 1, 'TRUE': 1, 'ON': 1, + '0': 0, 'NO': 0, 'FALSE': 0, 'OFF': 0} + v = self.get(section, option) + if not states.has_key(v.upper()): raise ValueError, 'Not a boolean: %s' % v - return val + return states[v.upper()] def optionxform(self, optionstr): return optionstr.lower()