From: Joe Guo Date: Mon, 30 Jul 2018 06:22:15 +0000 (+1200) Subject: PEP8: fix E711: comparison to None should be 'if cond is not None:' X-Git-Tag: tdb-1.3.17~2049 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=e940e4cd48fa866cdb81e38d7786aac953f30bdf PEP8: fix E711: comparison to None should be 'if cond is not None:' Signed-off-by: Joe Guo Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/join.py b/python/samba/join.py index ebcfea84444..66097b9c596 100644 --- a/python/samba/join.py +++ b/python/samba/join.py @@ -975,7 +975,7 @@ class DCJoinContext(object): repl.replicate(ctx.new_krbtgt_dn, source_dsa_invocation_id, destination_dsa_guid, exop=drsuapi.DRSUAPI_EXOP_REPL_SECRET, rodc=True) - elif ctx.rid_manager_dn != None: + elif ctx.rid_manager_dn is not None: # Try and get a RID Set if we can. This is only possible against the RID Master. Warn otherwise. try: repl.replicate(ctx.rid_manager_dn, source_dsa_invocation_id, diff --git a/python/samba/netcmd/delegation.py b/python/samba/netcmd/delegation.py index e0e281d3f7b..54ba71bdf41 100644 --- a/python/samba/netcmd/delegation.py +++ b/python/samba/netcmd/delegation.py @@ -56,7 +56,7 @@ class cmd_delegation_show(Command): creds = credopts.get_credentials(lp) paths = provision.provision_paths_from_lp(lp, lp.get("realm")) - if H == None: + if H is None: path = paths.samdb else: path = H @@ -121,7 +121,7 @@ class cmd_delegation_for_any_service(Command): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) paths = provision.provision_paths_from_lp(lp, lp.get("realm")) - if H == None: + if H is None: path = paths.samdb else: path = H @@ -174,7 +174,7 @@ class cmd_delegation_for_any_protocol(Command): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) paths = provision.provision_paths_from_lp(lp, lp.get("realm")) - if H == None: + if H is None: path = paths.samdb else: path = H @@ -219,7 +219,7 @@ class cmd_delegation_add_service(Command): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) paths = provision.provision_paths_from_lp(lp, lp.get("realm")) - if H == None: + if H is None: path = paths.samdb else: path = H @@ -273,7 +273,7 @@ class cmd_delegation_del_service(Command): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) paths = provision.provision_paths_from_lp(lp, lp.get("realm")) - if H == None: + if H is None: path = paths.samdb else: path = H diff --git a/python/samba/tests/pam_winbind.py b/python/samba/tests/pam_winbind.py index 4ee7c8d784b..68b05b30d7d 100644 --- a/python/samba/tests/pam_winbind.py +++ b/python/samba/tests/pam_winbind.py @@ -32,7 +32,7 @@ class SimplePamTests(samba.tests.TestCase): tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) - self.assertTrue(res != None) + self.assertTrue(res is not None) def test_authenticate_error(self): domain = os.environ["DOMAIN"] @@ -44,7 +44,7 @@ class SimplePamTests(samba.tests.TestCase): tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) - self.assertTrue(res != None) + self.assertTrue(res is not None) # Authenticate again to check that we are not locked out with just one # failed login @@ -54,4 +54,4 @@ class SimplePamTests(samba.tests.TestCase): tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) - self.assertTrue(res != None) + self.assertTrue(res is not None) diff --git a/python/samba/tests/pam_winbind_warn_pwd_expire.py b/python/samba/tests/pam_winbind_warn_pwd_expire.py index 849099446da..df60bc5ace6 100644 --- a/python/samba/tests/pam_winbind_warn_pwd_expire.py +++ b/python/samba/tests/pam_winbind_warn_pwd_expire.py @@ -33,7 +33,7 @@ class PasswordExpirePamTests(samba.tests.TestCase): tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc) res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password]) - self.assertTrue(res != None) + self.assertTrue(res is not None) if warn_pwd_expire == 0: self.assertTrue(res.info == ()) elif warn_pwd_expire == 50: diff --git a/python/samba/tests/password_hash_gpgme.py b/python/samba/tests/password_hash_gpgme.py index 20c07e61967..42cd71d3e08 100644 --- a/python/samba/tests/password_hash_gpgme.py +++ b/python/samba/tests/password_hash_gpgme.py @@ -133,7 +133,7 @@ class PassWordHashGpgmeTests(PassWordHashTests): sc = self.get_supplemental_creds() if expect_cleartext: (pos, ct_package) = get_package(sc, "Primary:CLEARTEXT") - self.assertTrue(ct_package != None, "Failed to retrieve cleartext") + self.assertTrue(ct_package is not None, "Failed to retrieve cleartext") # Check the clear-text value is correct. ct = ndr_unpack(drsblobs.package_PrimaryCLEARTEXTBlob, @@ -141,7 +141,7 @@ class PassWordHashGpgmeTests(PassWordHashTests): self.assertEquals(password.encode('utf-16-le'), ct.cleartext) else: ct_package = get_package(sc, "Primary:CLEARTEXT") - self.assertTrue(ct_package == None, + self.assertTrue(ct_package is None, "Got cleartext when we shouldn't have") def test_supplementalCredentials_cleartext_pso(self): diff --git a/source4/dsdb/tests/python/dirsync.py b/source4/dsdb/tests/python/dirsync.py index 67ba2bbc74b..474cd45f565 100755 --- a/source4/dsdb/tests/python/dirsync.py +++ b/source4/dsdb/tests/python/dirsync.py @@ -229,19 +229,19 @@ class SimpleDirsyncTests(DirsyncBaseTests): expression="samaccountname=*", controls=["dirsync:1:0:1"]) # Check that nTSecurityDescriptor is returned as it's the case when doing dirsync - self.assertTrue(res.msgs[0].get("ntsecuritydescriptor") != None) + self.assertTrue(res.msgs[0].get("ntsecuritydescriptor") is not None) # Check that non replicated attributes are not returned - self.assertTrue(res.msgs[0].get("badPwdCount") == None) + self.assertTrue(res.msgs[0].get("badPwdCount") is None) # Check that non forward link are not returned - self.assertTrue(res.msgs[0].get("memberof") == None) + self.assertTrue(res.msgs[0].get("memberof") is None) # Asking for instanceType will return also objectGUID res = self.ldb_admin.search(self.base_dn, expression="samaccountname=Administrator", attrs=["instanceType"], controls=["dirsync:1:0:1"]) - self.assertTrue(res.msgs[0].get("objectGUID") != None) - self.assertTrue(res.msgs[0].get("instanceType") != None) + self.assertTrue(res.msgs[0].get("objectGUID") is not None) + self.assertTrue(res.msgs[0].get("instanceType") is not None) # We don't return an entry if asked for objectGUID res = self.ldb_admin.search(self.base_dn, @@ -255,10 +255,10 @@ class SimpleDirsyncTests(DirsyncBaseTests): expression="(distinguishedName=%s)" % str(self.base_dn), attrs=["name"], controls=["dirsync:1:0:1"]) - self.assertTrue(res.msgs[0].get("objectGUID") != None) - self.assertTrue(res.msgs[0].get("name") != None) - self.assertTrue(res.msgs[0].get("parentGUID") == None) - self.assertTrue(res.msgs[0].get("instanceType") != None) + self.assertTrue(res.msgs[0].get("objectGUID") is not None) + self.assertTrue(res.msgs[0].get("name") is not None) + self.assertTrue(res.msgs[0].get("parentGUID") is None) + self.assertTrue(res.msgs[0].get("instanceType") is not None) # Asking for name will return also objectGUID and parentGUID # and instanceType and of course name @@ -266,10 +266,10 @@ class SimpleDirsyncTests(DirsyncBaseTests): expression="samaccountname=Administrator", attrs=["name"], controls=["dirsync:1:0:1"]) - self.assertTrue(res.msgs[0].get("objectGUID") != None) - self.assertTrue(res.msgs[0].get("name") != None) - self.assertTrue(res.msgs[0].get("parentGUID") != None) - self.assertTrue(res.msgs[0].get("instanceType") != None) + self.assertTrue(res.msgs[0].get("objectGUID") is not None) + self.assertTrue(res.msgs[0].get("name") is not None) + self.assertTrue(res.msgs[0].get("parentGUID") is not None) + self.assertTrue(res.msgs[0].get("instanceType") is not None) # Asking for dn will not return not only DN but more like if attrs=* # parentGUID should be returned @@ -366,7 +366,7 @@ class SimpleDirsyncTests(DirsyncBaseTests): controls=["dirsync:1:0:0"]) self.assertEqual(len(res.msgs), nb - 1) if nb > 1: - self.assertTrue(res.msgs[0].get("objectGUID") != None) + self.assertTrue(res.msgs[0].get("objectGUID") is not None) else: res = self.ldb_admin.search(self.base_dn, expression="(objectclass=configuration)", @@ -454,8 +454,8 @@ class SimpleDirsyncTests(DirsyncBaseTests): expression="(&(objectClass=organizationalUnit)(!(isDeleted=*)))", controls=[control3]) - self.assertTrue(res[0].get("parentGUID") != None) - self.assertTrue(res[0].get("name") != None) + self.assertTrue(res[0].get("parentGUID") is not None) + self.assertTrue(res[0].get("name") is not None) delete_force(self.ldb_admin, ouname) def test_dirsync_linkedattributes(self): @@ -571,7 +571,7 @@ class SimpleDirsyncTests(DirsyncBaseTests): guid2 = str(ndr_unpack(misc.GUID, res[0].get("objectGUID")[0])) self.assertEqual(guid2, guid) self.assertTrue(res[0].get("isDeleted")) - self.assertTrue(res[0].get("name") != None) + self.assertTrue(res[0].get("name") is not None) def test_cookie_from_others(self): res = self.ldb_admin.search(self.base_dn, @@ -596,7 +596,7 @@ class ExtendedDirsyncTests(SimpleDirsyncTests): expression="(name=Administrators)", controls=["dirsync:1:%d:1" % flag_incr_linked]) - self.assertTrue(res[0].get("member;range=1-1") != None) + self.assertTrue(res[0].get("member;range=1-1") is not None) self.assertTrue(len(res[0].get("member;range=1-1")) > 0) size = len(res[0].get("member;range=1-1")) @@ -673,7 +673,7 @@ class ExtendedDirsyncTests(SimpleDirsyncTests): if str(e["name"]) == "testou3": guid = str(ndr_unpack(misc.GUID, e.get("objectGUID")[0])) - self.assertTrue(guid != None) + self.assertTrue(guid is not None) ctl = str(res.controls[0]).split(":") ctl[1] = "1" ctl[2] = "1" diff --git a/source4/scripting/devel/demodirsync.py b/source4/scripting/devel/demodirsync.py index 67e361b1eb0..248cfec7101 100755 --- a/source4/scripting/devel/demodirsync.py +++ b/source4/scripting/devel/demodirsync.py @@ -96,7 +96,7 @@ cont = 0 if (len(ctrls)): for ctl in ctrls: cookie = printdirsync(ctl) - if cookie != None: + if cookie is not None: cont = (ctl.split(':'))[1] print("Returned %d entries" % len(msgs)) @@ -112,7 +112,7 @@ while (cont == "1"): if (len(ctrls)): for ctl in ctrls: cookie = printdirsync(ctl) - if cookie != None: + if cookie is not None: cont = (ctl.split(':'))[1] print("Returned %d entries" % len(msgs)) diff --git a/source4/scripting/devel/repl_cleartext_pwd.py b/source4/scripting/devel/repl_cleartext_pwd.py index 1da0417abc4..fc90589269e 100755 --- a/source4/scripting/devel/repl_cleartext_pwd.py +++ b/source4/scripting/devel/repl_cleartext_pwd.py @@ -240,7 +240,7 @@ if __name__ == "__main__": while True: (level, ctr) = drs_conn.DsGetNCChanges(drs_handle, 8, req8) - if ctr.first_object == None and ctr.object_count != 0: + if ctr.first_object is None and ctr.object_count != 0: raise RuntimeError("DsGetNCChanges: NULL first_object with object_count=%u" % (ctr.object_count)) obj_item = ctr.first_object diff --git a/source4/torture/drs/python/repl_move.py b/source4/torture/drs/python/repl_move.py index d65d173013a..fed97518560 100644 --- a/source4/torture/drs/python/repl_move.py +++ b/source4/torture/drs/python/repl_move.py @@ -138,7 +138,7 @@ class DrsMoveObjectTestCase(drs_base.DrsBaseTestCase): version, o.version)) i = i + 1 - if drs == None: + if drs is None: return req8 = DsGetNCChangesRequest8() diff --git a/wintest/wintest.py b/wintest/wintest.py index 4af7eb77b1d..064eb4bac46 100644 --- a/wintest/wintest.py +++ b/wintest/wintest.py @@ -515,7 +515,7 @@ options { i = child.exitstatus if wait_for_fail: # wait for timeout or fail - if i == None or i > 0: + if i is None or i > 0: return else: if i == 0: