Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pep8 cleanups

  • Loading branch information...
commit 69057bb7285e482751019189e68f1b7d92fe598e 1 parent ace7ae9
@jeethu jeethu authored
View
6 examples/cyclone_demo.py
@@ -71,7 +71,7 @@ def subscribe(self, channel):
RedisMixin.psconn.subscribe(channel)
RedisMixin.channels[channel].append(self)
- log.msg("Client %s subscribed to %s" % \
+ log.msg("Client %s subscribed to %s" %
(self.request.remote_ip, channel))
def unsubscribe_all(self, ign):
@@ -82,7 +82,7 @@ def unsubscribe_all(self, ign):
except:
continue
- log.msg("Client %s unsubscribed from %s" % \
+ log.msg("Client %s unsubscribed from %s" %
(self.request.remote_ip, channel))
# Unsubscribe from channel if no peers are listening
@@ -170,7 +170,7 @@ def post(self, channel):
try:
n = yield self.dbconn.publish(channel, message.encode("utf-8"))
except Exception, e:
- log.msg("Redis failed to publish('%s', '%s'): %s" % \
+ log.msg("Redis failed to publish('%s', '%s'): %s" %
(channel, repr(message), str(e)))
raise cyclone.web.HTTPError(503)
View
4 tests/test_connection.py
@@ -34,14 +34,14 @@ def test_Connection(self):
@defer.inlineCallbacks
def test_ConnectionDB1(self):
db = yield redis.Connection(redis_host, redis_port, dbid=1,
- reconnect=False)
+ reconnect=False)
self.assertEqual(isinstance(db, redis.ConnectionHandler), True)
yield db.disconnect()
@defer.inlineCallbacks
def test_ConnectionPool(self):
db = yield redis.ConnectionPool(redis_host, redis_port, poolsize=2,
- reconnect=False)
+ reconnect=False)
self.assertEqual(isinstance(db, redis.ConnectionHandler), True)
yield db.disconnect()
View
7 tests/test_multibulk.py
@@ -29,7 +29,7 @@ class LargeMultiBulk(unittest.TestCase):
@defer.inlineCallbacks
def setUp(self):
self.db = yield redis.Connection(
- redis_host, redis_port, reconnect=False)
+ redis_host, redis_port, reconnect=False)
@defer.inlineCallbacks
def tearDown(self):
@@ -53,9 +53,8 @@ def test_large_multibulk_str(self):
@defer.inlineCallbacks
def test_bulk_numeric(self):
test_values = [
- '', '.hello', '+world', '123test',
- +1, 0.1, 0.01, -0.1, 0, -10,
- ]
+ '', '.hello', '+world', '123test',
+ +1, 0.1, 0.01, -0.1, 0, -10]
for v in test_values:
yield self.db.set(self._KEY, v)
r = yield self.db.get(self._KEY)
View
6 tests/test_sets.py
@@ -29,13 +29,13 @@ class SetsTests(unittest.TestCase):
Tests to ensure that set returning operations return sets
'''
_KEYS = ['txredisapi:testsets1', 'txredisapi:testsets2',
- 'txredisapi:testsets3', 'txredisapi:testsets4']
+ 'txredisapi:testsets3', 'txredisapi:testsets4']
N = 1024
@defer.inlineCallbacks
def setUp(self):
- self.db = yield redis.Connection(redis_host,
- redis_port, reconnect=False)
+ self.db = yield redis.Connection(redis_host, redis_port,
+ reconnect=False)
@defer.inlineCallbacks
def tearDown(self):
View
110 tests/test_sortedsets.py
@@ -28,10 +28,10 @@ class SortedSetsTests(unittest.TestCase):
Tests for sorted sets
'''
_KEYS = ['txredisapi:testssets1', 'txredisapi:testssets2',
- 'txredisapi:testssets3', 'txredisapi:testssets4']
+ 'txredisapi:testssets3', 'txredisapi:testssets4']
_NUMBERS = ["zero", "one", "two", "three", "four",
- "five", "six", "seven", "eight", "nine"]
+ "five", "six", "seven", "eight", "nine"]
@defer.inlineCallbacks
def test_zaddrem(self):
@@ -52,10 +52,10 @@ def test_zaddrem(self):
r = yield self.db.zrem(key, "two", "three")
# Test if calling zadd with odd number of arguments errors out
yield self.db.zadd(key, 1, "one", 2).addBoth(
- self._check_invaliddata_error, shouldError=True)
+ self._check_invaliddata_error, shouldError=True)
# Now try doing it the right way
yield self.db.zadd(key, 1, "one", 2, "two").addBoth(
- self._check_invaliddata_error)
+ self._check_invaliddata_error)
@defer.inlineCallbacks
def test_zcard_zcount(self):
@@ -156,22 +156,22 @@ def test_zrevrangebyscore(self):
def test_zinterstore(self):
agg_map = {
'min': (('min', min), {
- -1: [('three', -3)],
- 0: [(u'three', 0)],
- 1: [(u'three', 3)],
- 2: [(u'three', 3)],
+ -1: [('three', -3)],
+ 0: [(u'three', 0)],
+ 1: [(u'three', 3)],
+ 2: [(u'three', 3)],
}),
'max': (('max', max), {
- -1: [('three', 3)],
- 0: [('three', 3)],
- 1: [('three', 3)],
- 2: [('three', 6)],
+ -1: [('three', 3)],
+ 0: [('three', 3)],
+ 1: [('three', 3)],
+ 2: [('three', 6)],
}),
'sum': (('sum', sum), {
- -1: [('three', 0)],
- 0: [('three', 3)],
- 1: [('three', 6)],
- 2: [('three', 9)],
+ -1: [('three', 0)],
+ 0: [('three', 3)],
+ 1: [('three', 6)],
+ 2: [('three', 9)],
})
}
return self._test_zunion_inter_store(self.db.zinterstore, agg_map)
@@ -179,35 +179,35 @@ def test_zinterstore(self):
def test_zunionstore(self):
agg_map = {
'min': (('min', min), {
- -1: [('five', -5), ('four', -4), ('three', -3),
- ('one', 1), ('two', 2)],
- 0: [('five', 0), ('four', 0), ('three', 0),
- ('one', 1), ('two', 2)],
- 1: [('one', 1), ('two', 2), ('three', 3),
- ('four', 4), ('five', 5)],
- 2: [('one', 1), ('two', 2), ('three', 3),
- ('four', 8), ('five', 10)]
- }),
+ -1: [('five', -5), ('four', -4), ('three', -3),
+ ('one', 1), ('two', 2)],
+ 0: [('five', 0), ('four', 0), ('three', 0),
+ ('one', 1), ('two', 2)],
+ 1: [('one', 1), ('two', 2), ('three', 3),
+ ('four', 4), ('five', 5)],
+ 2: [('one', 1), ('two', 2), ('three', 3),
+ ('four', 8), ('five', 10)]
+ }),
'max': (('max', max), {
- -1: [('five', -5), ('four', -4), ('one', 1),
- ('two', 2), ('three', 3)],
- 0: [('five', 0), ('four', 0), ('one', 1),
- ('two', 2), ('three', 3)],
- 1: [('one', 1), ('two', 2), ('three', 3),
- ('four', 4), ('five', 5)],
- 2: [('one', 1), ('two', 2), ('three', 6),
- ('four', 8), ('five', 10)]
- }),
+ -1: [('five', -5), ('four', -4), ('one', 1),
+ ('two', 2), ('three', 3)],
+ 0: [('five', 0), ('four', 0), ('one', 1),
+ ('two', 2), ('three', 3)],
+ 1: [('one', 1), ('two', 2), ('three', 3),
+ ('four', 4), ('five', 5)],
+ 2: [('one', 1), ('two', 2), ('three', 6),
+ ('four', 8), ('five', 10)]
+ }),
'sum': (('sum', sum), {
- -1: [('five', -5), ('four', -4), ('three', 0),
- ('one', 1), ('two', 2)],
- 0: [('five', 0), ('four', 0), ('one', 1),
- ('two', 2), ('three', 3)],
- 1: [('one', 1), ('two', 2), ('four', 4),
- ('five', 5), ('three', 6)],
- 2: [('one', 1), ('two', 2), ('four', 8),
- ('three', 9), ('five', 10)]
- })
+ -1: [('five', -5), ('four', -4), ('three', 0),
+ ('one', 1), ('two', 2)],
+ 0: [('five', 0), ('four', 0), ('one', 1),
+ ('two', 2), ('three', 3)],
+ 1: [('one', 1), ('two', 2), ('four', 4),
+ ('five', 5), ('three', 6)],
+ 2: [('one', 1), ('two', 2), ('four', 8),
+ ('three', 9), ('five', 10)]
+ })
}
return self._test_zunion_inter_store(self.db.zunionstore, agg_map)
@@ -226,24 +226,22 @@ def _test_zunion_inter_store(self, cmd, agg_function_map):
keys = [key, key1]
else:
keys = {key: 1, key1: key1_weight}
- r = yield cmd(destKey, keys,
- aggregate=agg_fn)
+ r = yield cmd(destKey, keys, aggregate=agg_fn)
if cmd == self.db.zunionstore:
t(r, len(set(l + l1)))
else:
t(r, len(set(l) & set(l1)))
r = yield self.db.zrange(destKey, withscores=True)
- t(r,
- agg_function_map[agg_fn_name][1][key1_weight])
+ t(r, agg_function_map[agg_fn_name][1][key1_weight])
yield self.db.delete(destKey)
# Finally, test for invalid aggregate functions
yield self.db.delete(key, key1)
yield self._make_sorted_set(key, begin=1, end=4)
yield self._make_sorted_set(key1, begin=3, end=6)
yield cmd(destKey, [key, key1], aggregate='SIN').addBoth(
- self._check_invaliddata_error, shouldError=True)
+ self._check_invaliddata_error, shouldError=True)
yield cmd(destKey, [key, key1], aggregate=lambda a, b: a + b).addBoth(
- self._check_invaliddata_error, shouldError=True)
+ self._check_invaliddata_error, shouldError=True)
yield self.db.delete(destKey)
@defer.inlineCallbacks
@@ -272,9 +270,9 @@ def _test_zrangebyscore(self, reverse):
# Test for invalid offset and count
yield self._make_sorted_set(key, begin=1, end=4)
yield command(key, offset=1).addBoth(
- self._check_invaliddata_error, shouldError=True)
+ self._check_invaliddata_error, shouldError=True)
yield command(key, count=1).addBoth(
- self._check_invaliddata_error, shouldError=True)
+ self._check_invaliddata_error, shouldError=True)
@defer.inlineCallbacks
def _test_zrank(self, reverse):
@@ -336,17 +334,17 @@ def _make_sorted_set(self, key, begin=0, end=10):
for x in range(begin, end):
l.extend((x, self._to_words(x)))
return self.db.zadd(key, *l).addCallback(
- self._sorted_set_check, zip(l[1::2], l[::2]))
+ self._sorted_set_check, zip(l[1::2], l[::2]))
@defer.inlineCallbacks
def setUp(self):
- self.db = yield redis.Connection(redis_host,
- redis_port, reconnect=False)
+ self.db = yield redis.Connection(redis_host, redis_port,
+ reconnect=False)
def tearDown(self):
return defer.gatherResults(
- [self.db.delete(x) for x in self._KEYS]).addCallback(
- lambda ign: self.db.disconnect())
+ [self.db.delete(x) for x in self._KEYS]).addCallback(
+ lambda ign: self.db.disconnect())
def _check_invaliddata_error(self, response, shouldError=False):
if shouldError:
View
4 tests/test_watch.py
@@ -43,8 +43,8 @@ def _db_connected(self, connection):
def _getRedisConnection(self, host=redis_host, port=redis_port, db=0):
return redis.Connection(
- host, port, dbid=db, reconnect=False).addCallback(
- self._db_connected)
+ host, port, dbid=db, reconnect=False).addCallback(
+ self._db_connected)
def _check_watcherror(self, response, shouldError=False):
if shouldError:
View
53 txredisapi.py
@@ -174,7 +174,7 @@ def lineReceived(self, line):
reply = int(data)
except ValueError:
reply = InvalidResponse(
- "Cannot convert data '%s' to integer" % data)
+ "Cannot convert data '%s' to integer" % data)
if self.multi_bulk_length:
self.handleMultiBulkElement(reply)
@@ -185,7 +185,7 @@ def lineReceived(self, line):
self.bulk_length = long(data)
except ValueError:
self.replyReceived(InvalidResponse(
- "Cannot convert data '%s' to integer" % data))
+ "Cannot convert data '%s' to integer" % data))
return
if self.bulk_length == -1:
self.bulkDataReceived(None)
@@ -198,8 +198,8 @@ def lineReceived(self, line):
self.multi_bulk_length = long(data)
except (TypeError, ValueError):
self.replyReceived(InvalidResponse(
- "Cannot convert multi-response header '%s' to integer" % \
- data))
+ "Cannot convert multi-response header '%s' to integer" %
+ data))
self.multi_bulk_length = 0
return
if self.multi_bulk_length == -1:
@@ -253,7 +253,7 @@ def bulkDataReceived(self, data):
if data and data[0] in _NUM_FIRST_CHARS: # Most likely a number
try:
element = int(data) if data.find('.') == -1 else \
- float(data)
+ float(data)
except ValueError:
pass
if element is None:
@@ -693,7 +693,7 @@ def smove(self, srckey, dstkey, member):
Move the specified member from one Set to another atomically
"""
return self.execute_command(
- "SMOVE", srckey, dstkey, member).addCallback(bool)
+ "SMOVE", srckey, dstkey, member).addCallback(bool)
def scard(self, key):
"""
@@ -713,7 +713,7 @@ def sinter(self, keys, *args):
"""
keys = list_or_args("sinter", keys, args)
return self.execute_command("SINTER", *keys).addCallback(
- self._make_set)
+ self._make_set)
def sinterstore(self, dstkey, keys, *args):
"""
@@ -729,7 +729,7 @@ def sunion(self, keys, *args):
"""
keys = list_or_args("sunion", keys, args)
return self.execute_command("SUNION", *keys).addCallback(
- self._make_set)
+ self._make_set)
def sunionstore(self, dstkey, keys, *args):
"""
@@ -746,7 +746,7 @@ def sdiff(self, keys, *args):
"""
keys = list_or_args("sdiff", keys, args)
return self.execute_command("SDIFF", *keys).addCallback(
- self._make_set)
+ self._make_set)
def sdiffstore(self, dstkey, keys, *args):
"""
@@ -761,7 +761,7 @@ def smembers(self, key):
Return all the members of the Set value at key
"""
return self.execute_command("SMEMBERS", key).addCallback(
- self._make_set)
+ self._make_set)
def srandmember(self, key):
"""
@@ -855,9 +855,8 @@ def zrevrange(self, key, start=0, end=-1, withscores=False):
"""
return self._zrange(key, start, end, withscores, True)
- def _zrangebyscore(self, key, min, max, withscores, offset,
- count, reverse):
- if reverse:
+ def _zrangebyscore(self, key, min, max, withscores, offset, count, rev):
+ if rev:
cmd = "ZREVRANGEBYSCORE"
else:
cmd = "ZRANGEBYSCORE"
@@ -876,22 +875,22 @@ def _zrangebyscore(self, key, min, max, withscores, offset,
return r
def zrangebyscore(self, key, min='-inf', max='+inf', withscores=False,
- offset=None, count=None):
+ offset=None, count=None):
"""
Return all the elements with score >= min and score <= max
(a range query) from the sorted set
"""
return self._zrangebyscore(key, min, max, withscores, offset,
- count, False)
+ count, False)
def zrevrangebyscore(self, key, max='+inf', min='-inf', withscores=False,
- offset=None, count=None):
+ offset=None, count=None):
"""
ZRANGEBYSCORE in reverse order
"""
# ZREVRANGEBYSCORE takes max before min
return self._zrangebyscore(key, max, min, withscores, offset,
- count, True)
+ count, True)
def zcount(self, key, min='-inf', max='+inf'):
"""
@@ -1062,9 +1061,9 @@ def hgetall(self, key):
# Sorting
def sort(self, key, start=None, end=None, by=None, get=None,
- desc=None, alpha=False, store=None):
+ desc=None, alpha=False, store=None):
if (start is not None and end is not None) or \
- (end is not None and start is None):
+ (end is not None and start is None):
raise RedisError("``start`` and ``end`` must both be specified")
pieces = [key]
@@ -1099,7 +1098,7 @@ def multi(self, keys=None):
keys = [keys]
d = defer.Deferred()
self.execute_command("WATCH", *keys).addCallback(
- self._watch_added, d)
+ self._watch_added, d)
else:
d = self.execute_command("MULTI").addCallback(self._multi_started)
self.inTransaction = True
@@ -1109,7 +1108,7 @@ def _watch_added(self, response, d):
if response != 'OK':
d.errback(RedisError('Invalid WATCH response: %s' % response))
self.execute_command("MULTI").addCallback(
- self._multi_started).chainDeferred(d)
+ self._multi_started).chainDeferred(d)
def _multi_started(self, response):
if response != 'OK':
@@ -1128,7 +1127,7 @@ def commit(self):
if self.inTransaction is False:
raise RedisError("Not in transaction")
return self.execute_command("EXEC").addCallback(
- self._commit_check)
+ self._commit_check)
def discard(self):
if self.inTransaction is False:
@@ -1420,7 +1419,7 @@ def _wrap(self, method, *args, **kwargs):
assert isinstance(key, (str, unicode))
except:
raise ValueError(
- "Method '%s' requires a key as the first argument" % method)
+ "Method '%s' requires a key as the first argument" % method)
m = _findhash.match(key)
if m is not None and len(m.groups()) >= 1:
@@ -1469,7 +1468,7 @@ def __repr__(self):
except:
pass
else:
- nodes.append("%s:%s/%d" % \
+ nodes.append("%s:%s/%d" %
(cli.host, cli.port, conn._factory.size))
return "<Redis Sharded Connection: %s>" % ", ".join(nodes)
@@ -1483,7 +1482,7 @@ def __repr__(self):
except:
pass
else:
- nodes.append("%s/%d" % \
+ nodes.append("%s/%d" %
(cli.name, conn._factory.size))
return "<Redis Sharded Connection: %s>" % ", ".join(nodes)
@@ -1495,11 +1494,11 @@ class RedisFactory(protocol.ReconnectingClientFactory):
def __init__(self, dbid, poolsize, isLazy=False,
handler=ConnectionHandler):
if not isinstance(poolsize, int):
- raise ValueError("Redis poolsize must be an integer, not %s" % \
+ raise ValueError("Redis poolsize must be an integer, not %s" %
repr(poolsize))
if not isinstance(dbid, (int, types.NoneType)):
- raise ValueError("Redis dbid must be an integer, not %s" % \
+ raise ValueError("Redis dbid must be an integer, not %s" %
repr(dbid))
self.dbid = dbid
Please sign in to comment.
Something went wrong with that request. Please try again.