From nobody Mon Dec 23 13:42:21 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 1517474224869342.36536796397274; Thu, 1 Feb 2018 00:37:04 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0FE2121E0B9EF; Thu, 1 Feb 2018 00:31:17 -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 BAF2421E0B9ED for ; Thu, 1 Feb 2018 00:31:15 -0800 (PST) Received: from localhost.localdomain (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Thu, 01 Feb 2018 09:36:49 +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: Thu, 1 Feb 2018 16:35:54 +0800 Message-Id: <20180201083608.16036-7-glin@suse.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180201083608.16036-1-glin@suse.com> References: <20180201083608.16036-1-glin@suse.com> Subject: [edk2] [PATCH v2 06/20] BaseTools: Remove the deprecated hash_key() 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 "has_key()" with "in" to be compatible with python3. Based on "futurize -f lib2to3.fixes.fix_has_key" Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Gary Lin --- BaseTools/Source/Python/AutoGen/AutoGen.py | 4 = ++-- BaseTools/Source/Python/Common/VpdInfoFile.py | 2 = +- BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py | 16 = ++++++++-------- BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py | 6 = +++--- BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py | 2 = +- BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py | 4 = ++-- BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py | 2 = +- BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py | 4 = ++-- BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py | 4 = ++-- BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py | 4 = ++-- BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py | 4 = ++-- BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py | 2 = +- BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py | 3 = +-- BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py | 4 = ++-- BaseTools/Source/Python/build/build.py | 2 = +- 15 files changed, 31 insertions(+), 32 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index 73ffff8a70d8..18da411f83a0 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1828,8 +1828,8 @@ class PlatformAutoGen(AutoGen): # retrieve BPDG tool's path from tool_def.txt according to VPD= _TOOL_GUID defined in DSC file. BPDGToolName =3D None for ToolDef in self.ToolDefinition.values(): - if ToolDef.has_key("GUID") and ToolDef["GUID"] =3D=3D self= .Platform.VpdToolGuid: - if not ToolDef.has_key("PATH"): + if "GUID" in ToolDef and ToolDef["GUID"] =3D=3D self.Platf= orm.VpdToolGuid: + if "PATH" not in ToolDef: EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, = "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % = self.Platform.VpdToolGuid) BPDGToolName =3D ToolDef["PATH"] break diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Sour= ce/Python/Common/VpdInfoFile.py index 280cdfb536a6..84dd7ac563dd 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -212,7 +212,7 @@ class VpdInfoFile: # # @param vpd A given VPD PCD=20 def GetOffset(self, vpd): - if not self._VpdArray.has_key(vpd): + if vpd not in self._VpdArray: return None =20 if len(self._VpdArray[vpd]) =3D=3D 0: diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py b/BaseTo= ols/Source/Python/UPT/GenMetaFile/GenInfFile.py index 517f2a6cdecd..4a9528b500f2 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py @@ -439,14 +439,14 @@ def GenLibraryClasses(ModuleObject): Statement =3D '# Guid: ' + LibraryItem.Guid + ' Version: '= + LibraryItem.Version =20 if len(BinaryFile.SupArchList) =3D=3D 0: - if LibraryClassDict.has_key('COMMON') and Statement no= t in LibraryClassDict['COMMON']: + if 'COMMON' in LibraryClassDict and Statement not in L= ibraryClassDict['COMMON']: LibraryClassDict['COMMON'].append(Statement) else: LibraryClassDict['COMMON'] =3D ['## @LIB_INSTANCES= '] LibraryClassDict['COMMON'].append(Statement) else: for Arch in BinaryFile.SupArchList: - if LibraryClassDict.has_key(Arch): + if Arch in LibraryClassDict: if Statement not in LibraryClassDict[Arch]: LibraryClassDict[Arch].append(Statement) else: @@ -918,14 +918,14 @@ def GenAsBuiltPacthPcdSections(ModuleObject): if FileNameObjList: ArchList =3D FileNameObjList[0].GetSupArchList() if len(ArchList) =3D=3D 0: - if PatchPcdDict.has_key(DT.TAB_ARCH_COMMON): + if DT.TAB_ARCH_COMMON in PatchPcdDict: if Statement not in PatchPcdDict[DT.TAB_ARCH_COMMON]: PatchPcdDict[DT.TAB_ARCH_COMMON].append(Statement) else: PatchPcdDict[DT.TAB_ARCH_COMMON] =3D [Statement] else: for Arch in ArchList: - if PatchPcdDict.has_key(Arch): + if Arch in PatchPcdDict: if Statement not in PatchPcdDict[Arch]: PatchPcdDict[Arch].append(Statement) else: @@ -968,13 +968,13 @@ def GenAsBuiltPcdExSections(ModuleObject): ArchList =3D FileNameObjList[0].GetSupArchList() =20 if len(ArchList) =3D=3D 0: - if PcdExDict.has_key('COMMON'): + if 'COMMON' in PcdExDict: PcdExDict['COMMON'].append(Statement) else: PcdExDict['COMMON'] =3D [Statement] else: for Arch in ArchList: - if PcdExDict.has_key(Arch): + if Arch in PcdExDict: if Statement not in PcdExDict[Arch]: PcdExDict[Arch].append(Statement) else: @@ -1072,7 +1072,7 @@ def GenBuildOptions(ModuleObject): for BuilOptionItem in BinaryFile.AsBuiltList[0].BinaryBuildFla= gList: Statement =3D '#' + BuilOptionItem.AsBuiltOptionFlags if len(BinaryFile.SupArchList) =3D=3D 0: - if BuildOptionDict.has_key('COMMON'): + if 'COMMON' in BuildOptionDict: if Statement not in BuildOptionDict['COMMON']: BuildOptionDict['COMMON'].append(Statement) else: @@ -1080,7 +1080,7 @@ def GenBuildOptions(ModuleObject): BuildOptionDict['COMMON'].append(Statement) else: for Arch in BinaryFile.SupArchList: - if BuildOptionDict.has_key(Arch): + if Arch in BuildOptionDict: if Statement not in BuildOptionDict[Arch]: BuildOptionDict[Arch].append(Statement) else: diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py b= /BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py index f968beee6081..a829c0cfe34c 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py @@ -272,7 +272,7 @@ class InfBinariesObject(InfSectionCommonDef): pass =20 if InfBianryVerItemObj !=3D None: - if self.Binaries.has_key((InfBianryVerItemObj)): + if (InfBianryVerItemObj) in self.Binaries: BinariesList =3D self.Binaries[InfBianryVerItemObj] BinariesList.append((InfBianryVerItemObj, VerComment)) self.Binaries[InfBianryVerItemObj] =3D BinariesList @@ -522,7 +522,7 @@ class InfBinariesObject(InfSectionCommonDef): # pass =20 if InfBianryCommonItemObj !=3D None: - if self.Binaries.has_key((InfBianryCommonItemObj)): + if (InfBianryCommonItemObj) in self.Binaries: BinariesList =3D self.Binaries[InfBianryCommonItemObj] BinariesList.append((InfBianryCommonItemObj, ItemComme= nt)) self.Binaries[InfBianryCommonItemObj] =3D BinariesList @@ -673,7 +673,7 @@ class InfBinariesObject(InfSectionCommonDef): # pass =20 if InfBianryUiItemObj !=3D None: - if self.Binaries.has_key((InfBianryUiItemObj)): + if (InfBianryUiItemObj) in self.Binaries: BinariesList =3D self.Binaries[InfBianryUiItem= Obj] BinariesList.append((InfBianryUiItemObj, UiCom= ment)) self.Binaries[InfBianryUiItemObj] =3D Binaries= List diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py b= /BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py index 1d074ee638fd..2c9ea6ccd2cc 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py @@ -957,7 +957,7 @@ class InfDefObject(InfSectionCommonDef): SpecValue =3D Name[Name.find("SPEC") + len("SPEC"):].s= trip() Name =3D "SPEC" Value =3D SpecValue + " =3D " + Value - if self.Defines.has_key(ArchListString): + if ArchListString in self.Defines: DefineList =3D self.Defines[ArchListString] = =20 LineInfo[0] =3D InfDefMemberObj.CurrentLine.GetFileNam= e() LineInfo[1] =3D InfDefMemberObj.CurrentLine.GetLineNo() diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py b/B= aseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py index 23125552e06d..e546127bd3e6 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py @@ -338,7 +338,7 @@ class InfGuidObject(): # pass =20 - if self.Guids.has_key((InfGuidItemObj)): =20 + if (InfGuidItemObj) in self.Guids: GuidList =3D self.Guids[InfGuidItemObj] =20 GuidList.append(InfGuidItemObj) self.Guids[InfGuidItemObj] =3D GuidList @@ -350,4 +350,4 @@ class InfGuidObject(): return True =20 def GetGuid(self): - return self.Guids \ No newline at end of file + return self.Guids diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObj= ect.py b/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.= py index b18c4c381bc0..4c3233b73552 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py @@ -238,7 +238,7 @@ class InfLibraryClassObject(): LibItemObj.SetVersion(LibItem[1]) LibItemObj.SetSupArchList(__SupArchList) =20 - if self.LibraryClasses.has_key((LibItemObj)): + if (LibItemObj) in self.LibraryClasses: LibraryList =3D self.LibraryClasses[LibItemObj] LibraryList.append(LibItemObj) self.LibraryClasses[LibItemObj] =3D LibraryList diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py b/BaseToo= ls/Source/Python/UPT/Object/Parser/InfMisc.py index 74099e208860..081e69db5feb 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py @@ -114,7 +114,7 @@ class InfSpecialCommentObject(InfSectionCommonDef): Type =3D=3D DT.TYPE_EVENT_SECTION or \ Type =3D=3D DT.TYPE_BOOTMODE_SECTION: for Item in SepcialSectionList: - if self.SpecialComments.has_key(Type): =20 + if Type in self.SpecialComments: ObjList =3D self.SpecialComments[Type] ObjList.append(Item) self.SpecialComments[Type] =3D ObjList @@ -145,4 +145,4 @@ def ErrorInInf(Message=3DNone, ErrorCode=3DNone, LineIn= fo=3DNone, RaiseError=3DTrue): File=3DLineInfo[0],=20 Line=3DLineInfo[1], ExtraData=3DLineInfo[2],=20 - RaiseError=3DRaiseError) \ No newline at end of file + RaiseError=3DRaiseError) diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py= b/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py index 37399134dbf3..164260ffbfef 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py @@ -171,7 +171,7 @@ class InfPackageObject(): # pass =20 - if self.Packages.has_key((PackageItemObj)): =20 + if (PackageItemObj) in self.Packages: PackageList =3D self.Packages[PackageItemObj] PackageList.append(PackageItemObj) self.Packages[PackageItemObj] =3D PackageList @@ -184,4 +184,4 @@ class InfPackageObject(): =20 def GetPackages(self, Arch =3D None): if Arch =3D=3D None: - return self.Packages \ No newline at end of file + return self.Packages diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py b/Ba= seTools/Source/Python/UPT/Object/Parser/InfPcdObject.py index 7b07036f91c2..b5ca01f148d1 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py @@ -411,7 +411,7 @@ class InfPcdObject(): else: PcdItemObj.SetSupportArchList(SupArchList) =20 - if self.Pcds.has_key((PcdTypeItem, PcdItemObj)): + if (PcdTypeItem, PcdItemObj) in self.Pcds: PcdsList =3D self.Pcds[PcdTypeItem, PcdItemObj] PcdsList.append(PcdItemObj) self.Pcds[PcdTypeItem, PcdItemObj] =3D PcdsList @@ -456,7 +456,7 @@ class InfPcdObject(): PackageInfo) =20 PcdTypeItem =3D KeysList[0][0] - if self.Pcds.has_key((PcdTypeItem, PcdItemObj)): + if (PcdTypeItem, PcdItemObj) in self.Pcds: PcdsList =3D self.Pcds[PcdTypeItem, PcdItemObj] PcdsList.append(PcdItemObj) self.Pcds[PcdTypeItem, PcdItemObj] =3D PcdsList diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py b/Ba= seTools/Source/Python/UPT/Object/Parser/InfPpiObject.py index 4df62bb459ff..53e1f342cac5 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py @@ -327,7 +327,7 @@ class InfPpiObject(): #=20 pass =20 - if self.Ppis.has_key((InfPpiItemObj)): =20 + if (InfPpiItemObj) in self.Ppis: PpiList =3D self.Ppis[InfPpiItemObj] PpiList.append(InfPpiItemObj) self.Ppis[InfPpiItemObj] =3D PpiList @@ -340,4 +340,4 @@ class InfPpiObject(): =20 =20 def GetPpi(self): - return self.Ppis \ No newline at end of file + return self.Ppis diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py= b/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py index c94e53c98f87..e552cb627b5e 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py @@ -296,7 +296,7 @@ class InfProtocolObject(): # pass =20 =20 - if self.Protocols.has_key((InfProtocolItemObj)): =20 + if (InfProtocolItemObj) in self.Protocols: ProcotolList =3D self.Protocols[InfProtocolItemObj] ProcotolList.append(InfProtocolItemObj) self.Protocols[InfProtocolItemObj] =3D ProcotolList diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py b= /BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py index 9988f8ecfeed..93ae21e16b76 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py @@ -224,7 +224,7 @@ class InfSourcesObject(InfSectionCommonDef): =20 ItemObj.SetSupArchList(__SupArchList)=20 = =20 - if self.Sources.has_key((ItemObj)): =20 + if (ItemObj) in self.Sources: SourceContent =3D self.Sources[ItemObj] SourceContent.append(ItemObj) self.Sources[ItemObj] =3D SourceContent @@ -237,4 +237,3 @@ class InfSourcesObject(InfSectionCommonDef): =20 def GetSources(self): return self.Sources - =20 \ No newline at end of file diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObje= ct.py b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py index 27a1c6ad25a0..f9db2944a495 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py @@ -103,7 +103,7 @@ class InfUserExtensionObject(): # Line=3DLineNo, # ExtraData=3DNone) =20 - if self.UserExtension.has_key(IdContentItem): =20 + if IdContentItem in self.UserExtension: # # Each UserExtensions section header must have a unique se= t=20 # of UserId, IdString and Arch values. @@ -130,4 +130,4 @@ class InfUserExtensionObject(): return True =20 def GetUserExtension(self): - return self.UserExtension \ No newline at end of file + return self.UserExtension diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index 68dca8e21524..c6a37ab1d9a3 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -75,7 +75,7 @@ TmpTableDict =3D {} # Otherwise, False is returned # def IsToolInPath(tool): - if os.environ.has_key('PATHEXT'): + if 'PATHEXT' in os.environ: extns =3D os.environ['PATHEXT'].split(os.path.pathsep) else: extns =3D ('',) --=20 2.16.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel