From nobody Sun May 5 11:20:55 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 1523577738306963.6557855867696; Thu, 12 Apr 2018 17:02:18 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D8DEE226EAC6F; Thu, 12 Apr 2018 17:02:15 -0700 (PDT) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 73E2C226CD7BE for ; Thu, 12 Apr 2018 17:02:14 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Apr 2018 17:02:13 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga004.jf.intel.com with ESMTP; 12 Apr 2018 17:02:13 -0700 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=192.55.52.136; helo=mga12.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,444,1517904000"; d="scan'208";a="191109782" From: Jaben To: edk2-devel@lists.01.org Date: Thu, 12 Apr 2018 17:02:10 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 1/2] BaseTools: fix None comparisons X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 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" when comparing a list/string against None and empty, just compare the objec= t. when comparing against None, dont use !=3D, =3D=3D, <> Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey Reviewed-by: Yonghong Zhu =20 --- BaseTools/Source/Python/AutoGen/AutoGen.py | 2= +- BaseTools/Source/Python/AutoGen/GenC.py | 2= +- BaseTools/Source/Python/GenFds/Fv.py | 5= ++--- BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py | 6= +++--- BaseTools/Source/Python/Workspace/DscBuildData.py | 4= ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index dbc9f893c2f1..2613c77a7a10 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1675,7 +1675,7 @@ class PlatformAutoGen(AutoGen): DscPcdEntry.TokenValue =3D Dec= PcdEntry.TokenValue DscPcdEntry.TokenSpaceGuidValu= e =3D eachDec.Guids[DecPcdEntry.TokenSpaceGuidCName] # Only fix the value while no = value provided in DSC file. - if (Sku.DefaultValue =3D=3D ""= or Sku.DefaultValue=3D=3DNone): + if not Sku.DefaultValue: DscPcdEntry.SkuInfoList[Ds= cPcdEntry.SkuInfoList.keys()[0]].DefaultValue =3D DecPcdEntry.DefaultValue = =20 if DscPcdEntry not in self._DynamicPcdList: diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/AutoGen/GenC.py index 58da9e6b1784..a15eb707421e 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1534,7 +1534,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: if NumEntryPoints !=3D 1: EdkLogger.error( "build", diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python= /GenFds/Fv.py index 345ad3bdcc90..aae644bef905 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -337,11 +337,10 @@ class FV (FvClassObject): # # Generate FV extension header file # - if self.FvNameGuid is None or self.FvNameGuid =3D=3D '': + if not self.FvNameGuid: 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 <> '': + else: TotalSize =3D 16 + 4 Buffer =3D '' if self.UsedSizeEnable: diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Generat= eKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateK= eys.py index 95a636966c59..9711de8f5c2e 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py @@ -9,7 +9,7 @@ # on STDOUT. # This tool has been tested with OpenSSL 1.0.1e 11 Feb 2013 # -# Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License # which accompanies this distribution. The full text of the license may b= e found at @@ -89,7 +89,7 @@ if __name__ =3D=3D '__main__': # # Check for output file argument # - if args.OutputFile <> None: + if args.OutputFile is not None: for Item in args.OutputFile: # # Save PEM filename and close output file @@ -109,7 +109,7 @@ if __name__ =3D=3D '__main__': # # Check for input file argument # - if args.InputFile <> None: + if args.InputFile is not None: for Item in args.InputFile: # # Save PEM filename and close input file diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 6766f059b0f7..9c77d6c50c27 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -2292,7 +2292,7 @@ class DscBuildData(PlatformBuildClassObject): pcdDecObject =3D self._DecPcds[pcd.TokenCName, pcd.TokenSpaceG= uidCName] # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): - if (sku.DefaultValue =3D=3D "" or sku.DefaultValue=3D=3DNo= ne): + if not sku.DefaultValue: sku.DefaultValue =3D pcdDecObject.DefaultValue if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in= pcd.SkuInfoList.keys(): valuefromDec =3D pcdDecObject.DefaultValue @@ -2624,7 +2624,7 @@ class DscBuildData(PlatformBuildClassObject): pcd.DatumType =3D pcdDecObject.DatumType # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): - if (sku.DefaultValue =3D=3D "" or sku.DefaultValue=3D=3DNo= ne): + if not sku.DefaultValue: sku.DefaultValue =3D pcdDecObject.DefaultValue if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in= pcd.SkuInfoList.keys(): valuefromDec =3D pcdDecObject.DefaultValue --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun May 5 11:20:55 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 1523577742090369.60964142886576; Thu, 12 Apr 2018 17:02:22 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1EF9D226EAC8D; Thu, 12 Apr 2018 17:02:16 -0700 (PDT) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 913CC2267F0F7 for ; Thu, 12 Apr 2018 17:02:14 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Apr 2018 17:02:13 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga004.jf.intel.com with ESMTP; 12 Apr 2018 17:02:13 -0700 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=192.55.52.136; helo=mga12.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,444,1517904000"; d="scan'208";a="191109785" From: Jaben To: edk2-devel@lists.01.org Date: Thu, 12 Apr 2018 17:02:11 -0700 Message-Id: <84e362fee3a440210443eb3305739a85b35fa8c7.1523577634.git.jaben.carsey@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 2/2] BaseTools: refactor and remove un-needed use of .keys() on dictionaries X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 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" sometimes just delete it. sometimes the loop needed .values() instead Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/AutoGen.py | 32 +++++----- BaseTools/Source/Python/AutoGen/GenMake.py | 24 ++++---- BaseTools/Source/Python/AutoGen/GenVar.py | 2 +- BaseTools/Source/Python/AutoGen/InfSectionParser.py | 6 +- BaseTools/Source/Python/BPDG/GenVpd.py | 2 +- BaseTools/Source/Python/Common/EdkIIWorkspace.py | 5 +- BaseTools/Source/Python/Common/Expression.py | 4 +- BaseTools/Source/Python/Common/Misc.py | 4 +- BaseTools/Source/Python/Common/Parsing.py | 13 ++--- BaseTools/Source/Python/Common/String.py | 2 +- BaseTools/Source/Python/Common/VpdInfoFile.py | 8 +-- BaseTools/Source/Python/GenFds/Capsule.py | 8 +-- BaseTools/Source/Python/GenFds/CapsuleData.py | 10 ++-- BaseTools/Source/Python/GenFds/Fd.py | 4 +- BaseTools/Source/Python/GenFds/FdfParser.py | 18 +++--- BaseTools/Source/Python/GenFds/FfsFileStatement.py | 6 +- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 2 +- BaseTools/Source/Python/GenFds/Fv.py | 14 ++--- BaseTools/Source/Python/GenFds/GenFds.py | 61 +++++++++-----= ------ BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 4 +- BaseTools/Source/Python/GenFds/Region.py | 12 ++-- BaseTools/Source/Python/TargetTool/TargetTool.py | 8 +-- BaseTools/Source/Python/Workspace/DscBuildData.py | 40 ++++++------- BaseTools/Source/Python/Workspace/InfBuildData.py | 5 +- BaseTools/Source/Python/Workspace/MetaFileParser.py | 4 +- BaseTools/Source/Python/Workspace/WorkspaceCommon.py | 6 +- BaseTools/Source/Python/build/BuildReport.py | 4 +- BaseTools/Source/Python/build/build.py | 22 ++++--- 28 files changed, 154 insertions(+), 176 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index 2613c77a7a10..eab25d99d017 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -769,7 +769,7 @@ class WorkspaceAutoGen(AutoGen): for Module in Pa.ModuleAutoGenList: if path.normpath(Module.MetaFile.File) =3D=3D = path.normpath(FfsFile.InfFileName): InfFoundFlag =3D True - if not Module.Guid.upper() in _GuidDict.ke= ys(): + if Module.Guid.upper() not in _GuidDict: _GuidDict[Module.Guid.upper()] =3D Ffs= File break else: @@ -796,7 +796,7 @@ class WorkspaceAutoGen(AutoGen): # BuildObject from one of AutoGenObjectList is= enough. # InfObj =3D self.AutoGenObjectList[0].BuildData= base.WorkspaceDb.BuildObject[PathClassObj, 'COMMON', self.BuildTarget, self= .ToolChain] - if not InfObj.Guid.upper() in _GuidDict.keys(): + if InfObj.Guid.upper() not in _GuidDict: _GuidDict[InfObj.Guid.upper()] =3D FfsFile else: EdkLogger.error("build", @@ -844,7 +844,7 @@ class WorkspaceAutoGen(AutoGen): "The format of= PCD value is incorrect. PCD: %s , Value: %s\n" % (_PcdName, PcdItem.Defaul= tValue), ExtraData=3Dse= lf.FdfFile) =20 - if not _PcdGuidString.upper() in _= GuidDict.keys(): + if _PcdGuidString.upper() not in _= GuidDict: _GuidDict[_PcdGuidString.upper= ()] =3D FfsFile PcdFoundFlag =3D True break @@ -858,7 +858,7 @@ class WorkspaceAutoGen(AutoGen): = FfsFile.Na= meGuid.upper()), ExtraData=3Dse= lf.FdfFile) =20 - if not FfsFile.NameGuid.upper() in _GuidDict.keys(): + if FfsFile.NameGuid.upper() not in _GuidDict: _GuidDict[FfsFile.NameGuid.upper()] =3D FfsFile else: # @@ -1409,10 +1409,8 @@ class PlatformAutoGen(AutoGen): PcdFromModule.IsFromBinaryInf =3D True =20 # Check the PCD from DSC or not=20 - if (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuid= CName) in self.Platform.Pcds.keys(): - PcdFromModule.IsFromDsc =3D True - else: - PcdFromModule.IsFromDsc =3D False + PcdFromModule.IsFromDsc =3D (PcdFromModule.TokenCName, Pcd= FromModule.TokenSpaceGuidCName) in self.Platform.Pcds + =20 if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule= .Type in GenC.gDynamicExPcd: if F.Path not in FdfModuleList: # If one of the Source built modules listed in the= DSC is not listed=20 @@ -1542,8 +1540,8 @@ class PlatformAutoGen(AutoGen): VpdFile =3D VpdInfoFile.VpdInfoFile() NeedProcessVpdMapFile =3D False =20 - for pcd in self.Platform.Pcds.keys(): - if pcd not in self._PlatformPcds.keys(): + for pcd in self.Platform.Pcds: + if pcd not in self._PlatformPcds: self._PlatformPcds[pcd] =3D self.Platform.Pcds[pcd] =20 for item in self._PlatformPcds: @@ -1553,7 +1551,7 @@ class PlatformAutoGen(AutoGen): if (self.Workspace.ArchList[-1] =3D=3D self.Arch):=20 for Pcd in self._DynamicPcdList: # just pick the a value to determine whether is unicode st= ring type - Sku =3D Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]] + Sku =3D Pcd.SkuInfoList.values()[0] Sku.VpdOffset =3D Sku.VpdOffset.strip() =20 if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32= , TAB_UINT64, TAB_VOID, "BOOLEAN"]: @@ -1640,7 +1638,7 @@ class PlatformAutoGen(AutoGen): if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYN= AMIC_EX_VPD]: if not (self.Platform.VpdToolGuid is None or self.Plat= form.VpdToolGuid =3D=3D ''): FoundFlag =3D False - for VpdPcd in VpdFile._VpdArray.keys(): + for VpdPcd in VpdFile._VpdArray: # This PCD has been referenced by module if (VpdPcd.TokenSpaceGuidCName =3D=3D DscPcdEn= try.TokenSpaceGuidCName) and \ (VpdPcd.TokenCName =3D=3D DscPcdEntry.Token= CName): @@ -1752,7 +1750,7 @@ class PlatformAutoGen(AutoGen): # Delete the DynamicPcdList At the last time enter into this f= unction for Pcd in self._DynamicPcdList: # just pick the a value to determine whether is unicode st= ring type - Sku =3D Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]] + Sku =3D Pcd.SkuInfoList.values()[0] Sku.VpdOffset =3D Sku.VpdOffset.strip() =20 if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32= , TAB_UINT64, TAB_VOID, "BOOLEAN"]: @@ -2492,7 +2490,7 @@ class PlatformAutoGen(AutoGen): for LibraryName in M.Libraries: Library =3D self.Platform.LibraryClasses[LibraryName, ':du= mmy:'] if Library is None: - for Key in self.Platform.LibraryClasses.data.keys(): + for Key in self.Platform.LibraryClasses.data: if LibraryName.upper() =3D=3D Key.upper(): Library =3D self.Platform.LibraryClasses[Key, = ':dummy:'] break @@ -3115,7 +3113,7 @@ class ModuleAutoGen(AutoGen): InfObj =3D InfSectionParser.InfSectionParser(Filename) DepexExpresionList =3D InfObj.GetDepexExpresionList() for DepexExpresion in DepexExpresionList: - for key in DepexExpresion.keys(): + for key in DepexExpresion: Arch, ModuleType =3D key DepexExpr =3D [x for x in DepexExpresion[key] if not s= tr(x).startswith('#')] # the type of build module is USER_DEFINED. @@ -3133,7 +3131,7 @@ class ModuleAutoGen(AutoGen): #the type of build module is USER_DEFINED. if self.ModuleType.upper() =3D=3D SUP_MODULE_USER_DEFINED: for Depex in DepexList: - for key in Depex.keys(): + for key in Depex: DepexStr +=3D '[Depex.%s.%s]\n' % key DepexStr +=3D '\n'.join(['# '+ val for val in Depex[ke= y]]) DepexStr +=3D '\n\n' @@ -3243,7 +3241,7 @@ class ModuleAutoGen(AutoGen): InfObj =3D InfSectionParser.InfSectionParser(Filename) TianoCoreUserExtenList =3D InfObj.GetUserExtensionTianoCore() for TianoCoreUserExtent in TianoCoreUserExtenList: - for Section in TianoCoreUserExtent.keys(): + for Section in TianoCoreUserExtent: ItemList =3D Section.split(TAB_SPLIT) Arch =3D self.Arch if len(ItemList) =3D=3D 4: diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index b7594d8988da..1bb5163e73e0 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -495,11 +495,11 @@ cleanlib: if k not in self._AutoGenObject.Macros: self._AutoGenObject.Macros[k] =3D v =20 - if 'MODULE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys(): + if 'MODULE_ENTRY_POINT' not in self._AutoGenObject.Macros: self._AutoGenObject.Macros['MODULE_ENTRY_POINT'] =3D ModuleEnt= ryPoint - if 'ARCH_ENTRY_POINT' not in self._AutoGenObject.Macros.keys(): + if 'ARCH_ENTRY_POINT' not in self._AutoGenObject.Macros: self._AutoGenObject.Macros['ARCH_ENTRY_POINT'] =3D ArchEntryPo= int - if 'IMAGE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys(): + if 'IMAGE_ENTRY_POINT' not in self._AutoGenObject.Macros: self._AutoGenObject.Macros['IMAGE_ENTRY_POINT'] =3D ImageEntry= Point =20 PCI_COMPRESS_Flag =3D False @@ -540,7 +540,7 @@ cleanlib: RespFileList =3D os.path.join(self._AutoGenObject.OutputDir, 'resp= filelist.txt') if RespDict: RespFileListContent =3D '' - for Resp in RespDict.keys(): + for Resp in RespDict: RespFile =3D os.path.join(self._AutoGenObject.OutputDir, s= tr(Resp).lower() + '.txt') StrList =3D RespDict[Resp].split(' ') UnexpandMacro =3D [] @@ -794,7 +794,7 @@ cleanlib: SingleCommandLength =3D len(SingleCommand) SingleCommandList =3D SingleCommand.split() if len(SingleCommandList) > 0: - for Flag in FlagDict.keys(): + for Flag in FlagDict: if '$('+ Flag +')' in SingleCommandList[0]: Tool =3D Flag break @@ -807,12 +807,12 @@ cleanlib: if 'FLAGS' not in self._AutoGenObject.= _BuildOption[Tool]: EdkLogger.error("build", AUTOGEN_E= RROR, "%s_FLAGS doesn't exist in %s ToolChain and %s Arch." %(Tool, self._A= utoGenObject.ToolChain, self._AutoGenObject.Arch), ExtraData=3D"[%s]" % str= (self._AutoGenObject)) Str =3D self._AutoGenObject._BuildOpti= on[Tool]['FLAGS'] - for Option in self._AutoGenObject.Buil= dOption.keys(): + for Option in self._AutoGenObject.Buil= dOption: for Attr in self._AutoGenObject.Bu= ildOption[Option]: if Str.find(Option + '_' + Att= r) !=3D -1: Str =3D Str.replace('$(' += Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) while(Str.find('$(') !=3D -1): - for macro in self._AutoGenObject.M= acros.keys(): + for macro in self._AutoGenObject.M= acros: MacroName =3D '$('+ macro + ')' if (Str.find(MacroName) !=3D -= 1): Str =3D Str.replace(MacroN= ame, self._AutoGenObject.Macros[macro]) @@ -824,12 +824,12 @@ cleanlib: SingleCommandLength +=3D self._AutoGen= Object.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._Includ= ePathList) elif item.find('$(') !=3D -1: Str =3D item - for Option in self._AutoGenObject.Buil= dOption.keys(): + for Option in self._AutoGenObject.Buil= dOption: for Attr in self._AutoGenObject.Bu= ildOption[Option]: if Str.find(Option + '_' + Att= r) !=3D -1: Str =3D Str.replace('$(' += Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) while(Str.find('$(') !=3D -1): - for macro in self._AutoGenObject.M= acros.keys(): + for macro in self._AutoGenObject.M= acros: MacroName =3D '$('+ macro + ')' if (Str.find(MacroName) !=3D -= 1): Str =3D Str.replace(MacroN= ame, self._AutoGenObject.Macros[macro]) @@ -842,19 +842,19 @@ cleanlib: FlagDict[Tool]['Value'] =3D True =20 # generate the response file content by combine the FLAGS = and INC - for Flag in FlagDict.keys(): + for Flag in FlagDict: if FlagDict[Flag]['Value']: Key =3D Flag + '_RESP' RespMacro =3D FlagDict[Flag]['Macro'].replace('FLA= GS', 'RESP') Value =3D self._AutoGenObject.BuildOption[Flag]['F= LAGS'] for inc in self._AutoGenObject._IncludePathList: Value +=3D ' ' + IncPrefix + inc - for Option in self._AutoGenObject.BuildOption.keys= (): + for Option in self._AutoGenObject.BuildOption: for Attr in self._AutoGenObject.BuildOption[Op= tion]: if Value.find(Option + '_' + Attr) !=3D -1: Value =3D Value.replace('$(' + Option = + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) while (Value.find('$(') !=3D -1): - for macro in self._AutoGenObject.Macros.keys(): + for macro in self._AutoGenObject.Macros: MacroName =3D '$('+ macro + ')' if (Value.find(MacroName) !=3D -1): Value =3D Value.replace(MacroName, sel= f._AutoGenObject.Macros[macro]) diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/P= ython/AutoGen/GenVar.py index d222e6ed5e7e..5d5e8637b6bd 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -113,8 +113,8 @@ class VariableMgr(object): self.VarInfo =3D [item[0] for item in indexedvarinfo.values()] =20 def assemble_variable(self, valuelist): - ordered_value =3D [valuelist[k] for k in sorted(valuelist.keys())] ordered_offset =3D sorted(valuelist.keys()) + ordered_value =3D [valuelist[k] for k in ordered_offset] var_value =3D [] num =3D 0 for offset in ordered_offset: diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTool= s/Source/Python/AutoGen/InfSectionParser.py index cdc9e5e8a849..cf4e76159e81 100644 --- a/BaseTools/Source/Python/AutoGen/InfSectionParser.py +++ b/BaseTools/Source/Python/AutoGen/InfSectionParser.py @@ -1,7 +1,7 @@ ## @file # Parser a Inf file and Get specify section data. # -# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License # which accompanies this distribution. The full text of the license may b= e found at @@ -70,7 +70,7 @@ class InfSectionParser(): if not self._FileSectionDataList: return UserExtensionTianoCore for SectionDataDict in self._FileSectionDataList: - for key in SectionDataDict.keys(): + for key in SectionDataDict: if key.lower().startswith("[userextensions") and key.lower= ().find('.tianocore.') > -1: SectionLine =3D key.lstrip(TAB_SECTION_START).rstrip(T= AB_SECTION_END) SubSectionList =3D [SectionLine] @@ -89,7 +89,7 @@ class InfSectionParser(): if not self._FileSectionDataList: return DepexExpresionList for SectionDataDict in self._FileSectionDataList: - for key in SectionDataDict.keys(): + for key in SectionDataDict: if key.lower() =3D=3D "[depex]" or key.lower().startswith(= "[depex."): SectionLine =3D key.lstrip(TAB_SECTION_START).rstrip(T= AB_SECTION_END) SubSectionList =3D [SectionLine] diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Pyth= on/BPDG/GenVpd.py index 887240e94cb4..69a9665f5a76 100644 --- a/BaseTools/Source/Python/BPDG/GenVpd.py +++ b/BaseTools/Source/Python/BPDG/GenVpd.py @@ -120,7 +120,7 @@ class PcdEntry: #=20 # =20 def _PackIntValue(self, IntValue, Size): - if Size not in _FORMAT_CHAR.keys(): + if Size not in _FORMAT_CHAR: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid size %d for PCD %s in integer datum s= ize(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno= )) =20 diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspace.py b/BaseTools/S= ource/Python/Common/EdkIIWorkspace.py index c14b4eb52d50..9d1bb12485f9 100644 --- a/BaseTools/Source/Python/Common/EdkIIWorkspace.py +++ b/BaseTools/Source/Python/Common/EdkIIWorkspace.py @@ -259,10 +259,7 @@ def ConvertDictionaryToTextFile(FileName, Dictionary, = CommentCharacter, KeySplit except: Lines =3D [] Keys =3D Dictionary.keys() - MaxLength =3D 0 - for Key in Keys: - if len(Key) > MaxLength: - MaxLength =3D len(Key) + MaxLength =3D max(map(len,Keys)) Index =3D 0 for Line in Lines: LineList =3D Line.split(KeySplitCharacter, 1) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 462e8f93f883..9a3415ccaabe 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -151,7 +151,7 @@ def ReplaceExprMacro(String, Macros, ExceptionList =3D = None): InQuote =3D True MacroStartPos =3D String.find('$(') if MacroStartPos < 0: - for Pcd in gPlatformPcds.keys(): + for Pcd in gPlatformPcds: if Pcd in String: if Pcd not in gConditionalPcds: gConditionalPcds.append(Pcd) @@ -908,7 +908,7 @@ class ValueExpressionEx(ValueExpression): for Label in LabelList: if not IsValidCName(Label): raise BadExpression('%s is not a v= alid c variable name' % Label) - if Label not in LabelDict.keys(): + if Label not in LabelDict: LabelDict[Label] =3D str(LabelOffs= et) if Item.startswith('UINT8'): LabelOffset =3D LabelOffset + 1 diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index 23c1a4a0b236..54b11cd2e54e 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1918,7 +1918,7 @@ class DefaultStore(): if not self.DefaultStores or "0" in self.DefaultStores: return "0",TAB_DEFAULT_STORES_DEFAULT else: - minvalue =3D min([int(value_str) for value_str in self.Default= Stores.keys()]) + minvalue =3D min([int(value_str) for value_str in self.Default= Stores]) return (str(minvalue), self.DefaultStores[str(minvalue)]) def GetMin(self,DefaultSIdList): if not DefaultSIdList: @@ -1958,7 +1958,7 @@ class SkuClass(): self.SkuIdSet =3D ['DEFAULT'] self.SkuIdNumberSet =3D ['0U'] elif SkuIdentifier =3D=3D 'ALL': - self.SkuIdSet =3D SkuIds.keys() + self.SkuIdSet =3D SkuIds self.SkuIdNumberSet =3D [num[0].strip() + 'U' for num in SkuId= s.values()] else: r =3D SkuIdentifier.split('|')=20 diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/P= ython/Common/Parsing.py index d199d1e40d8e..3518c86fc53c 100644 --- a/BaseTools/Source/Python/Common/Parsing.py +++ b/BaseTools/Source/Python/Common/Parsing.py @@ -37,16 +37,14 @@ def ParseDefineMacro2(Table, RecordSets, GlobalMacro): # # Overrided by Global Macros # - for Key in GlobalMacro.keys(): - Macros[Key] =3D GlobalMacro[Key] + Macros.update(GlobalMacro) =20 # # Replace the Macros # - for Key in RecordSets.keys(): - if RecordSets[Key] !=3D []: - for Item in RecordSets[Key]: - Item[0] =3D ReplaceMacro(Item[0], Macros) + for Value in (v for v in RecordSets.values() if v): + for Item in Value: + Item[0] =3D ReplaceMacro(Item[0], Macros) =20 ## ParseDefineMacro # @@ -79,8 +77,7 @@ def ParseDefineMacro(Table, GlobalMacro): # # Overrided by Global Macros # - for Key in GlobalMacro.keys(): - Macros[Key] =3D GlobalMacro[Key] + Macros.update(GlobalMacro) =20 # # Found all defined macro and replaced diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Py= thon/Common/String.py index 5dc5b85dc5a4..dfa13d70258c 100644 --- a/BaseTools/Source/Python/Common/String.py +++ b/BaseTools/Source/Python/Common/String.py @@ -110,7 +110,7 @@ def GetSplitList(String, SplitStr=3DDataType.TAB_VALUE_= SPLIT, MaxSplit=3D -1): # @param Arch: The Arch to be added or merged # def MergeArches(Dict, Key, Arch): - if Key in Dict.keys(): + if Key in Dict: Dict[Key].append(Arch) else: Dict[Key] =3D Arch.split() diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Sour= ce/Python/Common/VpdInfoFile.py index b1baf06b9ccd..5559a88b97f2 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -6,7 +6,7 @@ # is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt=20 # # -# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License # which accompanies this distribution. The full text of the license may b= e found at @@ -107,7 +107,7 @@ class VpdInfoFile: EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_IN= VALID, "Invalid max datum size for VPD PCD %s.%s"= % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) =20 - if Vpd not in self._VpdArray.keys(): + if Vpd not in self._VpdArray: # # If there is no Vpd instance in dict, that imply this offset = for a given SKU is a new one=20 # @@ -180,12 +180,12 @@ class VpdInfoFile: if (TokenSpaceName, PcdTokenName) not in self._VpdInfo: self._VpdInfo[(TokenSpaceName, PcdTokenName)] =3D [] self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId,Of= fset, Value)) - for VpdObject in self._VpdArray.keys(): + for VpdObject in self._VpdArray: VpdObjectTokenCName =3D VpdObject.TokenCName for PcdItem in GlobalData.MixedPcd: if (VpdObject.TokenCName, VpdObject.TokenSpaceGuidCNam= e) in GlobalData.MixedPcd[PcdItem]: VpdObjectTokenCName =3D PcdItem[0] - for sku in VpdObject.SkuInfoList.keys(): + for sku in VpdObject.SkuInfoList: if VpdObject.TokenSpaceGuidCName =3D=3D TokenSpaceName= and VpdObjectTokenCName =3D=3D PcdTokenName.strip() and sku =3D=3D SkuId: if self._VpdArray[VpdObject][sku] =3D=3D "*": if Offset =3D=3D "*": diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/P= ython/GenFds/Capsule.py index 9332f016f7da..fbd48f3c6d76 100644 --- a/BaseTools/Source/Python/GenFds/Capsule.py +++ b/BaseTools/Source/Python/GenFds/Capsule.py @@ -1,7 +1,7 @@ ## @file # generate capsule # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -201,7 +201,7 @@ class Capsule (CapsuleClassObject) : # @retval string Generated Capsule file path # def GenCapsule(self): - if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict.keys(= ): + if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict: return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] =20 GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCa= psuleName) @@ -251,11 +251,11 @@ class Capsule (CapsuleClassObject) : =20 CapInfFile.writelines("[options]" + T_CHAR_LF) =20 - for Item in self.TokensDict.keys(): + for Item in self.TokensDict: CapInfFile.writelines("EFI_" + \ Item + \ ' =3D ' + \ - self.TokensDict.get(Item) + \ + self.TokensDict[Item] + \ T_CHAR_LF) =20 return CapInfFile diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Sour= ce/Python/GenFds/CapsuleData.py index 5b806d9e4482..b376d6b2e9be 100644 --- a/BaseTools/Source/Python/GenFds/CapsuleData.py +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py @@ -1,7 +1,7 @@ ## @file # generate capsule # -# Copyright (c) 2007-2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007-2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -80,8 +80,8 @@ class CapsuleFv (CapsuleData): # def GenCapsuleSubItem(self): if self.FvName.find('.fv') =3D=3D -1: - if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profi= le.FvDict.keys(): - FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict.ge= t(self.FvName.upper()) + if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profi= le.FvDict: + FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict[se= lf.FvName.upper()] FdBuffer =3D StringIO.StringIO('') FvObj.CapsuleName =3D self.CapsuleName FvFile =3D FvObj.AddToBuffer(FdBuffer) @@ -112,8 +112,8 @@ class CapsuleFd (CapsuleData): # def GenCapsuleSubItem(self): if self.FdName.find('.fd') =3D=3D -1: - if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profi= le.FdDict.keys(): - FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict.ge= t(self.FdName.upper()) + if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profi= le.FdDict: + FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[se= lf.FdName.upper()] FdFile =3D FdObj.GenFd() return FdFile else: diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python= /GenFds/Fd.py index f735d3b5b015..cc4124ad902e 100644 --- a/BaseTools/Source/Python/GenFds/Fd.py +++ b/BaseTools/Source/Python/GenFds/Fd.py @@ -1,7 +1,7 @@ ## @file # process FD generation # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -46,7 +46,7 @@ class FD(FDClassObject): # @retval string Generated FD file name # def GenFd (self, Flag =3D False): - if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict.keys(): + if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict: return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] =20 # diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index 0427b80b2460..9dff0389b093 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -3401,7 +3401,7 @@ class FdfParser: if not self.__GetNextToken(): raise Warning("expected FV name", self.FileName, self.CurrentL= ineNumber) =20 - if self.__Token.upper() not in self.Profile.FvDict.keys(): + if self.__Token.upper() not in self.Profile.FvDict: raise Warning("FV name does not exist", self.FileName, self.Cu= rrentLineNumber) =20 CapsuleFv =3D CapsuleData.CapsuleFv() @@ -3435,7 +3435,7 @@ class FdfParser: if not self.__GetNextToken(): raise Warning("expected FD name", self.FileName, self.CurrentL= ineNumber) =20 - if self.__Token.upper() not in self.Profile.FdDict.keys(): + if self.__Token.upper() not in self.Profile.FdDict: raise Warning("FD name does not exist", self.FileName, self.Cu= rrentLineNumber) =20 CapsuleFd =3D CapsuleData.CapsuleFd() @@ -4531,7 +4531,7 @@ class FdfParser: def __GetCapInFd (self, FdName): =20 CapList =3D [] - if FdName.upper() in self.Profile.FdDict.keys(): + if FdName.upper() in self.Profile.FdDict: FdObj =3D self.Profile.FdDict[FdName.upper()] for elementRegion in FdObj.RegionList: if elementRegion.RegionType =3D=3D 'CAPSULE': @@ -4578,7 +4578,7 @@ class FdfParser: def __GetFvInFd (self, FdName): =20 FvList =3D [] - if FdName.upper() in self.Profile.FdDict.keys(): + if FdName.upper() in self.Profile.FdDict: FdObj =3D self.Profile.FdDict[FdName.upper()] for elementRegion in FdObj.RegionList: if elementRegion.RegionType =3D=3D 'FV': @@ -4647,7 +4647,7 @@ class FdfParser: # Check the cycle between FV and FD image # MaxLength =3D len (self.Profile.FvDict) - for FvName in self.Profile.FvDict.keys(): + for FvName in self.Profile.FvDict: LogStr =3D "\nCycle Reference Checking for FV: %s\n" % FvName RefFvStack =3D [] RefFvStack.append(FvName) @@ -4657,7 +4657,7 @@ class FdfParser: while RefFvStack !=3D [] and Index < MaxLength: Index =3D Index + 1 FvNameFromStack =3D RefFvStack.pop() - if FvNameFromStack.upper() in self.Profile.FvDict.keys(): + if FvNameFromStack.upper() in self.Profile.FvDict: FvObj =3D self.Profile.FvDict[FvNameFromStack.upper()] else: continue @@ -4696,7 +4696,7 @@ class FdfParser: # Check the cycle between Capsule and FD image # MaxLength =3D len (self.Profile.CapsuleDict) - for CapName in self.Profile.CapsuleDict.keys(): + for CapName in self.Profile.CapsuleDict: # # Capsule image to be checked. # @@ -4710,7 +4710,7 @@ class FdfParser: while RefCapStack !=3D [] and Index < MaxLength: Index =3D Index + 1 CapNameFromStack =3D RefCapStack.pop() - if CapNameFromStack.upper() in self.Profile.CapsuleDict.ke= ys(): + if CapNameFromStack.upper() in self.Profile.CapsuleDict: CapObj =3D self.Profile.CapsuleDict[CapNameFromStack.u= pper()] else: continue @@ -4755,7 +4755,7 @@ class FdfParser: if RefFvName in FvAnalyzedList: continue LogStr +=3D "Capsule %s contains FV %s\n" % (CapNa= meFromStack, RefFvName) - if RefFvName.upper() in self.Profile.FvDict.keys(): + if RefFvName.upper() in self.Profile.FvDict: FvObj =3D self.Profile.FvDict[RefFvName.upper(= )] else: continue diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools= /Source/Python/GenFds/FfsFileStatement.py index 3fd5a9c2158a..ba8e0465ef34 100644 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -1,7 +1,7 @@ ## @file # process FFS generation from FILE statement # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -83,14 +83,14 @@ class FileStatement (FileStatementClassObject) : SectionAlignments =3D None if self.FvName is not None : Buffer =3D StringIO.StringIO('') - if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.P= rofile.FvDict.keys(): + if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.P= rofile.FvDict: EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT de= scribed in FDF file!" % (self.FvName)) Fv =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.= FvName.upper()) FileName =3D Fv.AddToBuffer(Buffer) SectionFiles =3D [FileName] =20 elif self.FdName is not None: - if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.P= rofile.FdDict.keys(): + if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.P= rofile.FdDict: EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT de= scribed in FDF file!" % (self.FdName)) Fd =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.= FdName.upper()) FileName =3D Fd.GenFd() diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/= Source/Python/GenFds/FfsInfStatement.py index 5364569b96d7..7dc009ef9a16 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -612,7 +612,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # the file name FILE_GUIDmodule.inf, then PlatformData= Base.Modules use FILE_GUIDmodule.inf as key, # but the path (self.MetaFile.Path) is the real path # - for key in PlatformDataBase.Modules.keys(): + for key in PlatformDataBase.Modules: if InfFileKey =3D=3D str((PlatformDataBase.Modules= [key]).MetaFile.Path): DscArchList.append (Arch) break diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python= /GenFds/Fv.py index aae644bef905..ef5896d76b12 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -70,7 +70,7 @@ class FV (FvClassObject): # def AddToBuffer (self, Buffer, BaseAddress=3DNone, BlockSize=3D None, = BlockNum=3DNone, ErasePloarity=3D'1', VtfDict=3DNone, MacroDict =3D {}, Fla= g=3DFalse) : =20 - if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.= ImageBinDict.keys(): + if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.= ImageBinDict: return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =20 # @@ -78,14 +78,13 @@ class FV (FvClassObject): # If yes, return error. Doesn't support FV in Capsule image is als= o in FD flash region. # if self.CapsuleName is not None: - for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.ke= ys(): - FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[Fd= Name] + for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.val= ues(): for RegionObj in FdObj.RegionList: if RegionObj.RegionType =3D=3D 'FV': for RegionData in RegionObj.RegionDataList: if RegionData.endswith(".fv"): continue - elif RegionData.upper() + 'fv' in GenFds.Image= BinDict.keys(): + elif RegionData.upper() + 'fv' in GenFds.Image= BinDict: continue elif self.UiFvName.upper() =3D=3D RegionData.u= pper(): GenFdsGlobalVariable.ErrorLogger("Capsule = %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, s= elf.UiFvName.upper())) @@ -235,8 +234,7 @@ class FV (FvClassObject): if self.BlockSizeList: return True =20 - for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): - FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName] + for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values(= ): for RegionObj in FdObj.RegionList: if RegionObj.RegionType !=3D 'FV': continue @@ -441,7 +439,7 @@ class FV (FvClassObject): # Add [Files] # self.FvInfFile.writelines("[files]" + T_CHAR_LF) - if VtfDict is not None and self.UiFvName in VtfDict.keys(): + if VtfDict and self.UiFvName in VtfDict: self.FvInfFile.writelines("EFI_FILE_NAME =3D " = + \ - VtfDict.get(self.UiFvName) = + \ + VtfDict[self.UiFvName] = + \ T_CHAR_LF) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 810a1f86e948..1fa76021341b 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -92,7 +92,7 @@ def main(): else: Workspace =3D os.path.normcase(Options.Workspace) GenFdsGlobalVariable.WorkSpaceDir =3D Workspace - if 'EDK_SOURCE' in os.environ.keys(): + if 'EDK_SOURCE' in os.environ: GenFdsGlobalVariable.EdkSourceDir =3D os.path.normcase(os.= environ['EDK_SOURCE']) if (Options.debug): GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Wo= rkspace) @@ -156,7 +156,7 @@ def main(): # This also handles someone specifying the Conf directory = in the workspace. Using --conf=3DConf ConfDirectoryPath =3D os.path.join(GenFdsGlobalVariable.Wo= rkSpaceDir, ConfDirectoryPath) else: - if "CONF_PATH" in os.environ.keys(): + if "CONF_PATH" in os.environ: ConfDirectoryPath =3D os.path.normcase(os.environ["CONF_PA= TH"]) else: # Get standard WORKSPACE/Conf, use the absolute path to th= e WORKSPACE/Conf @@ -216,11 +216,11 @@ def main(): os.environ["WORKSPACE"] =3D Workspace =20 # Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGE= T if they are not defined - if "TARGET" not in GlobalData.gGlobalDefines.keys(): + if "TARGET" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines["TARGET"] =3D GenFdsGlobalVariable.T= argetName - if "TOOLCHAIN" not in GlobalData.gGlobalDefines.keys(): + if "TOOLCHAIN" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines["TOOLCHAIN"] =3D GenFdsGlobalVariabl= e.ToolChainTag - if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines.keys(): + if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] =3D GenFdsGlobalVa= riable.ToolChainTag =20 """call Workspace build create database""" @@ -278,21 +278,21 @@ def main(): EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Referen= ce Detected in FDF file") =20 if (Options.uiFdName) : - if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict.key= s(): + if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict: GenFds.OnlyGenerateThisFd =3D Options.uiFdName else: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, "No such an FD in FDF file: %s" % Options.= uiFdName) =20 if (Options.uiFvName) : - if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict.key= s(): + if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict: GenFds.OnlyGenerateThisFv =3D Options.uiFvName else: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, "No such an FV in FDF file: %s" % Options.= uiFvName) =20 if (Options.uiCapName) : - if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDi= ct.keys(): + if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDi= ct: GenFds.OnlyGenerateThisCap =3D Options.uiCapName else: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, @@ -388,7 +388,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, Name= Guid): KeyStringList.append(Target + '_' + ToolChain + '_' + Arch) =20 if GenFdsGlobalVariable.GuidToolDefinition: - if NameGuid in GenFdsGlobalVariable.GuidToolDefinition.keys(): + if NameGuid in GenFdsGlobalVariable.GuidToolDefinition: return GenFdsGlobalVariable.GuidToolDefinition[NameGuid] =20 ToolDefinition =3D ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable= .ConfDir).ToolsDefTxtDictionary @@ -450,10 +450,10 @@ def FindExtendTool(KeyStringList, CurrentArchList, Na= meGuid): if Key in KeyStringList and KeyList[4] =3D=3D 'GUID': ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' - if ToolPathKey in BuildOption.keys(): - ToolPathTmp =3D BuildOption.get(ToolPathKey) - if ToolOptionKey in BuildOption.keys(): - ToolOption =3D BuildOption.get(ToolOptionKey) + if ToolPathKey in BuildOption: + ToolPathTmp =3D BuildOption[ToolPathKey] + if ToolOptionKey in BuildOption: + ToolOption =3D BuildOption[ToolOptionKey] =20 GenFdsGlobalVariable.GuidToolDefinition[NameGuid] =3D (ToolPathTmp, To= olOption) return ToolPathTmp, ToolOption @@ -522,63 +522,56 @@ class GenFds : GenFdsGlobalVariable.SetDir ('', FdfParser, WorkSpace, ArchList) =20 GenFdsGlobalVariable.VerboseLogger(" Generate all Fd images and th= eir required FV and Capsule images!") - if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateT= hisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys(): - CapsuleObj =3D GenFdsGlobalVariable.FdfParser.Profile.CapsuleD= ict.get(GenFds.OnlyGenerateThisCap.upper()) + if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateT= hisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict: + CapsuleObj =3D GenFdsGlobalVariable.FdfParser.Profile.CapsuleD= ict[GenFds.OnlyGenerateThisCap.upper()] if CapsuleObj is not None: CapsuleObj.GenCapsule() return =20 - if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateTh= isFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): - FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(Ge= nFds.OnlyGenerateThisFd.upper()) + if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateTh= isFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict: + FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds= .OnlyGenerateThisFd.upper()] if FdObj is not None: FdObj.GenFd() return elif GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThis= Fv is None: - for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.ke= ys(): - FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[Fd= Name] + for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.val= ues(): FdObj.GenFd() =20 GenFdsGlobalVariable.VerboseLogger("\n Generate other FV images! ") - if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateTh= isFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): - FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(Ge= nFds.OnlyGenerateThisFv.upper()) + if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateTh= isFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict: + FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict[GenFds= .OnlyGenerateThisFv.upper()] if FvObj is not None: Buffer =3D StringIO.StringIO() FvObj.AddToBuffer(Buffer) Buffer.close() return elif GenFds.OnlyGenerateThisFv is None: - for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.ke= ys(): + for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.val= ues(): Buffer =3D StringIO.StringIO('') - FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict[Fv= Name] FvObj.AddToBuffer(Buffer) Buffer.close() =20 if GenFds.OnlyGenerateThisFv is None and GenFds.OnlyGenerateThisFd= is None and GenFds.OnlyGenerateThisCap is None: if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict !=3D {}: GenFdsGlobalVariable.VerboseLogger("\n Generate other Caps= ule images!") - for CapsuleName in GenFdsGlobalVariable.FdfParser.Profile.= CapsuleDict.keys(): - CapsuleObj =3D GenFdsGlobalVariable.FdfParser.Profile.= CapsuleDict[CapsuleName] + for CapsuleObj in GenFdsGlobalVariable.FdfParser.Profile.C= apsuleDict.values(): CapsuleObj.GenCapsule() =20 if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict !=3D {}: GenFdsGlobalVariable.VerboseLogger("\n Generate all Option= ROM!") - for DriverName in GenFdsGlobalVariable.FdfParser.Profile.O= ptRomDict.keys(): - OptRomObj =3D GenFdsGlobalVariable.FdfParser.Profile.O= ptRomDict[DriverName] + for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.Op= tRomDict.values(): OptRomObj.AddToBuffer(None) @staticmethod def GenFfsMakefile(OutputDir, FdfParser, WorkSpace, ArchList, GlobalDa= ta): GenFdsGlobalVariable.SetEnv(FdfParser, WorkSpace, ArchList, Global= Data) - for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): - FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName] + for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values(= ): FdObj.GenFd(Flag=3DTrue) =20 - for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): - FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName] + for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values(= ): FvObj.AddToBuffer(Buffer=3DNone, Flag=3DTrue) =20 if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict !=3D {}: - for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRo= mDict.keys(): - OptRomObj =3D GenFdsGlobalVariable.FdfParser.Profile.OptRo= mDict[DriverName] + for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRom= Dict.values(): OptRomObj.AddToBuffer(Buffer=3DNone, Flag=3DTrue) =20 return GenFdsGlobalVariable.FfsCmdDict @@ -591,7 +584,7 @@ class GenFds : def GetFvBlockSize(FvObj): DefaultBlockSize =3D 0x1 FdObj =3D None - if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateTh= isFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): + if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateTh= isFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict: FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds= .OnlyGenerateThisFd.upper()] if FdObj is None: for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict= .values(): diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index 2f9d58f6bf37..6f586ff2dad8 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -549,7 +549,7 @@ class GenFdsGlobalVariable: =20 GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) if MakefilePath: - if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(Ge= nFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict.keys(): + if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(Ge= nFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict: GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGl= obalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] =3D Makefil= ePath GenFdsGlobalVariable.SecCmdList =3D [] GenFdsGlobalVariable.CopyList =3D [] @@ -779,7 +779,7 @@ class GenFdsGlobalVariable: if MacroDict is not None and len (MacroDict) !=3D 0: Dict.update(MacroDict) =20 - for key in Dict.keys(): + for key in Dict: if Str.find(key) >=3D 0 : Str =3D Str.replace (key, Dict[key]) =20 diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Py= thon/GenFds/Region.py index e639739b7e03..44f122a71216 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -1,7 +1,7 @@ ## @file # process FD Region generation # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -102,7 +102,7 @@ class Region(RegionClassObject): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraDat= a=3DRegionData) =20 FileName =3D RegionData - elif RegionData.upper() + 'fv' in ImageBinDict.keys(): + elif RegionData.upper() + 'fv' in ImageBinDict: if not Flag: GenFdsGlobalVariable.InfLogger(' Region Name =3D= FV') FileName =3D ImageBinDict[RegionData.upper() + 'fv'] @@ -111,8 +111,8 @@ class Region(RegionClassObject): # Generate FvImage. # FvObj =3D None - if RegionData.upper() in GenFdsGlobalVariable.FdfParse= r.Profile.FvDict.keys(): - FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.F= vDict.get(RegionData.upper()) + if RegionData.upper() in GenFdsGlobalVariable.FdfParse= r.Profile.FvDict: + FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.F= vDict[RegionData.upper()] =20 if FvObj is not None : if not Flag: @@ -182,7 +182,7 @@ class Region(RegionClassObject): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraDat= a=3DRegionData) =20 FileName =3D RegionData - elif RegionData.upper() + 'cap' in ImageBinDict.keys(): + elif RegionData.upper() + 'cap' in ImageBinDict: GenFdsGlobalVariable.InfLogger(' Region Name =3D CAP= SULE') FileName =3D ImageBinDict[RegionData.upper() + 'cap'] else: @@ -190,7 +190,7 @@ class Region(RegionClassObject): # Generate Capsule image and Put it into FD buffer # CapsuleObj =3D None - if RegionData.upper() in GenFdsGlobalVariable.FdfParse= r.Profile.CapsuleDict.keys(): + if RegionData.upper() in GenFdsGlobalVariable.FdfParse= r.Profile.CapsuleDict: CapsuleObj =3D GenFdsGlobalVariable.FdfParser.Prof= ile.CapsuleDict[RegionData.upper()] =20 if CapsuleObj is not None : diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/S= ource/Python/TargetTool/TargetTool.py index 143b53ec35ef..ecac316b7a3a 100644 --- a/BaseTools/Source/Python/TargetTool/TargetTool.py +++ b/BaseTools/Source/Python/TargetTool/TargetTool.py @@ -1,7 +1,7 @@ ## @file # Target Tool Parser # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -65,7 +65,7 @@ class TargetTool(): LineList =3D Line.split(KeySplitCharacter,1) if len(LineList) >=3D 2: Key =3D LineList[0].strip() - if Key.startswith(CommentCharacter) =3D=3D False and K= ey in self.TargetTxtDictionary.keys(): + if Key.startswith(CommentCharacter) =3D=3D False and K= ey in self.TargetTxtDictionary: if Key =3D=3D TAB_TAT_DEFINES_ACTIVE_PLATFORM or K= ey =3D=3D TAB_TAT_DEFINES_TOOL_CHAIN_CONF \ or Key =3D=3D TAB_TAT_DEFINES_MAX_CONCURRENT_THR= EAD_NUMBER \ or Key =3D=3D TAB_TAT_DEFINES_ACTIVE_MODULE: @@ -105,7 +105,7 @@ class TargetTool(): LineList =3D Line.split(KeySplitCharacter,1) if len(LineList) >=3D 2: Key =3D LineList[0].strip() - if Key.startswith(CommentCharacter) =3D=3D False a= nd Key in self.TargetTxtDictionary.keys(): + if Key.startswith(CommentCharacter) =3D=3D False a= nd Key in self.TargetTxtDictionary: if Key not in existKeys: existKeys.append(Key) else: @@ -118,7 +118,7 @@ class TargetTool(): if ret is not None: Line =3D ret fw.write(Line) - for key in self.TargetTxtDictionary.keys(): + for key in self.TargetTxtDictionary: if key not in existKeys: print "Warning: %s does not exist in original configur= ation file" % key Line =3D GetConfigureKeyValue(self, key) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 9c77d6c50c27..ee97c4c842bd 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -593,7 +593,7 @@ class DscBuildData(PlatformBuildClassObject): # # If command line defined, should override the value in DSC file. # - if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData.gCommandLineDefines= .keys(): + if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData.gCommandLineDefines: try: self._LoadFixAddress =3D int(GlobalData.gCommandLineDefine= s['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0) except: @@ -1210,7 +1210,7 @@ class DscBuildData(PlatformBuildClassObject): for item in GlobalData.BuildOptionPcd: if len(item) =3D=3D 5 and (item[1],item[0]) in StruPcds: StructurePcdInCom[(item[0],item[1],item[2] )] =3D (item[3]= ,item[4]) - GlobalPcds =3D set([(item[0],item[1]) for item in StructurePcdInCo= m.keys()]) + GlobalPcds =3D {(item[0],item[1]) for item in StructurePcdInCom} for Pcd in StruPcds.values(): if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) not in GlobalPcds: continue @@ -1285,7 +1285,7 @@ class DscBuildData(PlatformBuildClassObject): DefaultStoreMgr =3D DefaultStore(self.DefaultStores) SkuIds =3D self.SkuIdMgr.AvailableSkuIdSet SkuIds.update({'DEFAULT':0}) - DefaultStores =3D set([storename for pcdobj in AllPcds.values() fo= r skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStor= eDict.keys()]) + DefaultStores =3D {storename for pcdobj in AllPcds.values() for sk= uobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDic= t} =20 S_PcdSet =3D [] # Find out all possible PCD candidates for self._Arch @@ -1430,10 +1430,10 @@ class DscBuildData(PlatformBuildClassObject): =20 for pcdkey in Pcds: pcd =3D Pcds[pcdkey] - if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in= pcd.SkuInfoList.keys(): + if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.Sk= uInfoList: pcd.SkuInfoList['DEFAULT'] =3D pcd.SkuInfoList['COMMON= '] del(pcd.SkuInfoList['COMMON']) - elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in p= cd.SkuInfoList.keys(): + elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuI= nfoList: del(pcd.SkuInfoList['COMMON']) =20 map(self.FilterSkuSettings,[Pcds[pcdkey] for pcdkey in Pcds if Pcd= s[pcdkey].Type in DynamicPcdType]) @@ -1883,7 +1883,7 @@ class DscBuildData(PlatformBuildClassObject): OverrideValues =3D {DefaultStore:""} if Pcd.SkuOverrideValues: OverrideValues =3D Pcd.SkuOverrideValues[SkuName] - for DefaultStoreName in OverrideValues.keys(): + for DefaultStoreName in OverrideValues: CApp =3D CApp + 'void\n' CApp =3D CApp + 'Initialize_%s_%s_%s_%s(\n' % (SkuName, Defaul= tStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) CApp =3D CApp + ' void\n' @@ -2261,7 +2261,7 @@ class DscBuildData(PlatformBuildClassObject): =20 PcdValue, DatumType, MaxDatumSize =3D self._ValidatePcd(PcdCNa= me, TokenSpaceGuid, Setting, Type, Dummy4) SkuInfo =3D SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '',= '', '', '', '', PcdValue) - if (PcdCName, TokenSpaceGuid) in Pcds.keys(): + if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject =3D Pcds[PcdCName, TokenSpaceGuid] pcdObject.SkuInfoList[SkuName] =3D SkuInfo if MaxDatumSize.strip(): @@ -2294,14 +2294,14 @@ class DscBuildData(PlatformBuildClassObject): for sku in pcd.SkuInfoList.values(): if not sku.DefaultValue: sku.DefaultValue =3D pcdDecObject.DefaultValue - if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in= pcd.SkuInfoList.keys(): + if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.Sk= uInfoList: valuefromDec =3D pcdDecObject.DefaultValue SkuInfo =3D SkuInfoClass('DEFAULT', '0', '', '', '', '', '= ', valuefromDec) pcd.SkuInfoList['DEFAULT'] =3D SkuInfo - elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in p= cd.SkuInfoList.keys(): + elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuI= nfoList: pcd.SkuInfoList['DEFAULT'] =3D pcd.SkuInfoList['COMMON'] del(pcd.SkuInfoList['COMMON']) - elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.S= kuInfoList.keys(): + elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoL= ist: del(pcd.SkuInfoList['COMMON']) =20 map(self.FilterSkuSettings,Pcds.values()) @@ -2311,7 +2311,7 @@ class DscBuildData(PlatformBuildClassObject): def FilterSkuSettings(self, PcdObj): =20 if self.SkuIdMgr.SkuUsageType =3D=3D self.SkuIdMgr.SINGLE: - if 'DEFAULT' in PcdObj.SkuInfoList.keys() and self.SkuIdMgr.Sy= stemSkuId not in PcdObj.SkuInfoList.keys(): + if 'DEFAULT' in PcdObj.SkuInfoList and self.SkuIdMgr.SystemSku= Id not in PcdObj.SkuInfoList: PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId] =3D PcdObj.S= kuInfoList['DEFAULT'] PcdObj.SkuInfoList =3D {'DEFAULT':PcdObj.SkuInfoList[self.SkuI= dMgr.SystemSkuId]} PcdObj.SkuInfoList['DEFAULT'].SkuIdName =3D 'DEFAULT' @@ -2352,7 +2352,7 @@ class DscBuildData(PlatformBuildClassObject): Pcds =3D {} DefaultStoreObj =3D DefaultStore(self._GetDefaultStores()) SkuIds =3D {skuname:skuid for skuname,skuid in self.SkuIdMgr.Avail= ableSkuIdSet.items() if skuname !=3D'COMMON'} - DefaultStores =3D set([storename for pcdobj in PcdSet.values() for= skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStore= Dict.keys()]) + DefaultStores =3D set([storename for pcdobj in PcdSet.values() for= skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStore= Dict]) for PcdCName, TokenSpaceGuid in PcdSet: PcdObj =3D PcdSet[(PcdCName, TokenSpaceGuid)] self.CopyDscRawValue(PcdObj) @@ -2465,7 +2465,7 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('Build', PCD_VARIABLE_ATTRIBUTES_CONFL= ICT_ERROR, "The variable %s.%s for DynamicHii PCDs has conflicting attribut= es [%s] and [%s] " % (VariableGuid, VariableName, VarAttribute, VariableAtt= rs[(VariableName, VariableGuid)])) =20 pcdDecObject =3D self._DecPcds[PcdCName, TokenSpaceGuid] - if (PcdCName, TokenSpaceGuid) in Pcds.keys(): + if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject =3D Pcds[PcdCName, TokenSpaceGuid] if SkuName in pcdObject.SkuInfoList: Skuitem =3D pcdObject.SkuInfoList[SkuName] @@ -2503,14 +2503,14 @@ class DscBuildData(PlatformBuildClassObject): for default_store in sku.DefaultStoreDict: sku.DefaultStoreDict[default_store]=3DpcdDecObject= .DefaultValue pcd.DefaultValue =3D pcdDecObject.DefaultValue - if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in= pcd.SkuInfoList.keys(): + if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.Sk= uInfoList: valuefromDec =3D pcdDecObject.DefaultValue SkuInfo =3D SkuInfoClass('DEFAULT', '0', SkuInfoObj.Variab= leName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,Va= riableAttribute=3DSkuInfoObj.VariableAttribute,DefaultStore=3D{DefaultStore= :valuefromDec}) pcd.SkuInfoList['DEFAULT'] =3D SkuInfo - elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in p= cd.SkuInfoList.keys(): + elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuI= nfoList: pcd.SkuInfoList['DEFAULT'] =3D pcd.SkuInfoList['COMMON'] del(pcd.SkuInfoList['COMMON']) - elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.S= kuInfoList.keys(): + elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoL= ist: del(pcd.SkuInfoList['COMMON']) =20 if pcd.MaxDatumSize.strip(): @@ -2592,7 +2592,7 @@ class DscBuildData(PlatformBuildClassObject): # VpdOffset, MaxDatumSize, InitialValue =3D self._ValidatePcd(Pc= dCName, TokenSpaceGuid, Setting, Type, Dummy4) SkuInfo =3D SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '',= '', '', '', VpdOffset, InitialValue) - if (PcdCName, TokenSpaceGuid) in Pcds.keys(): + if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject =3D Pcds[PcdCName, TokenSpaceGuid] pcdObject.SkuInfoList[SkuName] =3D SkuInfo if MaxDatumSize.strip(): @@ -2626,14 +2626,14 @@ class DscBuildData(PlatformBuildClassObject): for sku in pcd.SkuInfoList.values(): if not sku.DefaultValue: sku.DefaultValue =3D pcdDecObject.DefaultValue - if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in= pcd.SkuInfoList.keys(): + if 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' not in pcd.Sk= uInfoList: valuefromDec =3D pcdDecObject.DefaultValue SkuInfo =3D SkuInfoClass('DEFAULT', '0', '', '', '', '', S= kuInfoObj.VpdOffset, valuefromDec) pcd.SkuInfoList['DEFAULT'] =3D SkuInfo - elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in p= cd.SkuInfoList.keys(): + elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuI= nfoList: pcd.SkuInfoList['DEFAULT'] =3D pcd.SkuInfoList['COMMON'] del(pcd.SkuInfoList['COMMON']) - elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.S= kuInfoList.keys(): + elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoL= ist: del(pcd.SkuInfoList['COMMON']) =20 =20 diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/= Source/Python/Workspace/InfBuildData.py index e10873ae5903..ef0c61668d14 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -788,10 +788,7 @@ class InfBuildData(ModuleBuildClassObject): self._Includes.append(self._SourceOverridePath) =20 Macros =3D self._Macros - if 'PROCESSOR' in GlobalData.gEdkGlobal.keys(): - Macros['PROCESSOR'] =3D GlobalData.gEdkGlobal['PROCESSOR'] - else: - Macros['PROCESSOR'] =3D self._Arch + Macros['PROCESSOR'] =3D GlobalData.gEdkGlobal.get('PROCESSOR',= self._Arch) RecordList =3D self._RawData[MODEL_EFI_INCLUDE, self._Arch, se= lf._Platform] for Record in RecordList: if Record[0].find('EDK_SOURCE') > -1: diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/Source/Python/Workspace/MetaFileParser.py index f4c1868483d9..295ffcfe62f2 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1504,12 +1504,12 @@ class DscParser(MetaFileParser): # Allow using system environment variables in path after !inc= lude # __IncludeMacros['WORKSPACE'] =3D GlobalData.gGlobalDefines['WO= RKSPACE'] - if "ECP_SOURCE" in GlobalData.gGlobalDefines.keys(): + if "ECP_SOURCE" in GlobalData.gGlobalDefines: __IncludeMacros['ECP_SOURCE'] =3D GlobalData.gGlobalDefine= s['ECP_SOURCE'] # # During GenFds phase call DSC parser, will go into this branc= h. # - elif "ECP_SOURCE" in GlobalData.gCommandLineDefines.keys(): + elif "ECP_SOURCE" in GlobalData.gCommandLineDefines: __IncludeMacros['ECP_SOURCE'] =3D GlobalData.gCommandLineD= efines['ECP_SOURCE'] =20 __IncludeMacros['EFI_SOURCE'] =3D GlobalData.gGlobalDefines['E= FI_SOURCE'] diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseToo= ls/Source/Python/Workspace/WorkspaceCommon.py index 17ac3b105431..b19dbeeafc84 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -63,11 +63,11 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Targe= t, Toolchain,additionalPk PcdCName =3D Pcd[0] PcdTokenName =3D Pcd[1] if GlobalData.MixedPcd: - for PcdItem in GlobalData.MixedPcd.keys(): + for PcdItem in GlobalData.MixedPcd: if (PcdCName, PcdTokenName) in GlobalData.MixedPcd[Pcd= Item]: PcdCName =3D PcdItem[0] break - if (PcdCName, PcdTokenName) not in DecPcds.keys(): + if (PcdCName, PcdTokenName) not in DecPcds: DecPcds[PcdCName, PcdTokenName] =3D Pkg.Pcds[Pcd] return DecPcds, GuidDict =20 @@ -243,7 +243,7 @@ def _ResolveLibraryReference(Module, Platform): for LibraryName in M.Libraries: Library =3D Platform.LibraryClasses[LibraryName, ':dummy:'] if Library is None: - for Key in Platform.LibraryClasses.data.keys(): + for Key in Platform.LibraryClasses.data: if LibraryName.upper() =3D=3D Key.upper(): Library =3D Platform.LibraryClasses[Key, ':dummy:'] break diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/Python/build/BuildReport.py index f333279a5875..635c311f1a48 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -838,7 +838,7 @@ class PcdReport(object): for PcdItem in GlobalData.gConditionalPcds: if '.' in PcdItem: (TokenSpaceGuidCName, TokenCName) =3D PcdItem.spli= t('.') - if (TokenCName, TokenSpaceGuidCName) in Pa.Platfor= m.Pcds.keys(): + if (TokenCName, TokenSpaceGuidCName) in Pa.Platfor= m.Pcds: Pcd =3D Pa.Platform.Pcds[(TokenCName, TokenSpa= ceGuidCName)] PcdList =3D self.ConditionalPcds.setdefault(Pc= d.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, []) if Pcd not in PcdList: @@ -1043,7 +1043,7 @@ class PcdReport(object): DscMatch =3D (DscDefaultValue.strip() =3D=3D P= cdValue.strip()) =20 IsStructure =3D False - if GlobalData.gStructurePcd and (self.Arch in GlobalDa= ta.gStructurePcd.keys()) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in = GlobalData.gStructurePcd[self.Arch]): + if GlobalData.gStructurePcd and (self.Arch in GlobalDa= ta.gStructurePcd) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalD= ata.gStructurePcd[self.Arch]): IsStructure =3D True if TypeName in ('DYNVPD', 'DEXVPD'): SkuInfoList =3D Pcd.SkuInfoList diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index 6fb2e0ed3d09..31300d8d7b4c 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -53,7 +53,7 @@ import Common.EdkLogger import Common.GlobalData as GlobalData from GenFds.GenFds import GenFds =20 -from collections import OrderedDict +from collections import OrderedDict,defaultdict =20 # Version and Copyright VersionNumber =3D "0.60" + ' ' + gBUILD_VERSION @@ -524,8 +524,7 @@ class BuildTask: BuildTask._Thread.acquire(True) =20 # start a new build thread - Bo =3D BuildTask._ReadyQueue.keys()[0] - Bt =3D BuildTask._ReadyQueue.pop(Bo) + Bo,Bt =3D BuildTask._ReadyQueue.popitem() =20 # move into running queue BuildTask._RunningQueueLock.acquire() @@ -1000,7 +999,7 @@ class Build(): GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] =3D self.ToolChain= List[0] if self.ToolChainFamily: GlobalData.gGlobalDefines['FAMILY'] =3D self.ToolChainFamily[0] - if 'PREBUILD' in GlobalData.gCommandLineDefines.keys(): + if 'PREBUILD' in GlobalData.gCommandLineDefines: self.Prebuild =3D GlobalData.gCommandLineDefines.get('PREBUI= LD') else: self.Db.InitDatabase() @@ -1041,7 +1040,7 @@ class Build(): self.Prebuild +=3D self.PassCommandOption(self.BuildTargetList= , self.ArchList, self.ToolChainList, self.PlatformFile, self.Target) =20 def InitPostBuild(self): - if 'POSTBUILD' in GlobalData.gCommandLineDefines.keys(): + if 'POSTBUILD' in GlobalData.gCommandLineDefines: self.Postbuild =3D GlobalData.gCommandLineDefines.get('POSTBUI= LD') else: Platform =3D self.Db._MapPlatform(str(self.PlatformFile)) @@ -1524,7 +1523,7 @@ class Build(): # First get the XIP base address for FV map file. GuidPattern =3D re.compile("[-a-fA-F0-9]+") GuidName =3D re.compile("\(GUID=3D[-a-fA-F0-9]+") - for FvName in Wa.FdfProfile.FvDict.keys(): + for FvName in Wa.FdfProfile.FvDict: FvMapBuffer =3D os.path.join(Wa.FvDir, FvName + '.Fv.map') if not os.path.exists(FvMapBuffer): continue @@ -1963,15 +1962,14 @@ class Build(): self._SaveMapFile (MapBuffer, Wa) =20 def _GenFfsCmd(self): - CmdListDict =3D {} + # convert dictionary of Cmd:(Inf,Arch)=20 + # to a new dictionary of (Inf,Arch):Cmd,Cmd,Cmd... + CmdSetDict =3D defaultdict(set) GenFfsDict =3D GenFds.GenFfsMakefile('', GlobalData.gFdfParser, se= lf, self.ArchList, GlobalData) for Cmd in GenFfsDict: tmpInf, tmpArch =3D GenFfsDict[Cmd] - if (tmpInf, tmpArch) not in CmdListDict.keys(): - CmdListDict[tmpInf, tmpArch] =3D [Cmd] - else: - CmdListDict[tmpInf, tmpArch].append(Cmd) - return CmdListDict + CmdSetDict[tmpInf, tmpArch].add(Cmd) + return CmdSetDict =20 ## Build a platform in multi-thread mode # --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel