From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 8CAD72270D334 for ; Tue, 10 Apr 2018 07:20:10 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2018 07:20:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,432,1517904000"; d="scan'208";a="190327381" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.141]) by orsmga004.jf.intel.com with ESMTP; 10 Apr 2018 07:20:09 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu Date: Tue, 10 Apr 2018 07:20:06 -0700 Message-Id: <5a483778fbfbd93317b013c0109324950a05990f.1523369916.git.jaben.carsey@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH v1 1/3] BaseTools: refactor and remove more keys() usage 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: , X-List-Received-Date: Tue, 10 Apr 2018 14:20:10 -0000 this is no longer required to make dictionary objects iterable. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Workspace/DscBuildData.py | 59 +++++++++----------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index cf9608651269..35ef15262a09 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 = int(GlobalData.gCommandLineDefines['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0) except: @@ -682,9 +682,7 @@ class DscBuildData(PlatformBuildClassObject): self.DefaultStores[Record[1].upper()] = (self.ToInt(Record[0]),Record[1].upper()) if TAB_DEFAULT_STORES_DEFAULT not in self.DefaultStores: self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] = (0,TAB_DEFAULT_STORES_DEFAULT) - GlobalData.gDefaultStores = self.DefaultStores.keys() - if GlobalData.gDefaultStores: - GlobalData.gDefaultStores.sort() + GlobalData.gDefaultStores = sorted(self.DefaultStores.keys()) return self.DefaultStores ## Retrieve [Components] section information @@ -1430,11 +1428,11 @@ class DscBuildData(PlatformBuildClassObject): for pcdkey in Pcds: pcd = 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.SkuInfoList: pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON'] - del(pcd.SkuInfoList['COMMON']) - elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys(): - del(pcd.SkuInfoList['COMMON']) + del pcd.SkuInfoList['COMMON'] + elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList: + del pcd.SkuInfoList['COMMON'] map(self.FilterSkuSettings,[Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType]) return Pcds @@ -1479,10 +1477,7 @@ class DscBuildData(PlatformBuildClassObject): else: PcdValueDict[PcdCName, TokenSpaceGuid] = {SkuName:(PcdValue, DatumType, MaxDatumSize)} - PcdsKeys = PcdValueDict.keys() - for PcdCName, TokenSpaceGuid in PcdsKeys: - - PcdSetting = PcdValueDict[PcdCName, TokenSpaceGuid] + for ((PcdName,TokenSpaceGuid),PcdSetting) in PcdValueDict.iteritems(): PcdValue = None DatumType = None MaxDatumSize = None @@ -1883,7 +1878,7 @@ class DscBuildData(PlatformBuildClassObject): OverrideValues = {DefaultStore:""} if Pcd.SkuOverrideValues: OverrideValues = Pcd.SkuOverrideValues[SkuName] - for DefaultStoreName in OverrideValues.keys(): + for DefaultStoreName in OverrideValues: CApp = CApp + 'void\n' CApp = CApp + 'Initialize_%s_%s_%s_%s(\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) CApp = CApp + ' void\n' @@ -2261,7 +2256,7 @@ class DscBuildData(PlatformBuildClassObject): PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', '', PcdValue) - if (PcdCName, TokenSpaceGuid) in Pcds.keys(): + if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject = Pcds[PcdCName, TokenSpaceGuid] pcdObject.SkuInfoList[SkuName] = SkuInfo if MaxDatumSize.strip(): @@ -2294,15 +2289,15 @@ class DscBuildData(PlatformBuildClassObject): for sku in pcd.SkuInfoList.values(): if (sku.DefaultValue == "" or sku.DefaultValue==None): sku.DefaultValue = 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.SkuInfoList: valuefromDec = pcdDecObject.DefaultValue SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', '', valuefromDec) pcd.SkuInfoList['DEFAULT'] = SkuInfo - elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys(): + elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList: pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON'] - del(pcd.SkuInfoList['COMMON']) - elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys(): - del(pcd.SkuInfoList['COMMON']) + del pcd.SkuInfoList['COMMON'] + elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList: + del pcd.SkuInfoList['COMMON'] map(self.FilterSkuSettings,Pcds.values()) @@ -2311,7 +2306,7 @@ class DscBuildData(PlatformBuildClassObject): def FilterSkuSettings(self, PcdObj): if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE: - if 'DEFAULT' in PcdObj.SkuInfoList.keys() and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList.keys(): + if 'DEFAULT' in PcdObj.SkuInfoList and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList: PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId] = PcdObj.SkuInfoList['DEFAULT'] PcdObj.SkuInfoList = {'DEFAULT':PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId]} PcdObj.SkuInfoList['DEFAULT'].SkuIdName = 'DEFAULT' @@ -2465,7 +2460,7 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('Build', PCD_VARIABLE_ATTRIBUTES_CONFLICT_ERROR, "The variable %s.%s for DynamicHii PCDs has conflicting attributes [%s] and [%s] " % (VariableGuid, VariableName, VarAttribute, VariableAttrs[(VariableName, VariableGuid)])) pcdDecObject = self._DecPcds[PcdCName, TokenSpaceGuid] - if (PcdCName, TokenSpaceGuid) in Pcds.keys(): + if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject = Pcds[PcdCName, TokenSpaceGuid] if SkuName in pcdObject.SkuInfoList: Skuitem = pcdObject.SkuInfoList[SkuName] @@ -2503,15 +2498,15 @@ class DscBuildData(PlatformBuildClassObject): for default_store in sku.DefaultStoreDict: sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue pcd.DefaultValue = 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.SkuInfoList: valuefromDec = pcdDecObject.DefaultValue SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec}) pcd.SkuInfoList['DEFAULT'] = SkuInfo - elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys(): + elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList: pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON'] - del(pcd.SkuInfoList['COMMON']) - elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys(): - del(pcd.SkuInfoList['COMMON']) + del pcd.SkuInfoList['COMMON'] + elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList: + del pcd.SkuInfoList['COMMON'] if pcd.MaxDatumSize.strip(): MaxSize = int(pcd.MaxDatumSize, 0) @@ -2592,7 +2587,7 @@ class DscBuildData(PlatformBuildClassObject): # VpdOffset, MaxDatumSize, InitialValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', VpdOffset, InitialValue) - if (PcdCName, TokenSpaceGuid) in Pcds.keys(): + if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject = Pcds[PcdCName, TokenSpaceGuid] pcdObject.SkuInfoList[SkuName] = SkuInfo if MaxDatumSize.strip(): @@ -2626,15 +2621,15 @@ class DscBuildData(PlatformBuildClassObject): for sku in pcd.SkuInfoList.values(): if (sku.DefaultValue == "" or sku.DefaultValue==None): sku.DefaultValue = 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.SkuInfoList: valuefromDec = pcdDecObject.DefaultValue SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', SkuInfoObj.VpdOffset, valuefromDec) pcd.SkuInfoList['DEFAULT'] = SkuInfo - elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys(): + elif 'DEFAULT' not in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList: pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON'] - del(pcd.SkuInfoList['COMMON']) - elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys(): - del(pcd.SkuInfoList['COMMON']) + del pcd.SkuInfoList['COMMON'] + elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList: + del pcd.SkuInfoList['COMMON'] map(self.FilterSkuSettings,Pcds.values()) -- 2.16.2.windows.1