PEP8: fix W601: .has_key() is deprecated, use 'in'
authorJoe Guo <joeg@catalyst.net.nz>
Mon, 30 Jul 2018 04:43:51 +0000 (16:43 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Fri, 24 Aug 2018 05:49:25 +0000 (07:49 +0200)
Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/provision/__init__.py
python/samba/provision/sambadns.py
source4/script/depfilter.py

index 2b3b7fc07f27b7670d40e4bfa235b89939cd11a6..26d11a59ded04f4c4cf85ceb1d1edbfba31da172 100644 (file)
@@ -2371,7 +2371,7 @@ def provision(logger, session_info, smbconf=None,
                 os.chmod(paths.binddns_dir, 0o770)
                 os.chown(paths.binddns_dir, -1, paths.bind_gid)
             except OSError:
                 os.chmod(paths.binddns_dir, 0o770)
                 os.chown(paths.binddns_dir, -1, paths.bind_gid)
             except OSError:
-                if not os.environ.has_key('SAMBA_SELFTEST'):
+                if 'SAMBA_SELFTEST' not in os.environ:
                     logger.info("Failed to chown %s to bind gid %u",
                                 paths.binddns_dir, paths.bind_gid)
 
                     logger.info("Failed to chown %s to bind gid %u",
                                 paths.binddns_dir, paths.bind_gid)
 
@@ -2379,7 +2379,7 @@ def provision(logger, session_info, smbconf=None,
                 os.chmod(bind_dns_keytab_path, 0o640)
                 os.chown(bind_dns_keytab_path, -1, paths.bind_gid)
             except OSError:
                 os.chmod(bind_dns_keytab_path, 0o640)
                 os.chown(bind_dns_keytab_path, -1, paths.bind_gid)
             except OSError:
-                if not os.environ.has_key('SAMBA_SELFTEST'):
+                if 'SAMBA_SELFTEST' not in os.environ:
                     logger.info("Failed to chown %s to bind gid %u",
                                 bind_dns_keytab_path, paths.bind_gid)
 
                     logger.info("Failed to chown %s to bind gid %u",
                                 bind_dns_keytab_path, paths.bind_gid)
 
index a04d8b83ddbe0d8e2da6aace962f1a06fbb3959b..17f7640526936186cb7f4a3e8fd9a8fad1b8492c 100644 (file)
@@ -704,7 +704,7 @@ def create_dns_dir(logger, paths):
             # chmod needed to cope with umask
             os.chmod(dns_dir, 0o770)
         except OSError:
             # chmod needed to cope with umask
             os.chmod(dns_dir, 0o770)
         except OSError:
-            if not os.environ.has_key('SAMBA_SELFTEST'):
+            if 'SAMBA_SELFTEST' not in os.environ:
                 logger.error("Failed to chown %s to bind gid %u" % (
                     dns_dir, paths.bind_gid))
 
                 logger.error("Failed to chown %s to bind gid %u" % (
                     dns_dir, paths.bind_gid))
 
@@ -771,7 +771,7 @@ def create_zone_file(lp, logger, paths, targetdir, dnsdomain,
             # chmod needed to cope with umask
             os.chmod(paths.dns, 0o664)
         except OSError:
             # chmod needed to cope with umask
             os.chmod(paths.dns, 0o664)
         except OSError:
-            if not os.environ.has_key('SAMBA_SELFTEST'):
+            if 'SAMBA_SELFTEST' not in os.environ:
                 logger.error("Failed to chown %s to bind gid %u" % (
                     paths.dns, paths.bind_gid))
 
                 logger.error("Failed to chown %s to bind gid %u" % (
                     paths.dns, paths.bind_gid))
 
@@ -896,11 +896,11 @@ def create_samdb_copy(samdb, logger, paths, names, domainsid, domainguid):
                         os.chown(fpath, -1, paths.bind_gid)
                         os.chmod(fpath, 0o660)
         except OSError:
                         os.chown(fpath, -1, paths.bind_gid)
                         os.chmod(fpath, 0o660)
         except OSError:
-            if not os.environ.has_key('SAMBA_SELFTEST'):
+            if 'SAMBA_SELFTEST' not in os.environ:
                 logger.error(
                     "Failed to set permissions to sam.ldb* files, fix manually")
     else:
                 logger.error(
                     "Failed to set permissions to sam.ldb* files, fix manually")
     else:
-        if not os.environ.has_key('SAMBA_SELFTEST'):
+        if 'SAMBA_SELFTEST' not in os.environ:
             logger.warning("""Unable to find group id for BIND,
                 set permissions to sam.ldb* files manually""")
 
             logger.warning("""Unable to find group id for BIND,
                 set permissions to sam.ldb* files manually""")
 
index a82dffc1746e2bd4584e92206108194f72f2f7e4..c74298dd8d3d912bfa6cad6eaff7c528045309fd 100755 (executable)
@@ -24,7 +24,7 @@ graph = {}
 for arc in lines[1:-1]:
     match = sre.search('"(.*)" -> "(.*)"', arc)
     n1, n2 = match.group(1), match.group(2)
 for arc in lines[1:-1]:
     match = sre.search('"(.*)" -> "(.*)"', arc)
     n1, n2 = match.group(1), match.group(2)
-    if not graph.has_key(n1):
+    if n1 not in graph:
         graph[n1] = []
     graph[n1].append(n2)
 
         graph[n1] = []
     graph[n1].append(n2)
 
@@ -33,7 +33,7 @@ for arc in lines[1:-1]:
 subgraph = {}
 
 def add_deps(node):
 subgraph = {}
 
 def add_deps(node):
-    if graph.has_key(node) and not subgraph.has_key(node):
+    if node in graph and node not in subgraph:
         subgraph[node] = graph[node]
         for n in graph[node]:
             add_deps(n)
         subgraph[node] = graph[node]
         for n in graph[node]:
             add_deps(n)