Skip to content
Snippets Groups Projects
Commit f3a17cc6 authored by Gavin M. Roy's avatar Gavin M. Roy
Browse files

Remove duplicate code

parent 39ec1b37
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -16,7 +16,7 @@ from rabbitpy import base
LOGGER = logging.getLogger(__name__)
 
 
class Exchange(base.AMQPClass):
class _Exchange(base.AMQPClass):
"""Exchange class for interacting with an exchange in RabbitMQ including
declaration, binding and deletion.
 
Loading
Loading
@@ -34,12 +34,10 @@ class Exchange(base.AMQPClass):
auto_delete = False
type = 'direct'
 
def __init__(self, channel, name, exchange_type='direct',
durable=False, auto_delete=False,
def __init__(self, channel, name, durable=False, auto_delete=False,
arguments=None):
"""Create a new instance of the exchange object."""
super(Exchange, self).__init__(channel, name)
self.type = exchange_type
super(_Exchange, self).__init__(channel, name)
self.durable = durable
self.auto_delete = auto_delete
self.arguments = arguments or dict()
Loading
Loading
@@ -97,26 +95,44 @@ class Exchange(base.AMQPClass):
routing_key=routing_key))
 
 
class DirectExchange(Exchange):
"""The DirectExchange class is used for interacting with direct exchanges
only.
class Exchange(_Exchange):
"""Exchange class for interacting with an exchange in RabbitMQ including
declaration, binding and deletion.
 
:param channel: The channel object to communicate on
:type channel: :py:class:`rabbitpy.channel.Channel`
:param str name: The name of the exchange
:param str exchange_type: The exchange type
:param bool durable: Request a durable exchange
:param bool auto_delete: Automatically delete when not in use
:param dict arguments: Optional key/value arguments
 
"""
def __init__(self, channel, name, durable=False, auto_delete=False,
def __init__(self, channel, name, exchange_type='direct',
durable=False, auto_delete=False,
arguments=None):
"""Create a new instance of the exchange object."""
super(DirectExchange, self).__init__(channel, name, 'direct', durable,
auto_delete, arguments)
self.type = exchange_type
super(Exchange, self).__init__(channel, name, durable, auto_delete,
arguments)
class DirectExchange(_Exchange):
"""The DirectExchange class is used for interacting with direct exchanges
only.
:param channel: The channel object to communicate on
:type channel: :py:class:`rabbitpy.channel.Channel`
:param str name: The name of the exchange
:param bool durable: Request a durable exchange
:param bool auto_delete: Automatically delete when not in use
:param dict arguments: Optional key/value arguments
"""
type = 'direct'
 
 
class FanoutExchange(Exchange):
class FanoutExchange(_Exchange):
"""The FanoutExchange class is used for interacting with fanout exchanges
only.
 
Loading
Loading
@@ -128,14 +144,10 @@ class FanoutExchange(Exchange):
:param dict arguments: Optional key/value arguments
 
"""
def __init__(self, channel, name, durable=False, auto_delete=False,
arguments=None):
"""Create a new instance of the exchange object."""
super(FanoutExchange, self).__init__(channel, name, 'fanout', durable,
auto_delete, arguments)
type = 'fanout'
 
 
class HeadersExchange(Exchange):
class HeadersExchange(_Exchange):
"""The HeadersExchange class is used for interacting with direct exchanges
only.
 
Loading
Loading
@@ -147,14 +159,10 @@ class HeadersExchange(Exchange):
:param dict arguments: Optional key/value arguments
 
"""
def __init__(self, channel, name, durable=False, auto_delete=False,
arguments=None):
"""Create a new instance of the exchange object."""
super(HeadersExchange, self).__init__(channel, name, 'headers',
durable, auto_delete, arguments)
type = 'headers'
 
 
class TopicExchange(Exchange):
class TopicExchange(_Exchange):
"""The TopicExchange class is used for interacting with topic exchanges
only.
 
Loading
Loading
@@ -166,8 +174,4 @@ class TopicExchange(Exchange):
:param dict arguments: Optional key/value arguments
 
"""
def __init__(self, channel, name, durable=False, auto_delete=False,
arguments=None):
"""Create a new instance of the exchange object."""
super(TopicExchange, self).__init__(channel, name, 'topic', durable,
auto_delete, arguments)
type = 'topic'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment