*: Adopt to pycodestyle's checks

This patch adopts to the following pycodestyle's checks;
  E275: missing whitespace after keyword
  E305: expected 2 blank lines after end of function or class

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
IWASE Yusuke 2017-12-15 10:50:15 +09:00 committed by FUJITA Tomonori
parent bdf3549563
commit d64db265b3
35 changed files with 47 additions and 11 deletions

View File

@ -40,6 +40,7 @@ class AddressConverter(object):
return str(self._addr(self._strat.packed_to_int(bin), return str(self._addr(self._strat.packed_to_int(bin),
**self._addr_kwargs)) **self._addr_kwargs))
ipv4 = AddressConverter(netaddr.IPAddress, netaddr.strategy.ipv4, ipv4 = AddressConverter(netaddr.IPAddress, netaddr.strategy.ipv4,
fallback=netaddr.IPNetwork, version=4) fallback=netaddr.IPNetwork, version=4)
ipv6 = AddressConverter(netaddr.IPAddress, netaddr.strategy.ipv6, ipv6 = AddressConverter(netaddr.IPAddress, netaddr.strategy.ipv6,
@ -48,5 +49,7 @@ ipv6 = AddressConverter(netaddr.IPAddress, netaddr.strategy.ipv6,
class mac_mydialect(netaddr.mac_unix): class mac_mydialect(netaddr.mac_unix):
word_fmt = '%.2x' word_fmt = '%.2x'
mac = AddressConverter(netaddr.EUI, netaddr.strategy.eui48, version=48, mac = AddressConverter(netaddr.EUI, netaddr.strategy.eui48, version=48,
dialect=mac_mydialect) dialect=mac_mydialect)

View File

@ -236,6 +236,7 @@ class UnknownMrtMessage(MrtMessage):
def serialize(self): def serialize(self):
return self.buf return self.buf
# Registers self to unknown(default) type # Registers self to unknown(default) type
UnknownMrtMessage._UNKNOWN_TYPE = UnknownMrtMessage UnknownMrtMessage._UNKNOWN_TYPE = UnknownMrtMessage
@ -298,6 +299,7 @@ class Ospf2MrtRecord(MrtCommonRecord):
message=message, timestamp=timestamp, type_=type_, message=message, timestamp=timestamp, type_=type_,
subtype=subtype, length=length) subtype=subtype, length=length)
# Registers self to unknown(default) type # Registers self to unknown(default) type
Ospf2MrtMessage._UNKNOWN_TYPE = Ospf2MrtMessage Ospf2MrtMessage._UNKNOWN_TYPE = Ospf2MrtMessage

View File

@ -565,6 +565,7 @@ class RouteFamily(StringifyMixin):
def __hash__(self): def __hash__(self):
return hash((self.afi, self.safi)) return hash((self.afi, self.safi))
# Route Family Singleton # Route Family Singleton
RF_IPv4_UC = RouteFamily(addr_family.IP, subaddr_family.UNICAST) RF_IPv4_UC = RouteFamily(addr_family.IP, subaddr_family.UNICAST)
RF_IPv6_UC = RouteFamily(addr_family.IP6, subaddr_family.UNICAST) RF_IPv6_UC = RouteFamily(addr_family.IP6, subaddr_family.UNICAST)

View File

@ -142,6 +142,7 @@ class ipv4(packet_base.PacketBase):
struct.pack_into('!H', hdr, 10, self.csum) struct.pack_into('!H', hdr, 10, self.csum)
return hdr return hdr
ipv4.register_packet_type(icmp.icmp, inet.IPPROTO_ICMP) ipv4.register_packet_type(icmp.icmp, inet.IPPROTO_ICMP)
ipv4.register_packet_type(igmp.igmp, inet.IPPROTO_IGMP) ipv4.register_packet_type(igmp.igmp, inet.IPPROTO_IGMP)
ipv4.register_packet_type(tcp.tcp, inet.IPPROTO_TCP) ipv4.register_packet_type(tcp.tcp, inet.IPPROTO_TCP)

View File

@ -143,6 +143,7 @@ class ipv6(packet_base.PacketBase):
ext_hdrs_len += len(ext_hdr) ext_hdrs_len += len(ext_hdr)
return self._MIN_LEN + ext_hdrs_len return self._MIN_LEN + ext_hdrs_len
ipv6.register_packet_type(icmpv6.icmpv6, inet.IPPROTO_ICMPV6) ipv6.register_packet_type(icmpv6.icmpv6, inet.IPPROTO_ICMPV6)
ipv6.register_packet_type(tcp.tcp, inet.IPPROTO_TCP) ipv6.register_packet_type(tcp.tcp, inet.IPPROTO_TCP)
ipv6.register_packet_type(udp.udp, inet.IPPROTO_UDP) ipv6.register_packet_type(udp.udp, inet.IPPROTO_UDP)

View File

@ -695,6 +695,7 @@ class OSPFMessage(packet_base.PacketBase, type_desc.TypeDisp):
struct.pack_into("!H", buf, 12, csum) struct.pack_into("!H", buf, 12, csum)
return buf return buf
# alias # alias
ospf = OSPFMessage ospf = OSPFMessage

View File

@ -185,5 +185,6 @@ def _PacketBase__div__(self, trailer):
pkt.add_protocol(trailer) pkt.add_protocol(trailer)
return pkt return pkt
packet_base.PacketBase.__div__ = _PacketBase__div__ packet_base.PacketBase.__div__ = _PacketBase__div__
packet_base.PacketBase.__truediv__ = _PacketBase__div__ packet_base.PacketBase.__truediv__ = _PacketBase__div__

View File

@ -99,6 +99,7 @@ def checksum_ip(ipvx, length, payload):
buf = header + payload buf = header + payload
return checksum(buf) return checksum(buf)
_MODX = 4102 _MODX = 4102

View File

@ -44,6 +44,7 @@ class IntDescr(TypeDescr):
i //= 256 i //= 256
return binary return binary
Int1 = IntDescr(1) Int1 = IntDescr(1)
Int2 = IntDescr(2) Int2 = IntDescr(2)
Int3 = IntDescr(3) Int3 = IntDescr(3)
@ -91,6 +92,7 @@ class IntDescrMlt(TypeDescr):
binary += b binary += b
return binary return binary
Int4Double = IntDescrMlt(4, 2) Int4Double = IntDescrMlt(4, 2)

View File

@ -428,6 +428,7 @@ def nxm_nx_reg(idx):
def nxm_nx_reg_w(idx): def nxm_nx_reg_w(idx):
return nxm_header_w(0x0001, idx, 4) return nxm_header_w(0x0001, idx, 4)
NXM_HEADER_PACK_STRING = '!I' NXM_HEADER_PACK_STRING = '!I'
# #

View File

@ -822,6 +822,7 @@ class OFPActionVendor(OFPAction):
msg_pack_into(ofproto.OFP_ACTION_VENDOR_HEADER_PACK_STR, msg_pack_into(ofproto.OFP_ACTION_VENDOR_HEADER_PACK_STR,
buf, offset, self.type, self.len, self.vendor) buf, offset, self.type, self.len, self.vendor)
# OpenFlow1.2 or later compatible # OpenFlow1.2 or later compatible
OFPActionExperimenter = OFPActionVendor OFPActionExperimenter = OFPActionVendor

View File

@ -792,6 +792,7 @@ def oxm_tlv_header_extract_length(header):
length = header & 0xff length = header & 0xff
return length return length
oxm_types = [ oxm_types = [
oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4), oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4),
oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4), oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4),

View File

@ -1180,6 +1180,7 @@ def oxm_tlv_header_extract_length(header):
length = header & 0xff length = header & 0xff
return length return length
oxm_types = [ oxm_types = [
oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4), oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4),
oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4), oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4),

View File

@ -349,6 +349,7 @@ def oxm_tlv_header_extract_length(header):
length = header & 0xff length = header & 0xff
return length return length
oxm_types = [ oxm_types = [
oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4), oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4),
oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4), oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4),

View File

@ -386,6 +386,7 @@ def oxm_tlv_header_extract_length(header):
length = header & 0xff length = header & 0xff
return length return length
oxm_types = [ oxm_types = [
oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4), oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4),
oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4), oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4),
@ -457,6 +458,7 @@ def oxs_tlv_header(field, length):
def oxs_tlv_header_extract_length(header): def oxs_tlv_header_extract_length(header):
return header & 0xff return header & 0xff
oxs_types = [ oxs_types = [
oxs_fields.OpenFlowBasic('duration', 0, type_desc.Int4Double), oxs_fields.OpenFlowBasic('duration', 0, type_desc.Int4Double),
oxs_fields.OpenFlowBasic('idle_time', 1, type_desc.Int4Double), oxs_fields.OpenFlowBasic('idle_time', 1, type_desc.Int4Double),

View File

@ -69,5 +69,6 @@ class _CoreManager(Activity):
self._check_started() self._check_started()
return self._vrfs_conf return self._vrfs_conf
# _CoreManager instance that manages core bgp service and configuration data. # _CoreManager instance that manages core bgp service and configuration data.
CORE_MANAGER = _CoreManager() CORE_MANAGER = _CoreManager()

View File

@ -58,7 +58,7 @@ class L2VPNFlowSpecPath(VpnPath):
# Set dummy IP address. # Set dummy IP address.
kwargs['nexthop'] = '0.0.0.0' kwargs['nexthop'] = '0.0.0.0'
super(L2VPNFlowSpecPath, self).__init__(*args, **kwargs) super(L2VPNFlowSpecPath, self).__init__(*args, **kwargs)
from ryu.services.protocols.bgp.info_base.vrfl2vpnfs import( from ryu.services.protocols.bgp.info_base.vrfl2vpnfs import (
L2vpnFlowSpecPath) L2vpnFlowSpecPath)
self.VRF_PATH_CLASS = L2vpnFlowSpecPath self.VRF_PATH_CLASS = L2vpnFlowSpecPath
# Because the L2VPN Flow Specification does not require nexthop, # Because the L2VPN Flow Specification does not require nexthop,

View File

@ -58,7 +58,7 @@ class VPNv4FlowSpecPath(VpnPath):
# Set dummy IP address. # Set dummy IP address.
kwargs['nexthop'] = '0.0.0.0' kwargs['nexthop'] = '0.0.0.0'
super(VPNv4FlowSpecPath, self).__init__(*args, **kwargs) super(VPNv4FlowSpecPath, self).__init__(*args, **kwargs)
from ryu.services.protocols.bgp.info_base.vrf4fs import( from ryu.services.protocols.bgp.info_base.vrf4fs import (
Vrf4FlowSpecPath) Vrf4FlowSpecPath)
self.VRF_PATH_CLASS = Vrf4FlowSpecPath self.VRF_PATH_CLASS = Vrf4FlowSpecPath
# Because the IPv4 Flow Specification does not require nexthop, # Because the IPv4 Flow Specification does not require nexthop,

View File

@ -58,7 +58,7 @@ class VPNv6FlowSpecPath(VpnPath):
# Set dummy IP address. # Set dummy IP address.
kwargs['nexthop'] = '::' kwargs['nexthop'] = '::'
super(VPNv6FlowSpecPath, self).__init__(*args, **kwargs) super(VPNv6FlowSpecPath, self).__init__(*args, **kwargs)
from ryu.services.protocols.bgp.info_base.vrf6fs import( from ryu.services.protocols.bgp.info_base.vrf6fs import (
Vrf6FlowSpecPath) Vrf6FlowSpecPath)
self.VRF_PATH_CLASS = Vrf6FlowSpecPath self.VRF_PATH_CLASS = Vrf6FlowSpecPath
# Because the IPv6 Flow Specification does not require nexthop, # Because the IPv6 Flow Specification does not require nexthop,

View File

@ -516,4 +516,5 @@ class Cli(Activity):
server = hub.StreamServer(listen_info, ssh_server_factory) server = hub.StreamServer(listen_info, ssh_server_factory)
server.serve_forever() server.serve_forever()
SSH_CLI_CONTROLLER = Cli() SSH_CLI_CONTROLLER = Cli()

View File

@ -278,9 +278,11 @@ class RouteFamilyView(OperatorDetailView):
afi = fields.DataField('afi') afi = fields.DataField('afi')
safi = fields.DataField('safi') safi = fields.DataField('safi')
################################################################## ##################################################################
# Declarations of list and dict views based on detail views above # Declarations of list and dict views based on detail views above
################################################################## ##################################################################
PeerListView = create_list_view_class(PeerDetailView, 'PeerListView') PeerListView = create_list_view_class(PeerDetailView, 'PeerListView')
PeerDictView = create_dict_view_class(PeerDetailView, 'PeerDictView') PeerDictView = create_dict_view_class(PeerDetailView, 'PeerDictView')

View File

@ -154,6 +154,7 @@ class BgpProcessor(Activity):
# Wake-up processing thread if sleeping. # Wake-up processing thread if sleeping.
self.dest_que_evt.set() self.dest_que_evt.set()
# ============================================================================= # =============================================================================
# Best path computation related utilities. # Best path computation related utilities.
# ============================================================================= # =============================================================================

View File

@ -224,6 +224,7 @@ def valid_prefix_filter(filter_):
le = filter_.get('le', None) le = filter_.get('le', None)
return PrefixFilter(prefix, policy, ge=ge, le=le) return PrefixFilter(prefix, policy, ge=ge, le=le)
PREFIX_FILTER = 'prefix_filter' PREFIX_FILTER = 'prefix_filter'
SUPPORTED_FILTER_VALIDATORS = { SUPPORTED_FILTER_VALIDATORS = {

View File

@ -35,6 +35,7 @@ def _repr(self):
for k, v in self.__dict__.items() if not k.startswith('_')]) for k, v in self.__dict__.items() if not k.startswith('_')])
return "%s(%s)" % (self.__class__.__name__, m) return "%s(%s)" % (self.__class__.__name__, m)
Base.__repr__ = _repr Base.__repr__ = _repr

View File

@ -292,6 +292,7 @@ class MyHandler(socketserver.BaseRequestHandler):
class MyVerboseHandler(MyHandler): class MyVerboseHandler(MyHandler):
verbose = True verbose = True
if __name__ == '__main__': if __name__ == '__main__':
optlist, args = getopt.getopt(sys.argv[1:], 'dvo:') optlist, args = getopt.getopt(sys.argv[1:], 'dvo:')
debug = False debug = False

View File

@ -131,6 +131,7 @@ def _add_tests():
) )
test_lib.add_method(Test_ofctl_rest, name, f) test_lib.add_method(Test_ofctl_rest, name, f)
_add_tests() _add_tests()
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -50,5 +50,6 @@ class Test_ws_topology(unittest.TestCase):
rpc_client_mock1.get_proxy.assert_called_once_with() rpc_client_mock1.get_proxy.assert_called_once_with()
rpc_client_mock2.get_proxy.assert_called_once_with() rpc_client_mock2.get_proxy.assert_called_once_with()
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View File

@ -307,4 +307,5 @@ def _add_tests():
assert (cases == assert (cases ==
set(unittest.defaultTestLoader.getTestCaseNames(Test_Parser))) set(unittest.defaultTestLoader.getTestCaseNames(Test_Parser)))
_add_tests() _add_tests()

