diff options
| author | Chris McDonough <chrism@plope.com> | 2011-12-05 00:15:49 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-12-05 00:15:49 -0500 |
| commit | 046c04b43817caf84f650e17a4b56168c1df662b (patch) | |
| tree | e0a072fcba1c6af69e207fe7eec4c61263ec5bcf | |
| parent | 8fe02156794c2cac0cbc6961332f9d8bebc1cb90 (diff) | |
| parent | d694d7549654033af3fc3f5f8f30231f4b0eaab5 (diff) | |
| download | pyramid-046c04b43817caf84f650e17a4b56168c1df662b.tar.gz pyramid-046c04b43817caf84f650e17a4b56168c1df662b.tar.bz2 pyramid-046c04b43817caf84f650e17a4b56168c1df662b.zip | |
Merge branch '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): |
