diff options
author | Tim Savage <tim.savage@poweredbypenguins.org> | 2016-03-29 18:34:55 +1100 |
---|---|---|
committer | Tim Savage <tim.savage@poweredbypenguins.org> | 2016-03-29 18:34:55 +1100 |
commit | 2f4dc33b59ba5f284ada0bcff1cf507bb1ed6d19 (patch) | |
tree | 30f1db10984019f5c0890f91c6a2770a0f074041 /redis | |
parent | 8e6f655d069fd3b31de63ae7f9ef967a7bf6de14 (diff) | |
download | redis-py-2f4dc33b59ba5f284ada0bcff1cf507bb1ed6d19.tar.gz |
PEP8 fixes
Diffstat (limited to 'redis')
-rwxr-xr-x | redis/connection.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/redis/connection.py b/redis/connection.py index fb90e93..004c7a6 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -735,15 +735,18 @@ class UnixDomainSocketConnection(Connection): (exception.args[0], self.path, exception.args[1]) +FALSE_STRINGS = ('0', 'F', 'FALSE', 'N', 'NO') + + def to_bool(value): if value is None or value == '': return None - if isinstance(value, basestring) and value.upper() in ('0', 'F', 'FALSE', 'N', 'NO'): + if isinstance(value, basestring) and value.upper() in FALSE_STRINGS: return False return bool(value) -URL_QUERY_PARAMETER_TYPES = { +URL_QUERY_ARGUMENT_PARSERS = { 'socket_timeout': float, 'socket_connect_timeout': float, 'socket_keepalive': to_bool, @@ -811,11 +814,14 @@ class ConnectionPool(object): for name, value in iteritems(parse_qs(qs)): if value and len(value) > 0: - if name in URL_QUERY_PARAMETER_TYPES: + parser = URL_QUERY_ARGUMENT_PARSERS.get(name) + if parser: try: - url_options[name] = URL_QUERY_PARAMETER_TYPES[name](value[0]) + url_options[name] = parser(value[0]) except (TypeError, ValueError): - warnings.warn(UserWarning("Invalid value for `%s` in connection URL." % name)) + warnings.warn(UserWarning( + "Invalid value for `%s` in connection URL." % name + )) else: url_options[name] = value[0] |