View File

@ -157,4 +157,5 @@ def _add_tests():
ofpp=ofpp) ofpp=ofpp)
test_lib.add_method(Test_Parser_Compat, method_name, f) test_lib.add_method(Test_Parser_Compat, method_name, f)
_add_tests() _add_tests()

View File

@ -287,4 +287,5 @@ def _add_tests():
test_lib.add_method(Test_Parser_OFPMatch, test_lib.add_method(Test_Parser_OFPMatch,
method_name, f) method_name, f)
_add_tests() _add_tests()

View File

@ -204,4 +204,5 @@ def _add_tests():
test_lib.add_method(Test_Parser_OFPStats, test_lib.add_method(Test_Parser_OFPStats,
method_name, f) method_name, f)
_add_tests() _add_tests()

View File

@ -795,13 +795,13 @@ class Test_routing(unittest.TestCase):
not_implemented_buf = struct.pack( not_implemented_buf = struct.pack(
'!BBBBBB2x', 0, 6, ipv6.routing.ROUTING_TYPE_2, 0, 0, 0) '!BBBBBB2x', 0, 6, ipv6.routing.ROUTING_TYPE_2, 0, 0, 0)
instance = ipv6.routing.parser(not_implemented_buf) instance = ipv6.routing.parser(not_implemented_buf)
assert None == instance assert None is instance
def test_invalid_type(self): def test_invalid_type(self):
invalid_type = 99 invalid_type = 99
invalid_buf = struct.pack('!BBBBBB2x', 0, 6, invalid_type, 0, 0, 0) invalid_buf = struct.pack('!BBBBBB2x', 0, 6, invalid_type, 0, 0, 0)
instance = ipv6.routing.parser(invalid_buf) instance = ipv6.routing.parser(invalid_buf)
assert None == instance assert None is instance
class Test_routing_type3(unittest.TestCase): class Test_routing_type3(unittest.TestCase):

