diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-12-15 10:50:15 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-12-17 19:27:42 +0900 |
commit | d64db265b38b253fbaf0f3342893830489d074c3 (patch) | |
tree | c009378d411cb1f0f798f59b9ff682ababace5b3 | |
parent | bdf3549563f0fa5e1985a30d12cb923861e40866 (diff) |
*: 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>
35 files changed, 47 insertions, 11 deletions
diff --git a/ryu/lib/addrconv.py b/ryu/lib/addrconv.py index 36a00fa2..bf069e04 100644 --- a/ryu/lib/addrconv.py +++ b/ryu/lib/addrconv.py @@ -40,6 +40,7 @@ class AddressConverter(object): return str(self._addr(self._strat.packed_to_int(bin), **self._addr_kwargs)) + ipv4 = AddressConverter(netaddr.IPAddress, netaddr.strategy.ipv4, fallback=netaddr.IPNetwork, version=4) ipv6 = AddressConverter(netaddr.IPAddress, netaddr.strategy.ipv6, @@ -48,5 +49,7 @@ ipv6 = AddressConverter(netaddr.IPAddress, netaddr.strategy.ipv6, class mac_mydialect(netaddr.mac_unix): word_fmt = '%.2x' + + mac = AddressConverter(netaddr.EUI, netaddr.strategy.eui48, version=48, dialect=mac_mydialect) diff --git a/ryu/lib/mrtlib.py b/ryu/lib/mrtlib.py index b6d76983..83b4e536 100644 --- a/ryu/lib/mrtlib.py +++ b/ryu/lib/mrtlib.py @@ -236,6 +236,7 @@ class UnknownMrtMessage(MrtMessage): def serialize(self): return self.buf + # Registers self to unknown(default) type UnknownMrtMessage._UNKNOWN_TYPE = UnknownMrtMessage @@ -298,6 +299,7 @@ class Ospf2MrtRecord(MrtCommonRecord): message=message, timestamp=timestamp, type_=type_, subtype=subtype, length=length) + # Registers self to unknown(default) type Ospf2MrtMessage._UNKNOWN_TYPE = Ospf2MrtMessage diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py index ccea4963..9e501515 100644 --- a/ryu/lib/packet/bgp.py +++ b/ryu/lib/packet/bgp.py @@ -565,6 +565,7 @@ class RouteFamily(StringifyMixin): def __hash__(self): return hash((self.afi, self.safi)) + # Route Family Singleton RF_IPv4_UC = RouteFamily(addr_family.IP, subaddr_family.UNICAST) RF_IPv6_UC = RouteFamily(addr_family.IP6, subaddr_family.UNICAST) diff --git a/ryu/lib/packet/ipv4.py b/ryu/lib/packet/ipv4.py index 2547f06a..83990719 100644 --- a/ryu/lib/packet/ipv4.py +++ b/ryu/lib/packet/ipv4.py @@ -142,6 +142,7 @@ class ipv4(packet_base.PacketBase): struct.pack_into('!H', hdr, 10, self.csum) return hdr + ipv4.register_packet_type(icmp.icmp, inet.IPPROTO_ICMP) ipv4.register_packet_type(igmp.igmp, inet.IPPROTO_IGMP) ipv4.register_packet_type(tcp.tcp, inet.IPPROTO_TCP) diff --git a/ryu/lib/packet/ipv6.py b/ryu/lib/packet/ipv6.py index 3ab3aacf..524a0864 100644 --- a/ryu/lib/packet/ipv6.py +++ b/ryu/lib/packet/ipv6.py @@ -143,6 +143,7 @@ class ipv6(packet_base.PacketBase): ext_hdrs_len += len(ext_hdr) return self._MIN_LEN + ext_hdrs_len + ipv6.register_packet_type(icmpv6.icmpv6, inet.IPPROTO_ICMPV6) ipv6.register_packet_type(tcp.tcp, inet.IPPROTO_TCP) ipv6.register_packet_type(udp.udp, inet.IPPROTO_UDP) diff --git a/ryu/lib/packet/ospf.py b/ryu/lib/packet/ospf.py index 398dd9c0..5c156c03 100644 --- a/ryu/lib/packet/ospf.py +++ b/ryu/lib/packet/ospf.py @@ -695,6 +695,7 @@ class OSPFMessage(packet_base.PacketBase, type_desc.TypeDisp): struct.pack_into("!H", buf, 12, csum) return buf + # alias ospf = OSPFMessage diff --git a/ryu/lib/packet/packet.py b/ryu/lib/packet/packet.py index 7de24c18..2db641b7 100644 --- a/ryu/lib/packet/packet.py +++ b/ryu/lib/packet/packet.py @@ -185,5 +185,6 @@ def _PacketBase__div__(self, trailer): pkt.add_protocol(trailer) return pkt + packet_base.PacketBase.__div__ = _PacketBase__div__ packet_base.PacketBase.__truediv__ = _PacketBase__div__ diff --git a/ryu/lib/packet/packet_utils.py b/ryu/lib/packet/packet_utils.py index 546b49cf..30259e31 100644 --- a/ryu/lib/packet/packet_utils.py +++ b/ryu/lib/packet/packet_utils.py @@ -99,6 +99,7 @@ def checksum_ip(ipvx, length, payload): buf = header + payload return checksum(buf) + _MODX = 4102 diff --git a/ryu/lib/type_desc.py b/ryu/lib/type_desc.py index 3e4061a5..415fb574 100644 --- a/ryu/lib/type_desc.py +++ b/ryu/lib/type_desc.py @@ -44,6 +44,7 @@ class IntDescr(TypeDescr): i //= 256 return binary + Int1 = IntDescr(1) Int2 = IntDescr(2) Int3 = IntDescr(3) @@ -91,6 +92,7 @@ class IntDescrMlt(TypeDescr): binary += b return binary + Int4Double = IntDescrMlt(4, 2) diff --git a/ryu/ofproto/nicira_ext.py b/ryu/ofproto/nicira_ext.py index 416c6256..9e0f8873 100644 --- a/ryu/ofproto/nicira_ext.py +++ b/ryu/ofproto/nicira_ext.py @@ -428,6 +428,7 @@ def nxm_nx_reg(idx): def nxm_nx_reg_w(idx): return nxm_header_w(0x0001, idx, 4) + NXM_HEADER_PACK_STRING = '!I' # diff --git a/ryu/ofproto/ofproto_v1_0_parser.py b/ryu/ofproto/ofproto_v1_0_parser.py index 4da5a072..c2a25988 100644 --- a/ryu/ofproto/ofproto_v1_0_parser.py +++ b/ryu/ofproto/ofproto_v1_0_parser.py @@ -822,6 +822,7 @@ class OFPActionVendor(OFPAction): msg_pack_into(ofproto.OFP_ACTION_VENDOR_HEADER_PACK_STR, buf, offset, self.type, self.len, self.vendor) + # OpenFlow1.2 or later compatible OFPActionExperimenter = OFPActionVendor diff --git a/ryu/ofproto/ofproto_v1_2.py b/ryu/ofproto/ofproto_v1_2.py index 9c8aa906..1c8a971d 100644 --- a/ryu/ofproto/ofproto_v1_2.py +++ b/ryu/ofproto/ofproto_v1_2.py @@ -792,6 +792,7 @@ def oxm_tlv_header_extract_length(header): length = header & 0xff return length + oxm_types = [ oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4), oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4), diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py index 9fedae26..d599c1cb 100644 --- a/ryu/ofproto/ofproto_v1_3.py +++ b/ryu/ofproto/ofproto_v1_3.py @@ -1180,6 +1180,7 @@ def oxm_tlv_header_extract_length(header): length = header & 0xff return length + oxm_types = [ oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4), oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4), diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py index d1c48225..d332817b 100644 --- a/ryu/ofproto/ofproto_v1_4.py +++ b/ryu/ofproto/ofproto_v1_4.py @@ -349,6 +349,7 @@ def oxm_tlv_header_extract_length(header): length = header & 0xff return length + oxm_types = [ oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4), oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4), diff --git a/ryu/ofproto/ofproto_v1_5.py b/ryu/ofproto/ofproto_v1_5.py index 83531845..b1544ac6 100644 --- a/ryu/ofproto/ofproto_v1_5.py +++ b/ryu/ofproto/ofproto_v1_5.py @@ -386,6 +386,7 @@ def oxm_tlv_header_extract_length(header): length = header & 0xff return length + oxm_types = [ oxm_fields.OpenFlowBasic('in_port', 0, 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): return header & 0xff + oxs_types = [ oxs_fields.OpenFlowBasic('duration', 0, type_desc.Int4Double), oxs_fields.OpenFlowBasic('idle_time', 1, type_desc.Int4Double), diff --git a/ryu/services/protocols/bgp/core_manager.py b/ryu/services/protocols/bgp/core_manager.py index fbee25f4..d61824c2 100644 --- a/ryu/services/protocols/bgp/core_manager.py +++ b/ryu/services/protocols/bgp/core_manager.py @@ -69,5 +69,6 @@ class _CoreManager(Activity): self._check_started() return self._vrfs_conf + # _CoreManager instance that manages core bgp service and configuration data. CORE_MANAGER = _CoreManager() diff --git a/ryu/services/protocols/bgp/info_base/l2vpnfs.py b/ryu/services/protocols/bgp/info_base/l2vpnfs.py index d612cc74..64b40fca 100644 --- a/ryu/services/protocols/bgp/info_base/l2vpnfs.py +++ b/ryu/services/protocols/bgp/info_base/l2vpnfs.py @@ -58,7 +58,7 @@ class L2VPNFlowSpecPath(VpnPath): # Set dummy IP address. kwargs['nexthop'] = '0.0.0.0' 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) self.VRF_PATH_CLASS = L2vpnFlowSpecPath # Because the L2VPN Flow Specification does not require nexthop, diff --git a/ryu/services/protocols/bgp/info_base/vpnv4fs.py b/ryu/services/protocols/bgp/info_base/vpnv4fs.py index e87196c2..64511444 100644 --- a/ryu/services/protocols/bgp/info_base/vpnv4fs.py +++ b/ryu/services/protocols/bgp/info_base/vpnv4fs.py @@ -58,7 +58,7 @@ class VPNv4FlowSpecPath(VpnPath): # Set dummy IP address. kwargs['nexthop'] = '0.0.0.0' 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) self.VRF_PATH_CLASS = Vrf4FlowSpecPath # Because the IPv4 Flow Specification does not require nexthop, diff --git a/ryu/services/protocols/bgp/info_base/vpnv6fs.py b/ryu/services/protocols/bgp/info_base/vpnv6fs.py index 8f2a5dc3..5078442e 100644 --- a/ryu/services/protocols/bgp/info_base/vpnv6fs.py +++ b/ryu/services/protocols/bgp/info_base/vpnv6fs.py @@ -58,7 +58,7 @@ class VPNv6FlowSpecPath(VpnPath): # Set dummy IP address. kwargs['nexthop'] = '::' 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) self.VRF_PATH_CLASS = Vrf6FlowSpecPath # Because the IPv6 Flow Specification does not require nexthop, diff --git a/ryu/services/protocols/bgp/operator/ssh.py b/ryu/services/protocols/bgp/operator/ssh.py index cb2f63b4..5690f674 100644 --- a/ryu/services/protocols/bgp/operator/ssh.py +++ b/ryu/services/protocols/bgp/operator/ssh.py @@ -516,4 +516,5 @@ class Cli(Activity): server = hub.StreamServer(listen_info, ssh_server_factory) server.serve_forever() + SSH_CLI_CONTROLLER = Cli() diff --git a/ryu/services/protocols/bgp/operator/views/bgp.py b/ryu/services/protocols/bgp/operator/views/bgp.py index b116ee1d..9309e6c3 100644 --- a/ryu/services/protocols/bgp/operator/views/bgp.py +++ b/ryu/services/protocols/bgp/operator/views/bgp.py @@ -278,9 +278,11 @@ class RouteFamilyView(OperatorDetailView): afi = fields.DataField('afi') safi = fields.DataField('safi') + ################################################################## # Declarations of list and dict views based on detail views above ################################################################## + PeerListView = create_list_view_class(PeerDetailView, 'PeerListView') PeerDictView = create_dict_view_class(PeerDetailView, 'PeerDictView') diff --git a/ryu/services/protocols/bgp/processor.py b/ryu/services/protocols/bgp/processor.py index c65e9b82..789192ea 100644 --- a/ryu/services/protocols/bgp/processor.py +++ b/ryu/services/protocols/bgp/processor.py @@ -154,6 +154,7 @@ class BgpProcessor(Activity): # Wake-up processing thread if sleeping. self.dest_que_evt.set() + # ============================================================================= # Best path computation related utilities. # ============================================================================= diff --git a/ryu/services/protocols/bgp/rtconf/neighbors.py b/ryu/services/protocols/bgp/rtconf/neighbors.py index 8ebd1f50..86e04b39 100644 --- a/ryu/services/protocols/bgp/rtconf/neighbors.py +++ b/ryu/services/protocols/bgp/rtconf/neighbors.py @@ -224,6 +224,7 @@ def valid_prefix_filter(filter_): le = filter_.get('le', None) return PrefixFilter(prefix, policy, ge=ge, le=le) + PREFIX_FILTER = 'prefix_filter' SUPPORTED_FILTER_VALIDATORS = { diff --git a/ryu/services/protocols/zebra/db/base.py b/ryu/services/protocols/zebra/db/base.py index 0e20b70d..deda9916 100644 --- a/ryu/services/protocols/zebra/db/base.py +++ b/ryu/services/protocols/zebra/db/base.py @@ -35,6 +35,7 @@ def _repr(self): for k, v in self.__dict__.items() if not k.startswith('_')]) return "%s(%s)" % (self.__class__.__name__, m) + Base.__repr__ = _repr diff --git a/ryu/tests/packet_data_generator3/gen.py b/ryu/tests/packet_data_generator3/gen.py index cab3e805..aa5c2b7d 100644 --- a/ryu/tests/packet_data_generator3/gen.py +++ b/ryu/tests/packet_data_generator3/gen.py @@ -292,6 +292,7 @@ class MyHandler(socketserver.BaseRequestHandler): class MyVerboseHandler(MyHandler): verbose = True + if __name__ == '__main__': optlist, args = getopt.getopt(sys.argv[1:], 'dvo:') debug = False diff --git a/ryu/tests/unit/app/test_ofctl_rest.py b/ryu/tests/unit/app/test_ofctl_rest.py index 5b7a5be7..4d09821e 100644 --- a/ryu/tests/unit/app/test_ofctl_rest.py +++ b/ryu/tests/unit/app/test_ofctl_rest.py @@ -131,6 +131,7 @@ def _add_tests(): ) test_lib.add_method(Test_ofctl_rest, name, f) + _add_tests() if __name__ == "__main__": diff --git a/ryu/tests/unit/app/test_ws_topology.py b/ryu/tests/unit/app/test_ws_topology.py index 6eaaa0e5..6078ff7c 100644 --- a/ryu/tests/unit/app/test_ws_topology.py +++ b/ryu/tests/unit/app/test_ws_topology.py @@ -50,5 +50,6 @@ class Test_ws_topology(unittest.TestCase): rpc_client_mock1.get_proxy.assert_called_once_with() rpc_client_mock2.get_proxy.assert_called_once_with() + if __name__ == "__main__": unittest.main() diff --git a/ryu/tests/unit/ofproto/test_parser.py b/ryu/tests/unit/ofproto/test_parser.py index 081500ad..817ebc3c 100644 --- a/ryu/tests/unit/ofproto/test_parser.py +++ b/ryu/tests/unit/ofproto/test_parser.py @@ -307,4 +307,5 @@ def _add_tests(): assert (cases == set(unittest.defaultTestLoader.getTestCaseNames(Test_Parser))) + _add_tests() diff --git a/ryu/tests/unit/ofproto/test_parser_compat.py b/ryu/tests/unit/ofproto/test_parser_compat.py index dcca56bd..08be7583 100644 --- a/ryu/tests/unit/ofproto/test_parser_compat.py +++ b/ryu/tests/unit/ofproto/test_parser_compat.py @@ -157,4 +157,5 @@ def _add_tests(): ofpp=ofpp) test_lib.add_method(Test_Parser_Compat, method_name, f) + _add_tests() diff --git a/ryu/tests/unit/ofproto/test_parser_ofpmatch.py b/ryu/tests/unit/ofproto/test_parser_ofpmatch.py index d4dba9ea..bafcc2a9 100644 --- a/ryu/tests/unit/ofproto/test_parser_ofpmatch.py +++ b/ryu/tests/unit/ofproto/test_parser_ofpmatch.py @@ -287,4 +287,5 @@ def _add_tests(): test_lib.add_method(Test_Parser_OFPMatch, method_name, f) + _add_tests() diff --git a/ryu/tests/unit/ofproto/test_parser_ofpstats.py b/ryu/tests/unit/ofproto/test_parser_ofpstats.py index 0ce428ab..b14bb9de 100644 --- a/ryu/tests/unit/ofproto/test_parser_ofpstats.py +++ b/ryu/tests/unit/ofproto/test_parser_ofpstats.py @@ -204,4 +204,5 @@ def _add_tests(): test_lib.add_method(Test_Parser_OFPStats, method_name, f) + _add_tests() diff --git a/ryu/tests/unit/packet/test_ipv6.py b/ryu/tests/unit/packet/test_ipv6.py index 455dc8c3..e62ba042 100644 --- a/ryu/tests/unit/packet/test_ipv6.py +++ b/ryu/tests/unit/packet/test_ipv6.py @@ -795,13 +795,13 @@ class Test_routing(unittest.TestCase): not_implemented_buf = struct.pack( '!BBBBBB2x', 0, 6, ipv6.routing.ROUTING_TYPE_2, 0, 0, 0) instance = ipv6.routing.parser(not_implemented_buf) - assert None == instance + assert None is instance def test_invalid_type(self): invalid_type = 99 invalid_buf = struct.pack('!BBBBBB2x', 0, 6, invalid_type, 0, 0, 0) instance = ipv6.routing.parser(invalid_buf) - assert None == instance + assert None is instance class Test_routing_type3(unittest.TestCase): diff --git a/ryu/tests/unit/packet/test_slow.py b/ryu/tests/unit/packet/test_slow.py index 9e077fd2..3ce9d450 100644 --- a/ryu/tests/unit/packet/test_slow.py +++ b/ryu/tests/unit/packet/test_slow.py @@ -147,16 +147,16 @@ class Test_slow(unittest.TestCase): not_implemented_buf = pack( slow._PACK_STR, SLOW_SUBTYPE_MARKER) + self.buf[1:] (instance, nexttype, last) = slow.parser(not_implemented_buf) - assert None == instance - assert None == nexttype - assert None != last + assert instance is None + assert nexttype is None + assert last is not None def test_invalid_subtype(self): invalid_buf = b'\xff' + self.buf[1:] (instance, nexttype, last) = slow.parser(invalid_buf) - assert None == instance - assert None == nexttype - assert None != last + assert instance is None + assert nexttype is None + assert last is not None class Test_lacp(unittest.TestCase): diff --git a/ryu/tests/unit/test_requirements.py b/ryu/tests/unit/test_requirements.py index 7bfbd3f4..9f50a518 100644 --- a/ryu/tests/unit/test_requirements.py +++ b/ryu/tests/unit/test_requirements.py @@ -57,6 +57,7 @@ def _get_requirements(files): return requirements + OPENSTACK_REQUIREMENTS = _get_requirements(OPENSTACK_REQUIREMENTS_FILES) RYU_REQUIREMENTS = _get_requirements(RYU_REQUIREMENTS_FILES) diff --git a/ryu/topology/api.py b/ryu/topology/api.py index cd72b84b..e4fb2f1c 100644 --- a/ryu/topology/api.py +++ b/ryu/topology/api.py @@ -43,4 +43,5 @@ def get_host(app, dpid=None): def get_all_host(app): return get_host(app) + app_manager.require_app('ryu.topology.switches', api_style=True) |