python3: Use six.add_metaclass for metaclass

__metaclass__ can't be used with python 3 as metaclass syntax has been
changed in python 3.

Signed-off-by: Fumihiko Kakuma <kakuma@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
fumihiko kakuma 2016-06-13 13:12:25 +09:00 committed by FUJITA Tomonori
parent c897ae7d8a
commit d079bf38e7
6 changed files with 19 additions and 15 deletions

View File

@ -20,6 +20,7 @@ from __future__ import absolute_import
import abc
from collections import OrderedDict
import logging
import six
import socket
import time
import traceback
@ -125,6 +126,7 @@ class ActivityException(BGPSException):
pass
@six.add_metaclass(abc.ABCMeta)
class Activity(object):
"""Base class for a thread of execution that provides some custom settings.
@ -133,7 +135,6 @@ class Activity(object):
to start another activity or greenthread. Activity is also holds pointers
to sockets that it or its child activities of threads have create.
"""
__metaclass__ = abc.ABCMeta
def __init__(self, name=None):
self._name = name

View File

@ -25,6 +25,7 @@ from copy import copy
import logging
import functools
import netaddr
import six
from ryu.lib.packet.bgp import RF_IPv4_UC
from ryu.lib.packet.bgp import RouteTargetMembershipNLRI
@ -43,6 +44,7 @@ from ryu.services.protocols.bgp.processor import BPR_UNKNOWN
LOG = logging.getLogger('bgpspeaker.info_base.base')
@six.add_metaclass(ABCMeta)
class Table(object):
"""A container for holding information about destination/prefixes.
@ -50,7 +52,6 @@ class Table(object):
This is a base class which should be sub-classed for different route
family. A table can be uniquely identified by (Route Family, Scope Id).
"""
__metaclass__ = abc.ABCMeta
ROUTE_FAMILY = RF_IPv4_UC
def __init__(self, scope_id, core_service, signal_bus):
@ -275,6 +276,7 @@ class NonVrfPathProcessingMixin(object):
self._sent_routes = {}
@six.add_metaclass(ABCMeta)
class Destination(object):
"""State about a particular destination.
@ -282,7 +284,6 @@ class Destination(object):
a routing information base table *Table*.
"""
__metaclass__ = abc.ABCMeta
ROUTE_FAMILY = RF_IPv4_UC
def __init__(self, table, nlri):
@ -665,13 +666,13 @@ class Destination(object):
return result
@six.add_metaclass(ABCMeta)
class Path(object):
"""Represents a way of reaching an IP destination.
Also contains other meta-data given to us by a specific source (such as a
peer).
"""
__metaclass__ = ABCMeta
__slots__ = ('_source', '_path_attr_map', '_nlri', '_source_version_num',
'_exported_from', '_nexthop', 'next_path', 'prev_path',
'_is_withdraw', 'med_set_by_target_neighbor')
@ -835,6 +836,7 @@ class Path(object):
self._path_attr_map, self._nexthop, self._is_withdraw))
@six.add_metaclass(ABCMeta)
class Filter(object):
"""Represents a general filter for in-bound and out-bound filter
@ -845,7 +847,6 @@ class Filter(object):
================ ==================================================
"""
__metaclass__ = ABCMeta
ROUTE_FAMILY = RF_IPv4_UC

View File

@ -19,6 +19,7 @@
import abc
import logging
import six
from ryu.services.protocols.bgp.info_base.base import Destination
from ryu.services.protocols.bgp.info_base.base import NonVrfPathProcessingMixin
@ -55,8 +56,8 @@ class VpnTable(Table):
)
@six.add_metaclass(abc.ABCMeta)
class VpnPath(Path):
__metaclass__ = abc.ABCMeta
ROUTE_FAMILY = None
VRF_PATH_CLASS = None
NLRI_CLASS = None
@ -82,11 +83,10 @@ class VpnPath(Path):
return vrf_path
@six.add_metaclass(abc.ABCMeta)
class VpnDest(Destination, NonVrfPathProcessingMixin):
"""Base class for VPN destinations."""
__metaclass__ = abc.ABCMeta
def _best_path_lost(self):
old_best_path = self._best_path
NonVrfPathProcessingMixin._best_path_lost(self)

View File

@ -19,6 +19,7 @@
import abc
import logging
import six
from ryu.lib.packet.bgp import BGP_ATTR_TYPE_ORIGIN
from ryu.lib.packet.bgp import BGP_ATTR_TYPE_AS_PATH
@ -44,12 +45,12 @@ from ryu.services.protocols.bgp.utils.stats import RESOURCE_NAME
LOG = logging.getLogger('bgpspeaker.info_base.vrf')
@six.add_metaclass(abc.ABCMeta)
class VrfTable(Table):
"""Virtual Routing and Forwarding information base.
Keeps destination imported to given vrf in represents.
"""
__metaclass__ = abc.ABCMeta
ROUTE_FAMILY = None
VPN_ROUTE_FAMILY = None
NLRI_CLASS = None
@ -273,9 +274,9 @@ class VrfTable(Table):
return super(VrfTable, self).clean_uninteresting_paths(interested_rts)
@six.add_metaclass(abc.ABCMeta)
class VrfDest(Destination):
"""Base class for VRF destination."""
__metaclass__ = abc.ABCMeta
def __init__(self, table, nlri):
super(VrfDest, self).__init__(table, nlri)
@ -424,11 +425,11 @@ class VrfDest(Destination):
'with attribute label_list got %s' % path)
@six.add_metaclass(abc.ABCMeta)
class VrfPath(Path):
"""Represents a way of reaching an IP destination with a VPN.
"""
__slots__ = ('_label_list', '_puid')
__metaclass__ = abc.ABCMeta
ROUTE_FAMILY = None
VPN_PATH_CLASS = None

View File

@ -19,8 +19,10 @@
from abc import ABCMeta
from abc import abstractmethod
import six
@six.add_metaclass(ABCMeta)
class Protocol(object):
"""Interface for various protocols.
@ -31,7 +33,6 @@ class Protocol(object):
facilitate or provide hooks to sub-classes to override behavior as
appropriate.
"""
__metaclass__ = ABCMeta
@abstractmethod
def data_received(self, data):
@ -62,12 +63,12 @@ class Protocol(object):
pass
@six.add_metaclass(ABCMeta)
class Factory(object):
"""This is a factory which produces protocols.
Can also act as context for protocols.
"""
__metaclass__ = ABCMeta
# Put a subclass of Protocol here:
protocol = None

View File

@ -143,13 +143,13 @@ class ConfigValueError(RuntimeConfigError):
# Configuration base classes.
# =============================================================================
@six.add_metaclass(ABCMeta)
class BaseConf(object):
"""Base class for a set of configuration values.
Configurations can be required or optional. Also acts as a container of
configuration change listeners.
"""
__metaclass__ = ABCMeta
def __init__(self, **kwargs):
self._req_settings = self.get_req_settings()
@ -426,9 +426,9 @@ class ConfWithStats(BaseConf):
**kwargs)
@six.add_metaclass(ABCMeta)
class BaseConfListener(object):
"""Base class of all configuration listeners."""
__metaclass__ = ABCMeta
def __init__(self, base_conf):
pass