From nobody Mon Dec 23 18:02:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516337031142616.4954898931143; Thu, 18 Jan 2018 20:43:51 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BBDD12232BDE1; Thu, 18 Jan 2018 20:38:25 -0800 (PST) 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 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; 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 From: Gary Lin To: edk2-devel@lists.01.org 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: [edk2] [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: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Replace "<>" with "!=3D" 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 | 1= 2 ++++++------ BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py | 1= 2 ++++++------ 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__ =3D=3D '__main__': return Value =20 def ValidatePcdName (Argument): - if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argu= ment) <> ['','']: + if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argu= ment) !=3D ['','']: Message =3D '%s is not in the form .' % (Argument) raise argparse.ArgumentTypeError(Message) return Argument =20 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) !=3D ['','']: Message =3D '%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 =20 # Skip the following code for modules without any binary files - if self.BinaryFileList <> None and self.BinaryFileList <> []: + if self.BinaryFileList !=3D None and self.BinaryFileList !=3D []: return =20 ### TODO: How to handles mixed source and binary modules @@ -4499,7 +4499,7 @@ class ModuleAutoGen(AutoGen): Dpx =3D GenDepex.DependencyExpression(self.DepexList[ModuleTyp= e], ModuleType, True) DpxFile =3D gAutoGenDepexFileName % {"module_name" : self.Name} =20 - if len(Dpx.PostfixNotation) <> 0: + if len(Dpx.PostfixNotation) !=3D 0: self.DepexGenerated =3D True =20 if Dpx.Generate(path.join(self.OutputDir, DpxFile)): diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Sou= rce/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] =3D Line =20 # find the build_rule_version - if Line and Line[0] =3D=3D "#" and Line.find(TAB_BUILD_RULE_VE= RSION) <> -1: - if Line.find("=3D") <> -1 and Line.find("=3D") < (len(Line= ) - 1) and (Line[(Line.find("=3D") + 1):]).split(): + if Line and Line[0] =3D=3D "#" and Line.find(TAB_BUILD_RULE_VE= RSION) !=3D -1: + if Line.find("=3D") !=3D -1 and Line.find("=3D") < (len(Li= ne) - 1) and (Line[(Line.find("=3D") + 1):]).split(): self._FileVersion =3D (Line[(Line.find("=3D") + 1):]).= split()[0] # skip empty or comment line if Line =3D=3D "" or Line[0] =3D=3D "#": diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/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, AutoGe= nH): } =20 if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE', 'MM_CORE_ST= ANDALONE']: - if Info.SourceFileList <> None and Info.SourceFileList <> []: + if Info.SourceFileList !=3D None and Info.SourceFileList !=3D []: if NumEntryPoints !=3D 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 GUID= s were found - if TokenSpaceList <> []: =20 + if TokenSpaceList !=3D []: AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in = this module\n\n") if Info.ModuleType in ["USER_DEFINED", "BASE"]: GuidType =3D "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: =20 # convert source files and binary files to build targets self.ResultFileList =3D [str(T.Target) for T in self._AutoGenObjec= t.CodaTargetList] - if len(self.ResultFileList) =3D=3D 0 and len(self._AutoGenObject.S= ourceFileList) <> 0: + if len(self.ResultFileList) =3D=3D 0 and len(self._AutoGenObject.S= ourceFileList) !=3D 0: EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build", ExtraData=3D"[%s]" % str(self._AutoGenObject)) =20 diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/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) =3D=3D type(0): return Value, (Value.bit_length() + 7) / 8 - if type(Value) <> type(''): + if type(Value) !=3D type(''): raise BadExpression('Type %s is %s' %(Value, type(Value))) Value =3D 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 Entr= ies declared for %s with no FvNameGuid declaration." % (self.UiFvName)) =20 - if self.FvNameGuid <> None and self.FvNameGuid <> '': + if self.FvNameGuid !=3D None and self.FvNameGuid !=3D '': TotalSize =3D 16 + 4 Buffer =3D '' if self.UsedSizeEnable: diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py b/BaseTools/Sou= rce/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__ =3D=3D '__main__': sys.exit(1) =20 Version =3D Process.communicate() - if Process.returncode <> 0: + if Process.returncode !=3D 0: print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') sys.exit(Process.returncode) print(Version[0]) @@ -208,7 +208,7 @@ if __name__ =3D=3D '__main__': # Process =3D subprocess.Popen('%s smime -sign -binary -signer "%s" -out= form DER -md sha256 -certfile "%s"' % (OpenSslCommand, args.SignerPrivateCe= rtFileName, args.OtherPublicCertFileName), stdin=3Dsubprocess.PIPE, stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) Signature =3D Process.communicate(input=3DFullInputFileBuffer)[0] - if Process.returncode <> 0: + if Process.returncode !=3D 0: sys.exit(Process.returncode) =20 # @@ -277,7 +277,7 @@ if __name__ =3D=3D '__main__': # Process =3D subprocess.Popen('%s smime -verify -inform DER -content %s= -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCert= FileName), stdin=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubp= rocess.PIPE, shell=3DTrue) Process.communicate(input=3Dargs.SignatureBuffer)[0] - if Process.returncode <> 0: + if Process.returncode !=3D 0: print('ERROR: Verification failed') os.remove (args.OutputFileName) sys.exit(Process.returncode) diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Generat= eKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateK= eys.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__ =3D=3D '__main__': sys.exit(1) =20 Version =3D Process.communicate() - if Process.returncode <> 0: + if Process.returncode !=3D 0: print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') sys.exit(Process.returncode) print(Version[0]) @@ -90,7 +90,7 @@ if __name__ =3D=3D '__main__': # # Check for output file argument # - if args.OutputFile <> None: + if args.OutputFile !=3D None: for Item in args.OutputFile: # # Save PEM filename and close output file @@ -103,14 +103,14 @@ if __name__ =3D=3D '__main__': # Process =3D subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslComm= and, Item.name), stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell= =3DTrue) Process.communicate() - if Process.returncode <> 0: + if Process.returncode !=3D 0: print('ERROR: RSA 2048 key generation failed') sys.exit(Process.returncode) =20 # # Check for input file argument # - if args.InputFile <> None: + if args.InputFile !=3D None: for Item in args.InputFile: # # Save PEM filename and close input file @@ -125,7 +125,7 @@ if __name__ =3D=3D '__main__': # Process =3D subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSs= lCommand, Item), stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell= =3DTrue) PublicKeyHexString =3D Process.communicate()[0].split('=3D')[1].strip() - if Process.returncode <> 0: + if Process.returncode !=3D 0: print('ERROR: Unable to extract public key from private key') sys.exit(Process.returncode) PublicKey =3D '' @@ -138,7 +138,7 @@ if __name__ =3D=3D '__main__': Process =3D subprocess.Popen('%s dgst -sha256 -binary' % (OpenSslComma= nd), stdin=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess= .PIPE, shell=3DTrue) Process.stdin.write (PublicKey) PublicKeyHash =3D PublicKeyHash + Process.communicate()[0] - if Process.returncode <> 0: + if Process.returncode !=3D 0: print('ERROR: Unable to extract SHA 256 hash of public key') sys.exit(Process.returncode) =20 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__ =3D=3D '__main__': sys.exit(1) =20 Version =3D Process.communicate() - if Process.returncode <> 0: + if Process.returncode !=3D 0: print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') sys.exit(Process.returncode) print(Version[0]) @@ -157,7 +157,7 @@ if __name__ =3D=3D '__main__': while len(PublicKeyHexString) > 0: PublicKey =3D PublicKey + chr(int(PublicKeyHexString[0:2],16)) PublicKeyHexString=3DPublicKeyHexString[2:] - if Process.returncode <> 0: + if Process.returncode !=3D 0: sys.exit(Process.returncode) =20 if args.MonotonicCountStr: @@ -179,7 +179,7 @@ if __name__ =3D=3D '__main__': # Process =3D subprocess.Popen('%s sha256 -sign "%s"' % (OpenSslCommand,= args.PrivateKeyFileName), stdin=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIP= E, stderr=3Dsubprocess.PIPE, shell=3DTrue) Signature =3D Process.communicate(input=3DFullInputFileBuffer)[0] - if Process.returncode <> 0: + if Process.returncode !=3D 0: sys.exit(Process.returncode) =20 # @@ -202,14 +202,14 @@ if __name__ =3D=3D '__main__': # # Verify that the Hash Type matches the expected SHA256 type # - if uuid.UUID(bytes_le =3D Header.HashType) <> EFI_HASH_ALGORITHM_SHA25= 6_GUID: + if uuid.UUID(bytes_le =3D Header.HashType) !=3D EFI_HASH_ALGORITHM_SHA= 256_GUID: print('ERROR: unsupport hash GUID') sys.exit(1) =20 # # Verify the public key # - if Header.PublicKey <> PublicKey: + if Header.PublicKey !=3D PublicKey: print('ERROR: Public key in input file does not match public key fro= m private key file') sys.exit(1) =20 @@ -228,7 +228,7 @@ if __name__ =3D=3D '__main__': # =20 Process =3D subprocess.Popen('%s sha256 -prverify "%s" -signature %s' = % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=3Ds= ubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell= =3DTrue) Process.communicate(input=3DFullInputFileBuffer) - if Process.returncode <> 0: + if Process.returncode !=3D 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 =3D Process.communicate() - if Process.returncode <> 0: + if Process.returncode !=3D 0: print('ERROR: Can not collect output from command:', Command) return Result[0], Result[1] =20 --=20 2.15.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel