From: Russell Bryant Date: Tue, 22 Dec 2015 16:30:32 +0000 (-0500) Subject: python: Resolve a deprecation warning. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=603e325fa56392a4a139ba00aff5dd416d1c512e python: Resolve a deprecation warning. Resolve the following deprecation warning. This deprecation warning advises to use an alternative syntax which is also compatible with Python 3, where has_key() was removed. W601 .has_key() is deprecated, use 'in' Also fix this related error: E713 test for membership should be 'not in' Signed-off-by: Russell Bryant Acked-by: Ben Pfaff --- diff --git a/Makefile.am b/Makefile.am index beeb3d9ab..76cab14ad 100644 --- a/Makefile.am +++ b/Makefile.am @@ -343,7 +343,7 @@ endif if HAVE_FLAKE8 ALL_LOCAL += flake8-check flake8-check: $(FLAKE8_PYFILES) - $(AM_V_GEN) if flake8 $^ --ignore=E111,E112,E113,E123,E126,E127,E128,E129,E131,E501,E502,E703,E713,W601 ${FLAKE8_FLAGS}; then touch $@; else exit 1; fi + $(AM_V_GEN) if flake8 $^ --ignore=E111,E112,E113,E123,E126,E127,E128,E129,E131,E501,E502,E703 ${FLAKE8_FLAGS}; then touch $@; else exit 1; fi endif include $(srcdir)/manpages.mk diff --git a/tests/test-jsonrpc.py b/tests/test-jsonrpc.py index 86db4aad9..8ba070359 100644 --- a/tests/test-jsonrpc.py +++ b/tests/test-jsonrpc.py @@ -86,7 +86,7 @@ def do_listen(name): if error: rpc.close() dead_rpcs.append(rpc) - rpcs = [rpc for rpc in rpcs if not rpc in dead_rpcs] + rpcs = [rpc for rpc in rpcs if rpc not in dead_rpcs] if done and not rpcs: break @@ -187,7 +187,7 @@ notify REMOTE METHOD PARAMS send notification and exit command_name = args.command[0] args = args.command_args - if not command_name in commands: + if command_name not in commands: sys.stderr.write("%s: unknown command \"%s\" " "(use --help for help)\n" % (argv[0], command_name)) sys.exit(1) diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py index f121a0c8b..e240208d4 100644 --- a/tests/test-ovsdb.py +++ b/tests/test-ovsdb.py @@ -587,7 +587,7 @@ def main(argv): command_name = args[0] args = args[1:] - if not command_name in commands: + if command_name not in commands: sys.stderr.write("%s: unknown command \"%s\" " "(use --help for help)\n" % (ovs.util.PROGRAM_NAME, command_name)) diff --git a/vtep/ovs-vtep b/vtep/ovs-vtep index eb8e97b1f..07856c410 100755 --- a/vtep/ovs-vtep +++ b/vtep/ovs-vtep @@ -286,7 +286,7 @@ class Logical_Switch(object): self.add_remote_mac(mac, remote_macs[mac]) for mac in self.remote_macs.keys(): - if not remote_macs.has_key(mac): + if mac not in remote_macs: self.del_remote_mac(mac) self.remote_macs = remote_macs @@ -587,7 +587,7 @@ def handle_physical(): ls = Lswitches[ls_name] new_bindings.add(binding) - if Bindings.has_key(binding): + if binding in Bindings: if Bindings[binding] == ls_name: continue else: