From: Joe Guo Date: Mon, 30 Jul 2018 06:22:34 +0000 (+1200) Subject: PEP8: fix E713: test for membership should be 'not in' X-Git-Tag: tdb-1.3.17~2047 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f5bbcc10a82f409f41cce5685458332674e2010;p=thirdparty%2Fsamba.git PEP8: fix E713: test for membership should be 'not in' Signed-off-by: Joe Guo Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/lib/ldb-samba/tests/match_rules.py b/lib/ldb-samba/tests/match_rules.py index aaa9675c196..7c472816f8d 100755 --- a/lib/ldb-samba/tests/match_rules.py +++ b/lib/ldb-samba/tests/match_rules.py @@ -1774,7 +1774,7 @@ host = args[0] lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) -if not "://" in host: +if "://" not in host: if os.path.isfile(host): host = "tdb://%s" % host else: diff --git a/python/samba/__init__.py b/python/samba/__init__.py index c95b2fe3e26..291ef541189 100644 --- a/python/samba/__init__.py +++ b/python/samba/__init__.py @@ -340,7 +340,7 @@ def import_bundled_package(modulename, location, source_tree_container, if in_source_tree(): extra_path = os.path.join(source_tree_topdir(), source_tree_container, location) - if not extra_path in sys.path: + if extra_path not in sys.path: sys.path.insert(0, extra_path) sys.modules[modulename] = __import__(modulename) else: diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py index dfdbcf46655..ae93ed1c72f 100644 --- a/python/samba/dbchecker.py +++ b/python/samba/dbchecker.py @@ -1232,7 +1232,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base))) is_deleted = 'isDeleted' in obj and obj['isDeleted'][0].upper() == 'TRUE' target_is_deleted = 'isDeleted' in res[0] and res[0]['isDeleted'][0].upper() == 'TRUE' - if is_deleted and not obj.dn in self.deleted_objects_containers and linkID: + if is_deleted and obj.dn not in self.deleted_objects_containers and linkID: # A fully deleted object should not have any linked # attributes. (MS-ADTS 3.1.1.5.5.1.1 Tombstone # Requirements and 3.1.1.5.5.1.3 Recycled-Object @@ -2470,7 +2470,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base))) error_count = 0 # check that the dsServiceName is in GUID form - if not 'dsServiceName' in obj: + if 'dsServiceName' not in obj: self.report('ERROR: dsServiceName missing in @ROOTDSE') return error_count + 1 diff --git a/python/samba/gpclass.py b/python/samba/gpclass.py index 22f57c0dd95..8fb2f9344a6 100644 --- a/python/samba/gpclass.py +++ b/python/samba/gpclass.py @@ -448,7 +448,7 @@ def check_safe_path(path): dirs = re.split('/|\\\\', path) if 'sysvol' in path: dirs = dirs[dirs.index('sysvol') + 1:] - if not '..' in dirs: + if '..' not in dirs: return os.path.join(*dirs) raise OSError(path) @@ -567,7 +567,7 @@ def register_gp_extension(guid, name, path, return False lp, parser = parse_gpext_conf(smb_conf) - if not guid in parser.sections(): + if guid not in parser.sections(): parser.add_section(guid) parser.set(guid, 'DllName', path) parser.set(guid, 'ProcessGroupPolicy', name) diff --git a/python/samba/join.py b/python/samba/join.py index 66097b9c596..44bad58c9f4 100644 --- a/python/samba/join.py +++ b/python/samba/join.py @@ -381,7 +381,7 @@ class DCJoinContext(object): '''get the parent domain partition DN from parent DNS name''' res = ctx.samdb.search(base='CN=Partitions,%s' % ctx.config_dn, attrs=['fSMORoleOwner'], scope=ldb.SCOPE_BASE, controls=["extended_dn:1:1"]) - if not 'fSMORoleOwner' in res[0]: + if 'fSMORoleOwner' not in res[0]: raise DCJoinException("Can't find naming master on partition DN %s in %s" % (ctx.partition_dn, ctx.samdb.url)) try: master_guid = str(misc.GUID(ldb.Dn(ctx.samdb, res[0]['fSMORoleOwner'][0].decode('utf8')).get_extended_component('GUID'))) diff --git a/python/samba/kcc/__init__.py b/python/samba/kcc/__init__.py index 8bb9a3904bb..5e1762d5b6f 100644 --- a/python/samba/kcc/__init__.py +++ b/python/samba/kcc/__init__.py @@ -2056,7 +2056,7 @@ class KCC(object): for dc_s in self.my_site.dsa_table.values(): # If this partition (nc_x) doesn't appear as a # replica (f_of_x) on (dc_s) then continue - if not nc_x.nc_dnstr in dc_s.current_rep_table: + if nc_x.nc_dnstr not in dc_s.current_rep_table: continue # Pull out the NCReplica (f) of (x) with the dn @@ -2138,7 +2138,7 @@ class KCC(object): # If this partition NC (x) doesn't appear as a # replica (p) of NC (x) on the dsa DC (s) then # continue - if not nc_x.nc_dnstr in dc_s.current_rep_table: + if nc_x.nc_dnstr not in dc_s.current_rep_table: continue # Pull out the NCReplica with the dn that diff --git a/python/samba/kcc/kcc_utils.py b/python/samba/kcc/kcc_utils.py index a1dda6b5e02..c099140c936 100644 --- a/python/samba/kcc/kcc_utils.py +++ b/python/samba/kcc/kcc_utils.py @@ -744,7 +744,7 @@ class DirectoryServiceAgent(object): flags = dsdn.get_binary_integer() dnstr = str(dsdn.dn) - if not dnstr in tmp_table: + if dnstr not in tmp_table: rep = NCReplica(self, dnstr) tmp_table[dnstr] = rep else: diff --git a/python/samba/netcmd/dbcheck.py b/python/samba/netcmd/dbcheck.py index 3a940bf6d6a..6369e7fbb09 100644 --- a/python/samba/netcmd/dbcheck.py +++ b/python/samba/netcmd/dbcheck.py @@ -110,7 +110,7 @@ class cmd_dbcheck(Command): scope_map = {"SUB": ldb.SCOPE_SUBTREE, "BASE": ldb.SCOPE_BASE, "ONE": ldb.SCOPE_ONELEVEL} scope = scope.upper() - if not scope in scope_map: + if scope not in scope_map: raise CommandError("Unknown scope %s" % scope) search_scope = scope_map[scope] diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py index bcd9c63150b..635b197eb19 100644 --- a/python/samba/netcmd/ldapcmp.py +++ b/python/samba/netcmd/ldapcmp.py @@ -49,7 +49,7 @@ class LDAPBase(object): outf=sys.stdout, errf=sys.stderr, skip_missing_dn=True): ldb_options = [] samdb_url = host - if not "://" in host: + if "://" not in host: if os.path.isfile(host): samdb_url = "tdb://%s" % host else: @@ -580,7 +580,7 @@ class LDAPObject(object): # title = 4 * " " + "Attributes found only in %s:" % self.con.host for x in self.attributes.keys(): - if not x in other.attributes.keys() and \ + if x not in other.attributes.keys() and \ not x.upper() in [q.upper() for q in other.ignore_attributes]: if title: res += title + "\n" @@ -590,7 +590,7 @@ class LDAPObject(object): # title = 4 *" " + "Attributes found only in %s:" % other.con.host for x in other.attributes.keys(): - if not x in self.attributes.keys() and \ + if x not in self.attributes.keys() and \ not x.upper() in [q.upper() for q in self.ignore_attributes]: if title: res += title + "\n" diff --git a/python/samba/samba3/__init__.py b/python/samba/samba3/__init__.py index 1f8c5100bcb..78588e0c349 100644 --- a/python/samba/samba3/__init__.py +++ b/python/samba/samba3/__init__.py @@ -337,7 +337,7 @@ class WinsDatabase(object): ips.append(entries[i]) i += 1 nb_flags = int(entries[i][:-1], 16) - assert not name in self.entries, "Name %s exists twice" % name + assert name not in self.entries, "Name %s exists twice" % name self.entries[name] = (ttl, ips, nb_flags) f.close() diff --git a/python/samba/samdb.py b/python/samba/samdb.py index 50c4821f542..e91cf6516e7 100644 --- a/python/samba/samdb.py +++ b/python/samba/samdb.py @@ -929,7 +929,7 @@ schemaUpdateNow: 1 res = self.search(self.domain_dn(), scope=ldb.SCOPE_BASE, attrs=["minPwdAge"]) if len(res) == 0: return None - elif not "minPwdAge" in res[0]: + elif "minPwdAge" not in res[0]: return None else: return int(res[0]["minPwdAge"][0]) @@ -945,7 +945,7 @@ schemaUpdateNow: 1 res = self.search(self.domain_dn(), scope=ldb.SCOPE_BASE, attrs=["maxPwdAge"]) if len(res) == 0: return None - elif not "maxPwdAge" in res[0]: + elif "maxPwdAge" not in res[0]: return None else: return int(res[0]["maxPwdAge"][0]) @@ -961,7 +961,7 @@ schemaUpdateNow: 1 res = self.search(self.domain_dn(), scope=ldb.SCOPE_BASE, attrs=["minPwdLength"]) if len(res) == 0: return None - elif not "minPwdLength" in res[0]: + elif "minPwdLength" not in res[0]: return None else: return int(res[0]["minPwdLength"][0]) @@ -977,7 +977,7 @@ schemaUpdateNow: 1 res = self.search(self.domain_dn(), scope=ldb.SCOPE_BASE, attrs=["pwdProperties"]) if len(res) == 0: return None - elif not "pwdProperties" in res[0]: + elif "pwdProperties" not in res[0]: return None else: return int(res[0]["pwdProperties"][0]) diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index b3fccee8383..870258a6fb9 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -417,7 +417,7 @@ def connect_samdb(samdb_url, lp=None, session_info=None, credentials=None, to make proper URL for ldb.connect() while using default parameters for connection based on test environment """ - if not "://" in samdb_url: + if "://" not in samdb_url: if not ldap_only and os.path.isfile(samdb_url): samdb_url = "tdb://%s" % samdb_url else: diff --git a/python/samba/tests/samba3sam.py b/python/samba/tests/samba3sam.py index 5223e7cee60..bb8eff26a90 100644 --- a/python/samba/tests/samba3sam.py +++ b/python/samba/tests/samba3sam.py @@ -285,7 +285,7 @@ delete: description # Checking whether changes are no longer there... msg = self.ldb.search(expression="(cn=Niemand)") self.assertTrue(len(msg) >= 1) - self.assertTrue(not "description" in msg[0]) + self.assertTrue("description" not in msg[0]) # Renaming record... self.ldb.rename("cn=Niemand,cn=Users,dc=vernstok,dc=nl", @@ -411,7 +411,7 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") # Search remote record by remote DN @@ -420,8 +420,8 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 attrs=["dnsHostName", "lastLogon", "sambaLogonTime"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn) - self.assertTrue(not "dnsHostName" in res[0]) - self.assertTrue(not "lastLogon" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) + self.assertTrue("lastLogon" not in res[0]) self.assertEquals(str(res[0]["sambaLogonTime"]), "x") # Search split record by local DN @@ -439,8 +439,8 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 attrs=["dnsHostName", "lastLogon", "sambaLogonTime"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn) - self.assertTrue(not "dnsHostName" in res[0]) - self.assertTrue(not "lastLogon" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) + self.assertTrue("lastLogon" not in res[0]) self.assertEquals(str(res[0]["sambaLogonTime"]), "x") # Testing search by attribute @@ -463,7 +463,7 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 2) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=C")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "z") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=Z")) self.assertEquals(str(res[1]["dnsHostName"]), "z") @@ -475,10 +475,10 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 2) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=B")) - self.assertTrue(not "dnsHostName" in res[1]) + self.assertTrue("dnsHostName" not in res[1]) self.assertEquals(str(res[1]["lastLogon"]), "y") # Search by converted attribute @@ -496,7 +496,7 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 res[1]["objectSid"]) self.assertTrue("objectSid" in res[1]) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertSidEquals("S-1-5-21-4231626423-2410014848-2360679739-1052", res[0]["objectSid"]) @@ -509,7 +509,7 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 attrs=["dnsHostName", "lastLogon", "primaryGroupID"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(str(res[0]["primaryGroupID"]), "512") @@ -535,7 +535,7 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 2) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(str(res[0]["objectClass"][0]), "user") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=X")) @@ -549,11 +549,11 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 3) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(res[0]["objectClass"][0], "user") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=B")) - self.assertTrue(not "dnsHostName" in res[1]) + self.assertTrue("dnsHostName" not in res[1]) self.assertEquals(str(res[1]["lastLogon"]), "y") self.assertEquals(set(res[1]["objectClass"]), set(["top"])) self.assertEquals(str(res[2].dn), self.samba4.dn("cn=X")) @@ -581,7 +581,7 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 2) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=X")) self.assertEquals(str(res[1]["dnsHostName"]), "x") @@ -661,13 +661,13 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 6) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=B")) - self.assertTrue(not "dnsHostName" in res[1]) + self.assertTrue("dnsHostName" not in res[1]) self.assertEquals(str(res[1]["lastLogon"]), "y") self.assertEquals(str(res[2].dn), self.samba4.dn("cn=C")) - self.assertTrue(not "dnsHostName" in res[2]) + self.assertTrue("dnsHostName" not in res[2]) self.assertEquals(str(res[2]["lastLogon"]), "z") self.assertEquals(str(res[3].dn), self.samba4.dn("cn=Z")) self.assertEquals(str(res[3]["dnsHostName"]), "z") @@ -679,7 +679,7 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 4) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=C")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "z") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=Z")) self.assertEquals(str(res[1]["dnsHostName"]), "z") @@ -691,13 +691,13 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 6) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=B")) - self.assertTrue(not "dnsHostName" in res[1]) + self.assertTrue("dnsHostName" not in res[1]) self.assertEquals(str(res[1]["lastLogon"]), "y") self.assertEquals(str(res[2].dn), self.samba4.dn("cn=C")) - self.assertTrue(not "dnsHostName" in res[2]) + self.assertTrue("dnsHostName" not in res[2]) self.assertEquals(str(res[2]["lastLogon"]), "z") self.assertEquals(str(res[3].dn), self.samba4.dn("cn=Z")) self.assertEquals(str(res[3]["dnsHostName"]), "z") @@ -709,10 +709,10 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 6) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=B")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "y") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=C")) - self.assertTrue(not "dnsHostName" in res[1]) + self.assertTrue("dnsHostName" not in res[1]) self.assertEquals(str(res[1]["lastLogon"]), "z") self.assertEquals(str(res[2].dn), self.samba4.dn("cn=Y")) self.assertEquals(str(res[2]["dnsHostName"]), "y") @@ -727,13 +727,13 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 6) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=B")) - self.assertTrue(not "dnsHostName" in res[1]) + self.assertTrue("dnsHostName" not in res[1]) self.assertEquals(str(res[1]["lastLogon"]), "y") self.assertEquals(str(res[2].dn), self.samba4.dn("cn=C")) - self.assertTrue(not "dnsHostName" in res[2]) + self.assertTrue("dnsHostName" not in res[2]) self.assertEquals(str(res[2]["lastLogon"]), "z") self.assertEquals(str(res[3].dn), self.samba4.dn("cn=Z")) self.assertEquals(str(res[3]["dnsHostName"]), "z") @@ -744,13 +744,13 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 attrs=["dnsHostName", "lastLogon"]) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=B")) - self.assertTrue(not "dnsHostName" in res[1]) + self.assertTrue("dnsHostName" not in res[1]) self.assertEquals(str(res[1]["lastLogon"]), "y") self.assertEquals(str(res[2].dn), self.samba4.dn("cn=C")) - self.assertTrue(not "dnsHostName" in res[2]) + self.assertTrue("dnsHostName" not in res[2]) self.assertEquals(str(res[2]["lastLogon"]), "z") self.assertEquals(str(res[3].dn), self.samba4.dn("cn=Z")) self.assertEquals(str(res[3]["dnsHostName"]), "z") @@ -762,7 +762,7 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 5) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=C")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "z") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=Y")) self.assertEquals(str(res[1]["dnsHostName"]), "y") @@ -777,10 +777,10 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 5) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=C")) - self.assertTrue(not "dnsHostName" in res[1]) + self.assertTrue("dnsHostName" not in res[1]) self.assertEquals(str(res[1]["lastLogon"]), "z") self.assertEquals(str(res[2].dn), self.samba4.dn("cn=Z")) self.assertEquals(str(res[2]["dnsHostName"]), "z") @@ -791,13 +791,13 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(len(res), 7) res = sorted(res, key=attrgetter('dn')) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) - self.assertTrue(not "dnsHostName" in res[0]) + self.assertTrue("dnsHostName" not in res[0]) self.assertEquals(str(res[0]["lastLogon"]), "x") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=B")) - self.assertTrue(not "dnsHostName" in res[1]) + self.assertTrue("dnsHostName" not in res[1]) self.assertEquals(str(res[1]["lastLogon"]), "y") self.assertEquals(str(res[2].dn), self.samba4.dn("cn=C")) - self.assertTrue(not "dnsHostName" in res[2]) + self.assertTrue("dnsHostName" not in res[2]) self.assertEquals(str(res[2]["lastLogon"]), "z") self.assertEquals(str(res[3].dn), self.samba4.dn("cn=X")) self.assertEquals(str(res[3]["dnsHostName"]), "x") @@ -991,12 +991,12 @@ description: test self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn2) self.assertEquals(str(res[0]["description"]), "test") - self.assertTrue(not "revision" in res[0]) + self.assertTrue("revision" not in res[0]) # Check in local db res = self.samba4.db.search(dn, scope=SCOPE_BASE, attrs=attrs) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn) - self.assertTrue(not "description" in res[0]) + self.assertTrue("description" not in res[0]) self.assertEquals(str(res[0]["revision"]), "1") # Delete (newly) split record @@ -1027,9 +1027,9 @@ description: test res = self.samba4.db.search(dn, scope=SCOPE_BASE, attrs=attrs) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn) - self.assertTrue(not "description" in res[0]) - self.assertTrue(not "badPwdCount" in res[0]) - self.assertTrue(not "nextRid" in res[0]) + self.assertTrue("description" not in res[0]) + self.assertTrue("badPwdCount" not in res[0]) + self.assertTrue("nextRid" not in res[0]) self.assertEquals(str(res[0]["revision"]), "1") # Check in remote db attrs = ["description", "sambaBadPasswordCount", "sambaNextRid", @@ -1040,7 +1040,7 @@ description: test self.assertEquals(str(res[0]["description"]), "foo") self.assertEquals(str(res[0]["sambaBadPasswordCount"]), "3") self.assertEquals(str(res[0]["sambaNextRid"]), "1001") - self.assertTrue(not "revision" in res[0]) + self.assertTrue("revision" not in res[0]) # Modify of split record ldif = """ @@ -1066,9 +1066,9 @@ revision: 2 res = self.samba4.db.search(dn, scope=SCOPE_BASE, attrs=attrs) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn) - self.assertTrue(not "description" in res[0]) - self.assertTrue(not "badPwdCount" in res[0]) - self.assertTrue(not "nextRid" in res[0]) + self.assertTrue("description" not in res[0]) + self.assertTrue("badPwdCount" not in res[0]) + self.assertTrue("nextRid" not in res[0]) self.assertEquals(str(res[0]["revision"]), "2") # Check in remote db attrs = ["description", "sambaBadPasswordCount", "sambaNextRid", @@ -1079,7 +1079,7 @@ revision: 2 self.assertEquals(str(res[0]["description"]), "test") self.assertEquals(str(res[0]["sambaBadPasswordCount"]), "4") self.assertEquals(str(res[0]["sambaNextRid"]), "1001") - self.assertTrue(not "revision" in res[0]) + self.assertTrue("revision" not in res[0]) # Rename split record dn2 = self.samba4.dn("cn=toast") @@ -1098,9 +1098,9 @@ revision: 2 res = self.samba4.db.search(dn, scope=SCOPE_BASE, attrs=attrs) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn) - self.assertTrue(not "description" in res[0]) - self.assertTrue(not "badPwdCount" in res[0]) - self.assertTrue(not "nextRid" in res[0]) + self.assertTrue("description" not in res[0]) + self.assertTrue("badPwdCount" not in res[0]) + self.assertTrue("nextRid" not in res[0]) self.assertEquals(str(res[0]["revision"]), "2") # Check in remote db dn2 = self.samba3.dn("cn=toast") @@ -1112,7 +1112,7 @@ revision: 2 self.assertEquals(str(res[0]["description"]), "test") self.assertEquals(str(res[0]["sambaBadPasswordCount"]), "4") self.assertEquals(str(res[0]["sambaNextRid"]), "1001") - self.assertTrue(not "revision" in res[0]) + self.assertTrue("revision" not in res[0]) # Delete split record self.ldb.delete(dn) diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py index a393b70cc90..f7ab805cbaa 100644 --- a/selftest/selftesthelpers.py +++ b/selftest/selftesthelpers.py @@ -106,9 +106,9 @@ def plantestsuite_loadlist(name, env, cmdline): if isinstance(cmdline, list): cmdline = " ".join(cmdline) support_list = ("$LISTOPT" in cmdline) - if not "$LISTOPT" in cmdline: + if "$LISTOPT" not in cmdline: raise AssertionError("loadlist test %s does not support not --list" % name) - if not "$LOADLIST" in cmdline: + if "$LOADLIST" not in cmdline: raise AssertionError("loadlist test %s does not support --load-list" % name) print(("%s | %s" % (cmdline.replace("$LOADLIST", ""), add_prefix(name, env, support_list))).replace("$LISTOPT", "--list")) print(cmdline.replace("$LISTOPT", "") + " 2>&1 " + " | " + add_prefix(name, env, False)) diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index 830dd4ba63d..d79bd7f2ba5 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -601,7 +601,7 @@ class PlainFormatter(TestsuiteEnabledTestResult): out = "" unexpected = False - if not name in self.test_output: + if name not in self.test_output: print("no output for name[%s]" % name) if result in ("success", "xfail"): @@ -655,7 +655,7 @@ class PlainFormatter(TestsuiteEnabledTestResult): 'success': '.'}.get(result, "?(%s)" % result)) return - if not self.name in self.test_output: + if self.name not in self.test_output: self.test_output[self.name] = "" self.test_output[self.name] += "UNEXPECTED(%s): %s\n" % (result, testname) diff --git a/source4/dsdb/tests/python/acl.py b/source4/dsdb/tests/python/acl.py index 3251cb53fa6..aaa7995be97 100755 --- a/source4/dsdb/tests/python/acl.py +++ b/source4/dsdb/tests/python/acl.py @@ -51,7 +51,7 @@ if len(args) < 1: sys.exit(1) host = args[0] -if not "://" in host: +if "://" not in host: ldaphost = "ldap://%s" % host else: ldaphost = host diff --git a/source4/dsdb/tests/python/deletetest.py b/source4/dsdb/tests/python/deletetest.py index af1274eb7f3..0597d4fe52b 100755 --- a/source4/dsdb/tests/python/deletetest.py +++ b/source4/dsdb/tests/python/deletetest.py @@ -556,7 +556,7 @@ class BasicTreeDeleteTests(BasicDeleteTests): self.assertFalse("CN=Deleted Objects" in str(objDeleted7.dn)) -if not "://" in host: +if "://" not in host: if os.path.isfile(host): host = "tdb://%s" % host else: diff --git a/source4/dsdb/tests/python/dirsync.py b/source4/dsdb/tests/python/dirsync.py index 474cd45f565..d8cd3c67d08 100755 --- a/source4/dsdb/tests/python/dirsync.py +++ b/source4/dsdb/tests/python/dirsync.py @@ -58,7 +58,7 @@ if len(args) < 1: sys.exit(1) host = args.pop() -if not "://" in host: +if "://" not in host: ldaphost = "ldap://%s" % host ldapshost = "ldaps://%s" % host else: diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py index b2ef01b9420..dac8aa0fd67 100755 --- a/source4/dsdb/tests/python/ldap.py +++ b/source4/dsdb/tests/python/ldap.py @@ -3271,14 +3271,14 @@ class BaseDnTests(samba.tests.TestCase): self.assertEquals(given, expected) -if not "://" in host: +if "://" not in host: if os.path.isfile(host): host = "tdb://%s" % host else: host = "ldap://%s" % host ldb = SamDB(host, credentials=creds, session_info=system_session(lp), lp=lp) -if not "tdb://" in host: +if "tdb://" not in host: gc_ldb = Ldb("%s:3268" % host, credentials=creds, session_info=system_session(lp), lp=lp) else: diff --git a/source4/dsdb/tests/python/ldap_schema.py b/source4/dsdb/tests/python/ldap_schema.py index 9a4003ae612..716fd161895 100755 --- a/source4/dsdb/tests/python/ldap_schema.py +++ b/source4/dsdb/tests/python/ldap_schema.py @@ -1646,7 +1646,7 @@ class SchemaTests_msDS_isRODC(samba.tests.TestCase): self.assertTrue("msDS-isRODC" in ldb_msg) -if not "://" in host: +if "://" not in host: if os.path.isfile(host): host = "tdb://%s" % host else: diff --git a/source4/dsdb/tests/python/notification.py b/source4/dsdb/tests/python/notification.py index bb3280aaece..72f511faafc 100755 --- a/source4/dsdb/tests/python/notification.py +++ b/source4/dsdb/tests/python/notification.py @@ -365,7 +365,7 @@ delete: otherLoginWorkstations self.assertEquals(num, ERR_UNWILLING_TO_PERFORM) -if not "://" in url: +if "://" not in url: if os.path.isfile(url): url = "tdb://%s" % url else: diff --git a/source4/dsdb/tests/python/passwords.py b/source4/dsdb/tests/python/passwords.py index 44b04943027..0f73cf31928 100755 --- a/source4/dsdb/tests/python/passwords.py +++ b/source4/dsdb/tests/python/passwords.py @@ -1134,7 +1134,7 @@ unicodePwd:: """ + base64.b64encode("\"thatsAcomplPASS3\"".encode('utf-16-le')). self.ldb2 = None -if not "://" in host: +if "://" not in host: if os.path.isfile(host): host = "tdb://%s" % host else: diff --git a/source4/dsdb/tests/python/sam.py b/source4/dsdb/tests/python/sam.py index d45f5b80204..58d5edb7b1f 100755 --- a/source4/dsdb/tests/python/sam.py +++ b/source4/dsdb/tests/python/sam.py @@ -3760,7 +3760,7 @@ class SamTests(samba.tests.TestCase): delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn) -if not "://" in host: +if "://" not in host: if os.path.isfile(host): host = "tdb://%s" % host else: diff --git a/source4/dsdb/tests/python/sec_descriptor.py b/source4/dsdb/tests/python/sec_descriptor.py index cea148fc88d..2ce9caab572 100755 --- a/source4/dsdb/tests/python/sec_descriptor.py +++ b/source4/dsdb/tests/python/sec_descriptor.py @@ -2146,7 +2146,7 @@ class SdAutoInheritTests(DescriptorTests): self.assertTrue(sub_usn2 == sub_usn0) -if not "://" in host: +if "://" not in host: if os.path.isfile(host): host = "tdb://%s" % host else: diff --git a/source4/dsdb/tests/python/sites.py b/source4/dsdb/tests/python/sites.py index 7dd48d07f97..6002397df83 100755 --- a/source4/dsdb/tests/python/sites.py +++ b/source4/dsdb/tests/python/sites.py @@ -55,7 +55,7 @@ if len(args) < 1: sys.exit(1) host = args[0] -if not "://" in host: +if "://" not in host: ldaphost = "ldap://%s" % host else: ldaphost = host diff --git a/source4/dsdb/tests/python/token_group.py b/source4/dsdb/tests/python/token_group.py index 9769d2c03da..a69699ed169 100755 --- a/source4/dsdb/tests/python/token_group.py +++ b/source4/dsdb/tests/python/token_group.py @@ -649,7 +649,7 @@ class DynamicTokenTest(samba.tests.TestCase): self.assertEqual(rids.rids[0].rid, user_info.primary_gid) -if not "://" in url: +if "://" not in url: if os.path.isfile(url): url = "tdb://%s" % url else: diff --git a/source4/dsdb/tests/python/user_account_control.py b/source4/dsdb/tests/python/user_account_control.py index 5fd8aaf6f38..dd3276add98 100755 --- a/source4/dsdb/tests/python/user_account_control.py +++ b/source4/dsdb/tests/python/user_account_control.py @@ -58,7 +58,7 @@ if len(args) < 1: sys.exit(1) host = args[0] -if not "://" in host: +if "://" not in host: ldaphost = "ldap://%s" % host else: ldaphost = host diff --git a/source4/scripting/devel/pfm_verify.py b/source4/scripting/devel/pfm_verify.py index 4d4e0c9536f..c1e2f7ab692 100755 --- a/source4/scripting/devel/pfm_verify.py +++ b/source4/scripting/devel/pfm_verify.py @@ -163,7 +163,7 @@ if __name__ == "__main__": if len(args) != 1: import os - if not "DC_SERVER" in os.environ.keys(): + if "DC_SERVER" not in os.environ.keys(): parser.error("You must supply a server") args.append(os.environ["DC_SERVER"]) diff --git a/source4/scripting/devel/speedtest.py b/source4/scripting/devel/speedtest.py index 969edb08192..e8d412436e6 100755 --- a/source4/scripting/devel/speedtest.py +++ b/source4/scripting/devel/speedtest.py @@ -227,7 +227,7 @@ class AclSearchSpeedTest(SpeedTest): # Important unit running information -if not "://" in host: +if "://" not in host: host = "ldap://%s" % host ldb_options = ["modules:paged_searches"] diff --git a/source4/torture/drs/python/repl_rodc.py b/source4/torture/drs/python/repl_rodc.py index bdc7041571f..b9e3f827773 100644 --- a/source4/torture/drs/python/repl_rodc.py +++ b/source4/torture/drs/python/repl_rodc.py @@ -73,7 +73,7 @@ def drs_get_rodc_partial_attribute_set(samdb, samdb1, exceptions=[]): continue try: attid = samdb1.get_attid_from_lDAPDisplayName(ldap_display_name) - if not attid in exceptions: + if attid not in exceptions: attids.append(int(attid)) except: pass diff --git a/source4/torture/libnet/python/samr-test.py b/source4/torture/libnet/python/samr-test.py index 22b754fb6fb..82cf61d33b1 100644 --- a/source4/torture/libnet/python/samr-test.py +++ b/source4/torture/libnet/python/samr-test.py @@ -31,10 +31,10 @@ import os from samba import net import samba.tests -if not "ACCOUNT_NAME" in os.environ.keys(): +if "ACCOUNT_NAME" not in os.environ.keys(): raise Exception("Please supply ACCOUNT_NAME in environment") -if not "NEW_PASS" in os.environ.keys(): +if "NEW_PASS" not in os.environ.keys(): raise Exception("Please supply NEW_PASS in environment") account_name = os.environ["ACCOUNT_NAME"] diff --git a/wintest/wintest.py b/wintest/wintest.py index 064eb4bac46..166489aa037 100644 --- a/wintest/wintest.py +++ b/wintest/wintest.py @@ -49,7 +49,7 @@ class wintest(): def getvar(self, varname): '''return a substitution variable''' - if not varname in self.vars: + if varname not in self.vars: return None return self.vars[varname] @@ -133,7 +133,7 @@ class wintest(): if var_end == -1: return text var_name = text[var_start + 2:var_end] - if not var_name in self.vars: + if var_name not in self.vars: raise RuntimeError("Unknown substitution variable ${%s}" % var_name) text = text.replace("${%s}" % var_name, self.vars[var_name]) return text