Use "foo is not None" instead of "foo != None".
authorJulien Cristau <jcristau@debian.org>
Fri, 11 Oct 2019 13:34:39 +0000 (15:34 +0200)
committerJulien Cristau <jcristau@debian.org>
Fri, 11 Oct 2019 13:34:39 +0000 (15:34 +0200)
debian/changelog
sigcheck
ud-echelon
ud-emailmatcher
ud-generate
ud-gpgimport
ud-useradd
unmaintained/gpgwrapper
userdir_gpg.py

index 01cfbb2..8378dd1 100644 (file)
@@ -18,6 +18,7 @@ userdir-ldap (0.3.97) UNRELEASED; urgency=medium
     foo in bar").
   * ud-mailgate: use subprocess.Popen instead of os.popen.
   * Use "foo is None" instead of "foo == None".
+  * Use "foo is not None" instead of "foo != None".
 
  -- Peter Palfrader <weasel@debian.org>  Sat, 06 Apr 2019 22:04:34 +0200
 
index f3c17f0..9c59bd2 100755 (executable)
--- a/sigcheck
+++ b/sigcheck
@@ -82,7 +82,7 @@ def CheckLDAP(FingerPrint):
 
    # See if the group membership is OK
    # Only if a group was given on the commandline
-   if GroupMember != None:
+   if GroupMember is not None:
       Hit = 0;
       # Check primary group first
       if GAttr[0][1]["gid"][0] == GroupMember:
@@ -123,7 +123,7 @@ MsgID = None;
 try:
    # Startup the replay cache
    ErrType = EX_TEMPFAIL;
-   if ReplayCacheFile != None:
+   if ReplayCacheFile is not None:
       ErrMsg = "Failed to initialize the replay cache:";
       RC = ReplayCache(ReplayCacheFile);
 
@@ -153,15 +153,15 @@ try:
       raise UDFormatError, "Null signature text"
 
    # Check the signature against the replay cache
-   if ReplayCacheFile != None:
+   if ReplayCacheFile is not None:
       RC.process(pgp.sig_info)
 
    # Do LDAP stuff
-   if LDAPDn != None:
+   if LDAPDn is not None:
       CheckLDAP(pgp.key_fpr)
 
    ErrMsg = "Verifying message:";
-   if Phrases != None:
+   if Phrases is not None:
       F = open(Phrases,"r");
       while 1:
          Line = F.readline();
index 884ba3b..b2b4f07 100755 (executable)
@@ -117,7 +117,7 @@ try:
    if not List: List = "-";
 
    # Tada, write a log message
-   if User != None:
+   if User is not None:
       Msg = "[%s] \"%s\" \"%s\" \"%s\""%(Now,User[2],List,MsgID);
       MainLog.write("%s %s %s\n"%(User[0],User[1],Msg));
       Dn = "uid=" + User[0] + "," + BaseDn;
index aa717d5..b6e054d 100755 (executable)
@@ -81,7 +81,7 @@ while(1):
    
    Split = Line.split(":")
    if len(Split) >= 8 and Split[0] == "pub":
-      if FingerPrint != None and UID != None:
+      if FingerPrint is not None and UID is not None:
          for x in Emails:
             Match = AddressSplit.match(x);
             if Match is None:
index 4b589c5..770db6a 100755 (executable)
@@ -184,9 +184,9 @@ def IsInGroup(account, allowed, current_host):
   return False
 
 def Die(File, F, Fdb):
-   if F != None:
+   if F is not None:
       F.close()
-   if Fdb != None:
+   if Fdb is not None:
       Fdb.close()
    try: 
       os.remove(File + ".tmp")
@@ -198,10 +198,10 @@ def Die(File, F, Fdb):
       pass
 
 def Done(File, F, Fdb):
-   if F != None:
+   if F is not None:
       F.close()
       os.rename(File + ".tmp", File)
-   if Fdb != None:
+   if Fdb is not None:
       Fdb.close()
       os.rename(File + ".tdb.tmp", File + ".tdb")
 
@@ -848,7 +848,7 @@ def GenDNS(accounts, File):
                   F.write(Line)
 
                   Host = Split[0] + DNSZone
-                  if BSMTPCheck.match(Line) != None:
+                  if BSMTPCheck.match(Line) is not None:
                      F.write("; Has BSMTP\n")
 
                   # Write some identification information
@@ -989,7 +989,7 @@ def GenBSMTP(accounts, File, HomePrefix):
                   Line = " ".join(Split) + "\n"
      
                   Host = Split[0] + DNSZone
-                  if BSMTPCheck.match(Line) != None:
+                  if BSMTPCheck.match(Line) is not None:
                       F.write("%s: user=%s group=Debian file=%s%s/bsmtp/%s\n"%(Host,
                                   a['uid'], HomePrefix, a['uid'], Host))
      
index 72f09a4..1e95c46 100755 (executable)
@@ -95,7 +95,7 @@ def load_keys_from_gpg(keyrings):
          continue
       keys[fingerprint] = pgp_uid
 
-   if Keys.close() != None:
+   if Keys.close() is not None:
       raise "Error","GPG failed"
 
    return keys
@@ -179,7 +179,7 @@ for fpr in pgpkeys:
    UID = GetUID(l,SplitEmail(pgp_uid),UnknownMap);
    if UID[0] is None:
       print "Unassigned key in keyrings: %s, belonging to %s"%(fpr, pgp_uid)
-      if UID[1] != None:
+      if UID[1] is not None:
          for x in UID[1]: print x;
       print "MISSING " + fpr;
       continue;
index 6dd82d9..77f71dc 100755 (executable)
@@ -376,7 +376,7 @@ else:
           (ldap.MOD_REPLACE,"shadowExpire","")];
    if privsub != " ":
       Rec.append((ldap.MOD_REPLACE,"privateSub",privsub));
-   if Pass != None:
+   if Pass is not None:
       Rec.append((ldap.MOD_REPLACE,"userPassword","{crypt}"+Pass));
    # Do it
    l.modify_s(Dn,Rec);
@@ -397,7 +397,7 @@ Reply = TemplateSubst(Subst,open(templatepath, "r").read())
 Child = os.popen("/usr/sbin/sendmail -t","w");
 #Child = os.popen("cat","w");
 Child.write(Reply);
-if Child.close() != None:
+if Child.close() is not None:
    raise Error, "Sendmail gave a non-zero return code";
 
 # vim:set et:
index 793a524..108f981 100755 (executable)
@@ -126,7 +126,7 @@ ErrType = EX_TEMPFAIL;
 try:
    # Startup the replay cache
    ErrType = EX_TEMPFAIL;
-   if ReplayCacheFile != None:
+   if ReplayCacheFile is not None:
       ErrMsg = "Failed to initialize the replay cache:";
       RC = ReplayCache(ReplayCacheFile);
       RC.Clean();
@@ -145,7 +145,7 @@ try:
    ErrMsg = "Unable to check the signature or the signature was invalid:";
    Res = GPGCheckSig(Msg[0]);
 
-   if Res[0] != None:
+   if Res[0] is not None:
       raise Error, Res[0];
       
    if Res[3] is None:
@@ -164,15 +164,15 @@ try:
       PlainText = Res[3];   
 
    # Check the signature against the replay cache
-   if ReplayCacheFile != None:
+   if ReplayCacheFile is not None:
       ErrMsg = "The replay cache rejected your message. Check your clock!";
       Rply = RC.Check(Res[1]);
-      if Rply != None:
+      if Rply is not None:
          raise Error, Rply;
       RC.Add(Res[1]);
 
    # Do LDAP stuff
-   if LDAPDn != None:
+   if LDAPDn is not None:
       CheckLDAP(Res[2][1]);
       
    # Determine the sender address
@@ -195,7 +195,7 @@ try:
    # Invoke the child
    Child = os.popen(" ".join(arguments),"w");
    Child.write(PlainText);
-   if Child.close() != None:
+   if Child.close() is not None:
       raise Error, "Child gave a non-zero return code";
    
 except:
@@ -219,7 +219,7 @@ except:
 
    # Try to send the bounce
    try:
-      if ErrorTemplate != None:
+      if ErrorTemplate is not None:
          ErrReply = TemplateSubst(Subst,open(ErrorTemplate,"r").read());
       else:
          ErrReply = "\n"+str(Subst)+"\n";
@@ -227,7 +227,7 @@ except:
       Child = os.popen("/usr/sbin/sendmail -t","w");
       Child.write(ErrReplyHead);
       Child.write(ErrReply);
-      if Child.close() != None:
+      if Child.close() is not None:
          raise Error, "Sendmail gave a non-zero return code";
    except:
       sys.exit(EX_TEMPFAIL);
index fb5b938..9329261 100644 (file)
@@ -127,7 +127,7 @@ def GetClearSig(Msg, Paranoid=0, lax_multipart=False):
       # original signed block [needs to convert to \r\n]
       Output = "-----BEGIN PGP SIGNED MESSAGE-----\r\n";
       # Semi-evil hack to get the proper hash type inserted in the message
-      if Msg.get_param('micalg') != None:
+      if Msg.get_param('micalg') is not None:
           Output = Output + "Hash: SHA1,%s\r\n"%(Msg.get_param('micalg')[4:].upper())
       Output = Output + "\r\n";
       Output = Output + Signed.as_string().replace("\n-","\n- -") + "\n" + Signature.get_payload(decode=True)
@@ -216,7 +216,7 @@ def GPGWriteFilter(Program,Options,Message):
       InPipe[0] = -1;
 
       # Send the message
-      if Message != None:
+      if Message is not None:
          try:
             os.write(InPipe[1],Message);
          except:
@@ -272,7 +272,7 @@ def GPGEncrypt(Message,To,PGP2):
          Text = Res[2].read();
          return Text;
       finally:
-         if Res != None:
+         if Res is not None:
             Res[1].close();
             Res[2].close();
    else:
@@ -294,7 +294,7 @@ def GPGEncrypt(Message,To,PGP2):
             os.unlink(TmpName);
          except:
             pass;
-         if Res != None:
+         if Res is not None:
             Res[1].close();
             Res[2].close();
 
@@ -425,12 +425,12 @@ def GPGCheckSig(Message):
 
       # Try to decide if this message was sent using PGP2
       PGP2Message = 0;
-      if (re.search("-----[\n\r][\n\r]?Version: 2\\.",Message) != None):
+      if (re.search("-----[\n\r][\n\r]?Version: 2\\.",Message) is not None):
          PGP2Message = 1;
 
       return (Why,(SigId,Date,KeyFinger),(KeyID,KeyFinger,Owner,0,PGP2Message),Text);
    finally:
-      if Res != None:
+      if Res is not None:
          Res[1].close();
          Res[2].close();
 
@@ -529,7 +529,7 @@ def GPGKeySearch(SearchCriteria):
             continue
 
    finally:
-      if Strm != None:
+      if Strm is not None:
          Strm.close()
    return Result