View File

@ -147,16 +147,16 @@ class Test_slow(unittest.TestCase):
not_implemented_buf = pack( not_implemented_buf = pack(
slow._PACK_STR, SLOW_SUBTYPE_MARKER) + self.buf[1:] slow._PACK_STR, SLOW_SUBTYPE_MARKER) + self.buf[1:]
(instance, nexttype, last) = slow.parser(not_implemented_buf) (instance, nexttype, last) = slow.parser(not_implemented_buf)
assert None == instance assert instance is None
assert None == nexttype assert nexttype is None
assert None != last assert last is not None
def test_invalid_subtype(self): def test_invalid_subtype(self):
invalid_buf = b'\xff' + self.buf[1:] invalid_buf = b'\xff' + self.buf[1:]
(instance, nexttype, last) = slow.parser(invalid_buf) (instance, nexttype, last) = slow.parser(invalid_buf)
assert None == instance assert instance is None
assert None == nexttype assert nexttype is None
assert None != last assert last is not None
class Test_lacp(unittest.TestCase): class Test_lacp(unittest.TestCase):

View File

@ -57,6 +57,7 @@ def _get_requirements(files):
return requirements return requirements
OPENSTACK_REQUIREMENTS = _get_requirements(OPENSTACK_REQUIREMENTS_FILES) OPENSTACK_REQUIREMENTS = _get_requirements(OPENSTACK_REQUIREMENTS_FILES)
RYU_REQUIREMENTS = _get_requirements(RYU_REQUIREMENTS_FILES) RYU_REQUIREMENTS = _get_requirements(RYU_REQUIREMENTS_FILES)

View File

@ -43,4 +43,5 @@ def get_host(app, dpid=None):
def get_all_host(app): def get_all_host(app):
return get_host(app) return get_host(app)
app_manager.require_app('ryu.topology.switches', api_style=True) app_manager.require_app('ryu.topology.switches', api_style=True)