diff options
author | YAMAMOTO Takashi <yamamoto@valinux.co.jp> | 2014-02-10 18:30:15 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-02-11 13:56:40 +0900 |
commit | d5bb06a3f99ad697a2c7201a105feb9d8883781b (patch) | |
tree | 88fb41c1cd3509d611271ebb32e4c6de79ed856b | |
parent | 6f59821b50821e77585bdb6643d211b14bd8c5d6 (diff) |
use six.add_metaclass
as suggested by OpenStack Style Guideline.
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/lib/ofp_pktinfilter.py | 4 | ||||
-rw-r--r-- | ryu/lib/packet/bgp.py | 3 | ||||
-rw-r--r-- | ryu/lib/packet/icmpv6.py | 5 | ||||
-rw-r--r-- | ryu/lib/packet/ipv6.py | 5 | ||||
-rw-r--r-- | ryu/lib/packet/packet_base.py | 3 | ||||
-rw-r--r-- | ryu/lib/packet/sctp.py | 27 | ||||
-rw-r--r-- | ryu/lib/packet/stream_parser.py | 5 | ||||
-rw-r--r-- | ryu/lib/packet/vlan.py | 4 | ||||
-rw-r--r-- | ryu/services/protocols/vrrp/router.py | 4 | ||||
-rw-r--r-- | tools/pip-requires | 1 |
10 files changed, 26 insertions, 35 deletions
diff --git a/ryu/lib/ofp_pktinfilter.py b/ryu/lib/ofp_pktinfilter.py index c3bd9797..a84f7bb4 100644 --- a/ryu/lib/ofp_pktinfilter.py +++ b/ryu/lib/ofp_pktinfilter.py @@ -16,6 +16,7 @@ import logging from abc import ABCMeta, abstractmethod +import six from ryu.lib.packet import packet @@ -36,9 +37,8 @@ def packet_in_filter(cls, args=None): return _packet_in_filter +@six.add_metaclass(ABCMeta) class PacketInFilterBase(object): - __metaclass__ = ABCMeta - def __init__(self, args): self.args = args diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py index 6c1d6ad7..2d71917c 100644 --- a/ryu/lib/packet/bgp.py +++ b/ryu/lib/packet/bgp.py @@ -23,6 +23,7 @@ RFC 4271 BGP-4 # - RFC 4364 BGP/MPLS IP Virtual Private Networks (VPNs) import abc +import six import struct from ryu.ofproto.ofproto_parser import msg_pack_into @@ -137,8 +138,8 @@ def pad(bin, len_): return bin + (len_ - len(bin)) * '\0' +@six.add_metaclass(abc.ABCMeta) class _AddrPrefix(StringifyMixin): - __metaclass__ = abc.ABCMeta _PACK_STR = '!B' # length def __init__(self, length, addr, prefixes=None): diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py index 4ba1d63d..c36ad04a 100644 --- a/ryu/lib/packet/icmpv6.py +++ b/ryu/lib/packet/icmpv6.py @@ -15,6 +15,7 @@ import abc import struct +import six import sys import array import binascii @@ -387,10 +388,8 @@ class nd_router_advert(stringify.StringifyMixin): return length +@six.add_metaclass(abc.ABCMeta) class nd_option(stringify.StringifyMixin): - - __metaclass__ = abc.ABCMeta - @classmethod @abc.abstractmethod def option_type(cls): diff --git a/ryu/lib/packet/ipv6.py b/ryu/lib/packet/ipv6.py index 1c481b5c..960f1acb 100644 --- a/ryu/lib/packet/ipv6.py +++ b/ryu/lib/packet/ipv6.py @@ -14,6 +14,7 @@ # limitations under the License. import abc +import six import struct from . import packet_base from . import icmpv6 @@ -147,11 +148,9 @@ ipv6.register_packet_type(udp.udp, inet.IPPROTO_UDP) ipv6.register_packet_type(sctp.sctp, inet.IPPROTO_SCTP) +@six.add_metaclass(abc.ABCMeta) class header(stringify.StringifyMixin): """extension header abstract class.""" - - __metaclass__ = abc.ABCMeta - def __init__(self, nxt): self.nxt = nxt diff --git a/ryu/lib/packet/packet_base.py b/ryu/lib/packet/packet_base.py index cbc213fd..f08330b9 100644 --- a/ryu/lib/packet/packet_base.py +++ b/ryu/lib/packet/packet_base.py @@ -14,12 +14,13 @@ # limitations under the License. import abc +import six from ryu.lib import stringify +@six.add_metaclass(abc.ABCMeta) class PacketBase(stringify.StringifyMixin): """A base class for a protocol (ethernet, ipv4, ...) header.""" - __metaclass__ = abc.ABCMeta _TYPES = {} @classmethod diff --git a/ryu/lib/packet/sctp.py b/ryu/lib/packet/sctp.py index e984dc21..88d9d37e 100644 --- a/ryu/lib/packet/sctp.py +++ b/ryu/lib/packet/sctp.py @@ -14,6 +14,7 @@ # limitations under the License. import abc +import six import struct from ryu.lib import addrconv @@ -227,9 +228,8 @@ class sctp(packet_base.PacketBase): # Chunk Types # #======================================================================= +@six.add_metaclass(abc.ABCMeta) class chunk(stringify.StringifyMixin): - - __metaclass__ = abc.ABCMeta _PACK_STR = '!BBH' _MIN_LEN = struct.calcsize(_PACK_STR) @@ -252,9 +252,8 @@ class chunk(stringify.StringifyMixin): return self.length +@six.add_metaclass(abc.ABCMeta) class chunk_init_base(chunk): - - __metaclass__ = abc.ABCMeta _PACK_STR = '!BBHIIHHI' _MIN_LEN = struct.calcsize(_PACK_STR) _class_prefixes = ['param_'] @@ -304,9 +303,8 @@ class chunk_init_base(chunk): return str(buf) +@six.add_metaclass(abc.ABCMeta) class chunk_heartbeat_base(chunk): - - __metaclass__ = abc.ABCMeta _class_prefixes = ['param_'] def __init__(self, flags=0, length=0, info=None): @@ -338,10 +336,8 @@ class chunk_heartbeat_base(chunk): return str(buf) +@six.add_metaclass(abc.ABCMeta) class chunk_ack_base(chunk): - - __metaclass__ = abc.ABCMeta - def __init__(self, flags=0, length=0): super(chunk_ack_base, self).__init__(self.chunk_type(), length) self.flags = flags @@ -360,9 +356,8 @@ class chunk_ack_base(chunk): return buf +@six.add_metaclass(abc.ABCMeta) class chunk_ecn_base(chunk): - - __metaclass__ = abc.ABCMeta _PACK_STR = '!BBHI' _MIN_LEN = struct.calcsize(_PACK_STR) @@ -1176,9 +1171,8 @@ class chunk_shutdown_complete(chunk): # Cause Code # #======================================================================= +@six.add_metaclass(abc.ABCMeta) class cause(stringify.StringifyMixin): - - __metaclass__ = abc.ABCMeta _PACK_STR = '!HH' _MIN_LEN = struct.calcsize(_PACK_STR) @@ -1210,10 +1204,8 @@ class cause(stringify.StringifyMixin): return length +@six.add_metaclass(abc.ABCMeta) class cause_with_value(cause): - - __metaclass__ = abc.ABCMeta - def __init__(self, value=None, length=0): super(cause_with_value, self).__init__(length) self.value = value @@ -1777,9 +1769,8 @@ class cause_protocol_violation(cause_with_value): # Chunk Parameter Types # #======================================================================= +@six.add_metaclass(abc.ABCMeta) class param(stringify.StringifyMixin): - - __metaclass__ = abc.ABCMeta _PACK_STR = '!HH' _MIN_LEN = struct.calcsize(_PACK_STR) diff --git a/ryu/lib/packet/stream_parser.py b/ryu/lib/packet/stream_parser.py index 87e1aed6..75e6cc53 100644 --- a/ryu/lib/packet/stream_parser.py +++ b/ryu/lib/packet/stream_parser.py @@ -16,8 +16,10 @@ from abc import ABCMeta, abstractmethod +import six +@six.add_metaclass(ABCMeta) class StreamParser(object): """Streaming parser base class. @@ -29,9 +31,6 @@ class StreamParser(object): is TCP. """ - - __metaclass__ = ABCMeta - class TooSmallException(Exception): pass diff --git a/ryu/lib/packet/vlan.py b/ryu/lib/packet/vlan.py index 1ee7dd38..a4f4332c 100644 --- a/ryu/lib/packet/vlan.py +++ b/ryu/lib/packet/vlan.py @@ -14,6 +14,7 @@ # limitations under the License. import abc +import six import struct from . import packet_base from . import arp @@ -26,9 +27,8 @@ from . import pbb from ryu.ofproto import ether +@six.add_metaclass(abc.ABCMeta) class _vlan(packet_base.PacketBase): - - __metaclass__ = abc.ABCMeta _PACK_STR = "!HH" _MIN_LEN = struct.calcsize(_PACK_STR) diff --git a/ryu/services/protocols/vrrp/router.py b/ryu/services/protocols/vrrp/router.py index ff2290d5..610a67b4 100644 --- a/ryu/services/protocols/vrrp/router.py +++ b/ryu/services/protocols/vrrp/router.py @@ -21,6 +21,7 @@ VRRPManager creates/deletes VRRPRounter instances dynamically. """ import abc +import six from ryu.base import app_manager from ryu.controller import event @@ -103,9 +104,8 @@ class VRRPParams(object): return (3.0 * self.master_adver_interval) + self.skew_time +@six.add_metaclass(abc.ABCMeta) class VRRPState(object): - __metaclass__ = abc.ABCMeta - def __init__(self, vrrp_router): super(VRRPState, self).__init__() self.vrrp_router = vrrp_router diff --git a/tools/pip-requires b/tools/pip-requires index 565e4d42..96315d00 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -5,4 +5,5 @@ netaddr oslo.config paramiko routes +six webob>=1.0.8 |