Added a ConfigurableTypes class for various type converters.

This commit is contained in:
Jeremy Fincher 2003-11-07 20:16:14 +00:00
parent 69adce4a57
commit cbe13abbf8

View File

@ -231,6 +231,18 @@ class ConfigurableDictionary(object):
# XXX: Make persistent.
class ConfigurableTypes(object):
def bool(self, s):
s = s.lower()
if s in ('true', 'enable', 'on'):
return True
elif s in ('false', 'disable', 'off'):
return False
else:
s = 'Value must be one of on/off/true/false/enable/disable.'
raise ValueError, s
class Configurable(object):
"""A mixin class to provide a "config" command that can be consistent
across all plugins, in order to unify the configuration for each plugin.