diff options
Diffstat (limited to 'paste/deploy/converters.py')
-rw-r--r-- | paste/deploy/converters.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/paste/deploy/converters.py b/paste/deploy/converters.py index f37d267..c9d87de 100644 --- a/paste/deploy/converters.py +++ b/paste/deploy/converters.py @@ -3,12 +3,16 @@ from paste.deploy.compat import basestring +truthy = frozenset(['true', 'yes', 'on', 'y', 't', '1']) +falsy = frozenset(['false', 'no', 'off', 'n', 'f', '0']) + + def asbool(obj): if isinstance(obj, basestring): obj = obj.strip().lower() - if obj in ['true', 'yes', 'on', 'y', 't', '1']: + if obj in truthy: return True - elif obj in ['false', 'no', 'off', 'n', 'f', '0']: + elif obj in falsy: return False else: raise ValueError("String is not true/false: %r" % obj) |