Apply six for metaclass

__metaclass__ cannot be used in python3.six be used in general
for python 3 compatibility.

Porting Change-Id I9fc7a59df3af29b4cc1287c40fa4e883d994a961
from oslo-incubator

Change-Id: Icdacdcf5556b6d3b8450d1350c6f62b4f5a9690b
This commit is contained in:
Davanum Srinivas 2013-10-14 10:42:15 -04:00
parent 91f74d8df0
commit 5f760096d6
5 changed files with 16 additions and 13 deletions

View File

@ -15,6 +15,8 @@
import abc
import six
from oslo.messaging import exceptions
@ -22,10 +24,9 @@ class TransportDriverError(exceptions.MessagingException):
"""Base class for transport driver specific exceptions."""
@six.add_metaclass(abc.ABCMeta)
class IncomingMessage(object):
__metaclass__ = abc.ABCMeta
def __init__(self, listener, ctxt, message):
self.conf = listener.conf
self.listener = listener
@ -37,10 +38,9 @@ class IncomingMessage(object):
"Send a reply or failure back to the client."
@six.add_metaclass(abc.ABCMeta)
class Listener(object):
__metaclass__ = abc.ABCMeta
def __init__(self, driver, target):
self.conf = driver.conf
self.driver = driver
@ -51,10 +51,9 @@ class Listener(object):
"Blocking until a message is pending and return IncomingMessage."
@six.add_metaclass(abc.ABCMeta)
class BaseDriver(object):
__metaclass__ = abc.ABCMeta
def __init__(self, conf, url,
default_exchange=None, allowed_remote_exmods=[]):
self.conf = conf

View File

@ -17,7 +17,10 @@ import abc
import collections
import threading
import six
@six.add_metaclass(abc.ABCMeta)
class Pool(object):
"""A thread-safe object pool.
@ -28,8 +31,6 @@ class Pool(object):
Resizing is not supported.
"""
__metaclass__ = abc.ABCMeta
def __init__(self, max_size=4):
super(Pool, self).__init__()

View File

@ -16,15 +16,16 @@ import abc
import logging
import sys
import six
from oslo import messaging
_LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class ExecutorBase(object):
__metaclass__ = abc.ABCMeta
def __init__(self, conf, listener, callback):
self.conf = conf
self.listener = listener

View File

@ -19,6 +19,7 @@ import abc
import logging
from oslo.config import cfg
import six
from stevedore import named
from oslo.messaging.openstack.common import timeutils
@ -39,10 +40,9 @@ _notifier_opts = [
_LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class _Driver(object):
__metaclass__ = abc.ABCMeta
def __init__(self, conf, topics, transport):
self.conf = conf
self.topics = topics

View File

@ -18,10 +18,12 @@ __all__ = ['Serializer', 'NoOpSerializer']
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class Serializer(object):
"""Generic (de-)serialization definition base class."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def serialize_entity(self, ctxt, entity):