From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=195.135.221.5; helo=smtp.nue.novell.com; envelope-from=glin@suse.com; receiver=edk2-devel@lists.01.org Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3C350222CF1BA for ; Thu, 18 Jan 2018 20:38:23 -0800 (PST) Received: from localhost.localdomain (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Fri, 19 Jan 2018 05:43:42 +0100 From: Gary Lin To: edk2-devel@lists.01.org Cc: Yonghong Zhu , Liming Gao Date: Fri, 19 Jan 2018 12:43:04 +0800 Message-Id: <20180119044316.4713-4-glin@suse.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180119044316.4713-1-glin@suse.com> References: <20180119044316.4713-1-glin@suse.com> Subject: [PATCH 03/15] BaseTools: Remove the old python "not-equal" X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jan 2018 04:38:24 -0000 Replace "<>" with "!=" to be compatible with python3. Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Gary Lin --- BaseTools/Scripts/BinToPcd.py | 4 ++-- BaseTools/Source/Python/AutoGen/AutoGen.py | 4 ++-- BaseTools/Source/Python/AutoGen/BuildEngine.py | 4 ++-- BaseTools/Source/Python/AutoGen/GenC.py | 4 ++-- BaseTools/Source/Python/AutoGen/GenMake.py | 2 +- BaseTools/Source/Python/Common/Misc.py | 2 +- BaseTools/Source/Python/GenFds/Fv.py | 2 +- BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py | 6 +++--- BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py | 12 ++++++------ BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py | 12 ++++++------ BaseTools/Source/Python/Workspace/DscBuildData.py | 2 +- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py index c4e7b8a5c2e2..1867f35e148e 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -41,13 +41,13 @@ if __name__ == '__main__': return Value def ValidatePcdName (Argument): - if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) <> ['','']: + if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['','']: Message = '%s is not in the form .' % (Argument) raise argparse.ArgumentTypeError(Message) return Argument def ValidateGuidName (Argument): - if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) <> ['','']: + if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['','']: Message = '%s is not a valid GUID C name' % (Argument) raise argparse.ArgumentTypeError(Message) return Argument diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 5e55d5d655e3..7b9054b73b51 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -4033,7 +4033,7 @@ class ModuleAutoGen(AutoGen): return # Skip the following code for modules without any binary files - if self.BinaryFileList <> None and self.BinaryFileList <> []: + if self.BinaryFileList != None and self.BinaryFileList != []: return ### TODO: How to handles mixed source and binary modules @@ -4499,7 +4499,7 @@ class ModuleAutoGen(AutoGen): Dpx = GenDepex.DependencyExpression(self.DepexList[ModuleType], ModuleType, True) DpxFile = gAutoGenDepexFileName % {"module_name" : self.Name} - if len(Dpx.PostfixNotation) <> 0: + if len(Dpx.PostfixNotation) != 0: self.DepexGenerated = True if Dpx.Generate(path.join(self.OutputDir, DpxFile)): diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py index 46685967d1ee..f0a973c9f197 100644 --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py @@ -388,8 +388,8 @@ class BuildRule: self.RuleContent[Index] = Line # find the build_rule_version - if Line and Line[0] == "#" and Line.find(TAB_BUILD_RULE_VERSION) <> -1: - if Line.find("=") <> -1 and Line.find("=") < (len(Line) - 1) and (Line[(Line.find("=") + 1):]).split(): + if Line and Line[0] == "#" and Line.find(TAB_BUILD_RULE_VERSION) != -1: + if Line.find("=") != -1 and Line.find("=") < (len(Line) - 1) and (Line[(Line.find("=") + 1):]).split(): self._FileVersion = (Line[(Line.find("=") + 1):]).split()[0] # skip empty or comment line if Line == "" or Line[0] == "#": diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 3e98506cc807..b8ba687bcda0 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1521,7 +1521,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): } if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE', 'MM_CORE_STANDALONE']: - if Info.SourceFileList <> None and Info.SourceFileList <> []: + if Info.SourceFileList != None and Info.SourceFileList != []: if NumEntryPoints != 1: EdkLogger.error( "build", @@ -1683,7 +1683,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): AutoGenH.Append("\n// Definition of SkuId Array\n") AutoGenH.Append("extern UINT64 _gPcd_SkuId_Array[];\n") # Add extern declarations to AutoGen.h if one or more Token Space GUIDs were found - if TokenSpaceList <> []: + if TokenSpaceList != []: AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n") if Info.ModuleType in ["USER_DEFINED", "BASE"]: GuidType = "GUID" diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 3f98a34d81ec..8891b1b97d23 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -562,7 +562,7 @@ cleanlib: # convert source files and binary files to build targets self.ResultFileList = [str(T.Target) for T in self._AutoGenObject.CodaTargetList] - if len(self.ResultFileList) == 0 and len(self._AutoGenObject.SourceFileList) <> 0: + if len(self.ResultFileList) == 0 and len(self._AutoGenObject.SourceFileList) != 0: EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build", ExtraData="[%s]" % str(self._AutoGenObject)) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index f1eb4c5a7892..223dc7971b0d 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1509,7 +1509,7 @@ def ParseDevPathValue (Value): def ParseFieldValue (Value): if type(Value) == type(0): return Value, (Value.bit_length() + 7) / 8 - if type(Value) <> type(''): + if type(Value) != type(''): raise BadExpression('Type %s is %s' %(Value, type(Value))) Value = Value.strip() if Value.startswith('UINT8') and Value.endswith(')'): diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py index c0b869d250f1..be8b885d069e 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -341,7 +341,7 @@ class FV (FvClassObject): if len(self.FvExtEntryType) > 0 or self.UsedSizeEnable: GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entries declared for %s with no FvNameGuid declaration." % (self.UiFvName)) - if self.FvNameGuid <> None and self.FvNameGuid <> '': + if self.FvNameGuid != None and self.FvNameGuid != '': TotalSize = 16 + 4 Buffer = '' if self.UsedSizeEnable: diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py index 4f79d0f82967..11d11700ed99 100644 --- a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py +++ b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py @@ -118,7 +118,7 @@ if __name__ == '__main__': sys.exit(1) Version = Process.communicate() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH') sys.exit(Process.returncode) print(Version[0]) @@ -208,7 +208,7 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s smime -sign -binary -signer "%s" -outform DER -md sha256 -certfile "%s"' % (OpenSslCommand, args.SignerPrivateCertFileName, args.OtherPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Signature = Process.communicate(input=FullInputFileBuffer)[0] - if Process.returncode <> 0: + if Process.returncode != 0: sys.exit(Process.returncode) # @@ -277,7 +277,7 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s smime -verify -inform DER -content %s -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Process.communicate(input=args.SignatureBuffer)[0] - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Verification failed') os.remove (args.OutputFileName) sys.exit(Process.returncode) diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py index 06ed2610271f..2aa6877c92be 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py @@ -80,7 +80,7 @@ if __name__ == '__main__': sys.exit(1) Version = Process.communicate() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH') sys.exit(Process.returncode) print(Version[0]) @@ -90,7 +90,7 @@ if __name__ == '__main__': # # Check for output file argument # - if args.OutputFile <> None: + if args.OutputFile != None: for Item in args.OutputFile: # # Save PEM filename and close output file @@ -103,14 +103,14 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslCommand, Item.name), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Process.communicate() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: RSA 2048 key generation failed') sys.exit(Process.returncode) # # Check for input file argument # - if args.InputFile <> None: + if args.InputFile != None: for Item in args.InputFile: # # Save PEM filename and close input file @@ -125,7 +125,7 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) PublicKeyHexString = Process.communicate()[0].split('=')[1].strip() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Unable to extract public key from private key') sys.exit(Process.returncode) PublicKey = '' @@ -138,7 +138,7 @@ if __name__ == '__main__': Process = subprocess.Popen('%s dgst -sha256 -binary' % (OpenSslCommand), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Process.stdin.write (PublicKey) PublicKeyHash = PublicKeyHash + Process.communicate()[0] - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Unable to extract SHA 256 hash of public key') sys.exit(Process.returncode) diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py index 99a5d8aa5a01..8c235ae51e7e 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py @@ -101,7 +101,7 @@ if __name__ == '__main__': sys.exit(1) Version = Process.communicate() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH') sys.exit(Process.returncode) print(Version[0]) @@ -157,7 +157,7 @@ if __name__ == '__main__': while len(PublicKeyHexString) > 0: PublicKey = PublicKey + chr(int(PublicKeyHexString[0:2],16)) PublicKeyHexString=PublicKeyHexString[2:] - if Process.returncode <> 0: + if Process.returncode != 0: sys.exit(Process.returncode) if args.MonotonicCountStr: @@ -179,7 +179,7 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s sha256 -sign "%s"' % (OpenSslCommand, args.PrivateKeyFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Signature = Process.communicate(input=FullInputFileBuffer)[0] - if Process.returncode <> 0: + if Process.returncode != 0: sys.exit(Process.returncode) # @@ -202,14 +202,14 @@ if __name__ == '__main__': # # Verify that the Hash Type matches the expected SHA256 type # - if uuid.UUID(bytes_le = Header.HashType) <> EFI_HASH_ALGORITHM_SHA256_GUID: + if uuid.UUID(bytes_le = Header.HashType) != EFI_HASH_ALGORITHM_SHA256_GUID: print('ERROR: unsupport hash GUID') sys.exit(1) # # Verify the public key # - if Header.PublicKey <> PublicKey: + if Header.PublicKey != PublicKey: print('ERROR: Public key in input file does not match public key from private key file') sys.exit(1) @@ -228,7 +228,7 @@ if __name__ == '__main__': # Process = subprocess.Popen('%s sha256 -prverify "%s" -signature %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) Process.communicate(input=FullInputFileBuffer) - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Verification failed') os.remove (args.OutputFileName) sys.exit(Process.returncode) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index cce7a6273313..3ddbc4ca0b05 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1259,7 +1259,7 @@ class DscBuildData(PlatformBuildClassObject): print('ERROR: Can not execute command:', Command) sys.exit(1) Result = Process.communicate() - if Process.returncode <> 0: + if Process.returncode != 0: print('ERROR: Can not collect output from command:', Command) return Result[0], Result[1] -- 2.15.1