python: Resolve a deprecation warning.
authorRussell Bryant <russell@ovn.org>
Tue, 22 Dec 2015 16:30:32 +0000 (11:30 -0500)
committerRussell Bryant <russell@ovn.org>
Tue, 5 Jan 2016 23:16:49 +0000 (18:16 -0500)
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 <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Makefile.am
tests/test-jsonrpc.py
tests/test-ovsdb.py
vtep/ovs-vtep

index beeb3d9..76cab14 100644 (file)
@@ -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
index 86db4aa..8ba0703 100644 (file)
@@ -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)
index f121a0c..e240208 100644 (file)
@@ -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))
index eb8e97b..07856c4 100755 (executable)
@@ -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: