diff options
| author | Chris McDonough <chrism@plope.com> | 2011-12-05 00:14:20 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-12-05 00:14:20 -0500 |
| commit | d694d7549654033af3fc3f5f8f30231f4b0eaab5 (patch) | |
| tree | e0a072fcba1c6af69e207fe7eec4c61263ec5bcf | |
| parent | 8fe02156794c2cac0cbc6961332f9d8bebc1cb90 (diff) | |
| parent | 1c37b5487d229d1896ec983de1377f3282825739 (diff) | |
| download | pyramid-d694d7549654033af3fc3f5f8f30231f4b0eaab5.tar.gz pyramid-d694d7549654033af3fc3f5f8f30231f4b0eaab5.tar.bz2 pyramid-d694d7549654033af3fc3f5f8f30231f4b0eaab5.zip | |
Merge branch 'master' of https://github.com/aconrad/pyramid into aconrad-master
| -rw-r--r-- | pyramid/settings.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/pyramid/settings.py b/pyramid/settings.py index 11587a8be..86304307e 100644 --- a/pyramid/settings.py +++ b/pyramid/settings.py @@ -26,6 +26,8 @@ deprecated( 'the ``settings`` attribute of the registry available from the request ' '(``request.registry.settings``)).') +truthy = frozenset(('t', 'true', 'y', 'yes', 'on', '1')) + def asbool(s): """ Return the boolean value ``True`` if the case-lowered value of string input ``s`` is any of ``t``, ``true``, ``y``, ``on``, or ``1``, otherwise @@ -34,10 +36,10 @@ def asbool(s): or ``False``, return it.""" if s is None: return False - if s in (True, False): + if isinstance(s, bool): return s s = str(s).strip() - return s.lower() in ('t', 'true', 'y', 'yes', 'on', '1') + return s.lower() in truthy def aslist_cronly(value): if isinstance(value, string_types): |
