Apply six for metaclass

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

Change-Id: I1d9909d70bb614c9d1c336d0c492027f5b6b5088
Closes-Bug: #1236648
This commit is contained in:
fujioka yuuichi 2013-10-08 10:58:50 +09:00
parent 7f0db9568d
commit 5a657dd947
10 changed files with 23 additions and 23 deletions

View File

@ -18,6 +18,7 @@
import abc import abc
import six
from oslo.config import cfg from oslo.config import cfg
@ -33,11 +34,10 @@ OK = 'ok'
ALARM = 'alarm' ALARM = 'alarm'
@six.add_metaclass(abc.ABCMeta)
class Evaluator(object): class Evaluator(object):
"""Base class for alarm rule evaluator plugins.""" """Base class for alarm rule evaluator plugins."""
__metaclass__ = abc.ABCMeta
def __init__(self, notifier): def __init__(self, notifier):
self.notifier = notifier self.notifier = notifier
self.api_client = None self.api_client = None

View File

@ -17,13 +17,13 @@
# under the License. # under the License.
import abc import abc
import six
@six.add_metaclass(abc.ABCMeta)
class AlarmNotifier(object): class AlarmNotifier(object):
"""Base class for alarm notifier plugins.""" """Base class for alarm notifier plugins."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def notify(self, action, alarm_id, previous, current, reason): def notify(self, action, alarm_id, previous, current, reason):
"""Notify that an alarm has been triggered. """Notify that an alarm has been triggered.

View File

@ -19,6 +19,7 @@
# under the License. # under the License.
import abc import abc
import six
from oslo.config import cfg from oslo.config import cfg
from stevedore import extension from stevedore import extension
@ -58,10 +59,9 @@ cfg.CONF.import_opt('partition_rpc_topic', 'ceilometer.alarm.rpc',
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class AlarmService(object): class AlarmService(object):
__metaclass__ = abc.ABCMeta
EXTENSIONS_NAMESPACE = "ceilometer.alarm.evaluator" EXTENSIONS_NAMESPACE = "ceilometer.alarm.evaluator"
def _load_evaluators(self): def _load_evaluators(self):

View File

@ -17,12 +17,12 @@
# under the License. # under the License.
import abc import abc
import six
@six.add_metaclass(abc.ABCMeta)
class Base(object): class Base(object):
__metaclass__ = abc.ABCMeta
def __init__(self, conf): def __init__(self, conf):
self.conf = conf self.conf = conf

View File

@ -19,16 +19,16 @@
""" """
import abc import abc
import six
from ceilometer import plugin from ceilometer import plugin
@six.add_metaclass(abc.ABCMeta)
class ComputePollster(plugin.PollsterBase): class ComputePollster(plugin.PollsterBase):
"""Base class for plugins that support the polling API on the compute node. """Base class for plugins that support the polling API on the compute node.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def get_samples(self, manager, cache, instance): def get_samples(self, manager, cache, instance):
"""Return a sequence of Counter instances from polling the resources. """Return a sequence of Counter instances from polling the resources.

View File

@ -22,6 +22,7 @@ import abc
import collections import collections
import fnmatch import fnmatch
from oslo.config import cfg from oslo.config import cfg
import six
# Import this option so every Notification plugin can use it freely. # Import this option so every Notification plugin can use it freely.
cfg.CONF.import_opt('notification_topics', cfg.CONF.import_opt('notification_topics',
@ -37,11 +38,10 @@ class PluginBase(object):
""" """
@six.add_metaclass(abc.ABCMeta)
class NotificationBase(PluginBase): class NotificationBase(PluginBase):
"""Base class for plugins that support the notification API.""" """Base class for plugins that support the notification API."""
__metaclass__ = abc.ABCMeta
@abc.abstractproperty @abc.abstractproperty
def event_types(self): def event_types(self):
"""Return a sequence of strings defining the event types to be """Return a sequence of strings defining the event types to be
@ -85,11 +85,10 @@ class NotificationBase(PluginBase):
return [] return []
@six.add_metaclass(abc.ABCMeta)
class PollsterBase(PluginBase): class PollsterBase(PluginBase):
"""Base class for plugins that support the polling API.""" """Base class for plugins that support the polling API."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def get_samples(self, manager, cache): def get_samples(self, manager, cache):
"""Return a sequence of Counter instances from polling the resources. """Return a sequence of Counter instances from polling the resources.

View File

@ -21,6 +21,7 @@
import abc import abc
from stevedore import driver from stevedore import driver
from ceilometer.openstack.common import network_utils from ceilometer.openstack.common import network_utils
import six
def get_publisher(url, namespace='ceilometer.publisher'): def get_publisher(url, namespace='ceilometer.publisher'):
@ -34,11 +35,10 @@ def get_publisher(url, namespace='ceilometer.publisher'):
return loaded_driver.driver(parse_result) return loaded_driver.driver(parse_result)
@six.add_metaclass(abc.ABCMeta)
class PublisherBase(object): class PublisherBase(object):
"""Base class for plugins that publish the sampler.""" """Base class for plugins that publish the sampler."""
__metaclass__ = abc.ABCMeta
def __init__(self, parsed_url): def __init__(self, parsed_url):
pass pass

View File

@ -21,6 +21,7 @@
import abc import abc
import datetime import datetime
import math import math
import six
from ceilometer.openstack.common import timeutils from ceilometer.openstack.common import timeutils
@ -102,21 +103,19 @@ class Pagination(object):
self.sort_dirs = sort_dirs self.sort_dirs = sort_dirs
@six.add_metaclass(abc.ABCMeta)
class StorageEngine(object): class StorageEngine(object):
"""Base class for storage engines.""" """Base class for storage engines."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def get_connection(self, conf): def get_connection(self, conf):
"""Return a Connection instance based on the configuration settings.""" """Return a Connection instance based on the configuration settings."""
@six.add_metaclass(abc.ABCMeta)
class Connection(object): class Connection(object):
"""Base class for storage system connections.""" """Base class for storage system connections."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self, conf): def __init__(self, conf):
"""Constructor.""" """Constructor."""

View File

@ -20,6 +20,7 @@
"""Base classes for API tests.""" """Base classes for API tests."""
import os import os
import six
import uuid import uuid
import warnings import warnings
@ -78,8 +79,8 @@ class DB2FakeConnectionUrl(MongoDBFakeConnectionUrl):
self.url = self.url.replace('mongodb:', 'db2:', 1) self.url = self.url.replace('mongodb:', 'db2:', 1)
@six.add_metaclass(test_base.SkipNotImplementedMeta)
class MixinTestsWithBackendScenarios(object): class MixinTestsWithBackendScenarios(object):
__metaclass__ = test_base.SkipNotImplementedMeta
scenarios = [ scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')), ('sqlalchemy', dict(database_connection='sqlite://')),

View File

@ -17,6 +17,8 @@
# under the License. # under the License.
import abc import abc
import six
from stevedore import extension from stevedore import extension
@ -35,11 +37,10 @@ class TransformerExtensionManager(extension.ExtensionManager):
return self.by_name[name] return self.by_name[name]
@six.add_metaclass(abc.ABCMeta)
class TransformerBase(object): class TransformerBase(object):
"""Base class for plugins that transform the sample.""" """Base class for plugins that transform the sample."""
__metaclass__ = abc.ABCMeta
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""Setup transformer. """Setup transformer.