From 2031e60d3c5fbb56b610b6912189518c76165248 Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Fri, 26 Jul 2013 13:03:46 +0900 Subject: Refactors boolean returns Return the boolean evaluation itself rather than a boolean after evaluation Change-Id: I6329d474c921e29eb3a690270de12d51cb863710 --- openstack/common/rpc/impl_kombu.py | 8 ++------ openstack/common/rpc/matchmaker.py | 12 +++--------- openstack/common/rpc/matchmaker_ring.py | 4 +--- 3 files changed, 6 insertions(+), 18 deletions(-) (limited to 'openstack/common') diff --git a/openstack/common/rpc/impl_kombu.py b/openstack/common/rpc/impl_kombu.py index 6b1ae93..61ab415 100644 --- a/openstack/common/rpc/impl_kombu.py +++ b/openstack/common/rpc/impl_kombu.py @@ -490,12 +490,8 @@ class Connection(object): # future with this? ssl_params['cert_reqs'] = ssl.CERT_REQUIRED - if not ssl_params: - # Just have the default behavior - return True - else: - # Return the extended behavior - return ssl_params + # Return the extended behavior or just have the default behavior + return ssl_params or True def _connect(self, params): """Connect to rabbit. Re-establish any queues that may have diff --git a/openstack/common/rpc/matchmaker.py b/openstack/common/rpc/matchmaker.py index e80ab37..a94f542 100644 --- a/openstack/common/rpc/matchmaker.py +++ b/openstack/common/rpc/matchmaker.py @@ -248,9 +248,7 @@ class DirectBinding(Binding): that it maps directly to a host, thus direct. """ def test(self, key): - if '.' in key: - return True - return False + return '.' in key class TopicBinding(Binding): @@ -262,17 +260,13 @@ class TopicBinding(Binding): matches that of a direct exchange. """ def test(self, key): - if '.' not in key: - return True - return False + return '.' not in key class FanoutBinding(Binding): """Match on fanout keys, where key starts with 'fanout.' string.""" def test(self, key): - if key.startswith('fanout~'): - return True - return False + return key.startswith('fanout~') class StubExchange(Exchange): diff --git a/openstack/common/rpc/matchmaker_ring.py b/openstack/common/rpc/matchmaker_ring.py index 45a095f..6b488ce 100644 --- a/openstack/common/rpc/matchmaker_ring.py +++ b/openstack/common/rpc/matchmaker_ring.py @@ -63,9 +63,7 @@ class RingExchange(mm.Exchange): self.ring0[k] = itertools.cycle(self.ring[k]) def _ring_has(self, key): - if key in self.ring0: - return True - return False + return key in self.ring0 class RoundRobinRingExchange(RingExchange): -- cgit