Use "foo is not None" instead of "foo != None".
[mirror/userdir-ldap.git] / userdir_gpg.py
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