diff --git a/src/plugins.py b/src/plugins.py index b2a0b0f32..390a5f8df 100644 --- a/src/plugins.py +++ b/src/plugins.py @@ -256,8 +256,27 @@ class _ConfigurableTypes(object): else: s = 'Value must be one of on/off/true/false/enable/disable.' raise ConfigurableTypeError, s + + def str(self, s): + if s and s[0] not in '\'"' and s[-1] not in '\'"': + s = repr(s) + try: + v = utils.safeEval(s) + if type(v) is not str: + raise ValueError + except ValueError: + raise ConfigurableTypeError, 'Value must be a string.' + return v + + def int(self, s): + try: + return int(s) + except ValueError: + raise ConfigurableTypeError, 'Value must be an int.' ConfigurableTypes = _ConfigurableTypes() +foobar = 'baz' + 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.