* [PATCH v3 2/2] BaseTools: refactor and remove un-needed use of .keys() on dictionaries
[not found] <cover.1523975965.git.jaben.carsey@intel.com>
@ 2018-04-17 14:40 ` Jaben Carsey
2018-04-18 8:44 ` Zhu, Yonghong
0 siblings, 1 reply; 2+ messages in thread
From: Jaben Carsey @ 2018-04-17 14:40 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu
From: Jaben <jaben.carsey@intel.com>
sometimes just delete it.
sometimes the loop needed .values() instead
v2 was my error
v3 fix error per Yonghong's review.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
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 | 2 +-
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, 153 insertions(+), 175 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) == path.normpath(FfsFile.InfFileName):
InfFoundFlag = True
- if not Module.Guid.upper() in _GuidDict.keys():
+ if Module.Guid.upper() not in _GuidDict:
_GuidDict[Module.Guid.upper()] = FfsFile
break
else:
@@ -796,7 +796,7 @@ class WorkspaceAutoGen(AutoGen):
# BuildObject from one of AutoGenObjectList is enough.
#
InfObj = self.AutoGenObjectList[0].BuildDatabase.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()] = 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.DefaultValue),
ExtraData=self.FdfFile)
- if not _PcdGuidString.upper() in _GuidDict.keys():
+ if _PcdGuidString.upper() not in _GuidDict:
_GuidDict[_PcdGuidString.upper()] = FfsFile
PcdFoundFlag = True
break
@@ -858,7 +858,7 @@ class WorkspaceAutoGen(AutoGen):
FfsFile.NameGuid.upper()),
ExtraData=self.FdfFile)
- if not FfsFile.NameGuid.upper() in _GuidDict.keys():
+ if FfsFile.NameGuid.upper() not in _GuidDict:
_GuidDict[FfsFile.NameGuid.upper()] = FfsFile
else:
#
@@ -1409,10 +1409,8 @@ class PlatformAutoGen(AutoGen):
PcdFromModule.IsFromBinaryInf = True
# Check the PCD from DSC or not
- if (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds.keys():
- PcdFromModule.IsFromDsc = True
- else:
- PcdFromModule.IsFromDsc = False
+ PcdFromModule.IsFromDsc = (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds
+
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
@@ -1542,8 +1540,8 @@ class PlatformAutoGen(AutoGen):
VpdFile = VpdInfoFile.VpdInfoFile()
NeedProcessVpdMapFile = False
- 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] = self.Platform.Pcds[pcd]
for item in self._PlatformPcds:
@@ -1553,7 +1551,7 @@ class PlatformAutoGen(AutoGen):
if (self.Workspace.ArchList[-1] == self.Arch):
for Pcd in self._DynamicPcdList:
# just pick the a value to determine whether is unicode string type
- Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
+ Sku = Pcd.SkuInfoList.values()[0]
Sku.VpdOffset = Sku.VpdOffset.strip()
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_DYNAMIC_EX_VPD]:
if not (self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == ''):
FoundFlag = False
- for VpdPcd in VpdFile._VpdArray.keys():
+ for VpdPcd in VpdFile._VpdArray:
# This PCD has been referenced by module
if (VpdPcd.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \
(VpdPcd.TokenCName == DscPcdEntry.TokenCName):
@@ -1752,7 +1750,7 @@ class PlatformAutoGen(AutoGen):
# Delete the DynamicPcdList At the last time enter into this function
for Pcd in self._DynamicPcdList:
# just pick the a value to determine whether is unicode string type
- Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
+ Sku = Pcd.SkuInfoList.values()[0]
Sku.VpdOffset = Sku.VpdOffset.strip()
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 = self.Platform.LibraryClasses[LibraryName, ':dummy:']
if Library is None:
- for Key in self.Platform.LibraryClasses.data.keys():
+ for Key in self.Platform.LibraryClasses.data:
if LibraryName.upper() == Key.upper():
Library = self.Platform.LibraryClasses[Key, ':dummy:']
break
@@ -3115,7 +3113,7 @@ class ModuleAutoGen(AutoGen):
InfObj = InfSectionParser.InfSectionParser(Filename)
DepexExpresionList = InfObj.GetDepexExpresionList()
for DepexExpresion in DepexExpresionList:
- for key in DepexExpresion.keys():
+ for key in DepexExpresion:
Arch, ModuleType = key
DepexExpr = [x for x in DepexExpresion[key] if not str(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() == SUP_MODULE_USER_DEFINED:
for Depex in DepexList:
- for key in Depex.keys():
+ for key in Depex:
DepexStr += '[Depex.%s.%s]\n' % key
DepexStr += '\n'.join(['# '+ val for val in Depex[key]])
DepexStr += '\n\n'
@@ -3243,7 +3241,7 @@ class ModuleAutoGen(AutoGen):
InfObj = InfSectionParser.InfSectionParser(Filename)
TianoCoreUserExtenList = InfObj.GetUserExtensionTianoCore()
for TianoCoreUserExtent in TianoCoreUserExtenList:
- for Section in TianoCoreUserExtent.keys():
+ for Section in TianoCoreUserExtent:
ItemList = Section.split(TAB_SPLIT)
Arch = self.Arch
if len(ItemList) == 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] = v
- 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'] = ModuleEntryPoint
- 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'] = ArchEntryPoint
- 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'] = ImageEntryPoint
PCI_COMPRESS_Flag = False
@@ -540,7 +540,7 @@ cleanlib:
RespFileList = os.path.join(self._AutoGenObject.OutputDir, 'respfilelist.txt')
if RespDict:
RespFileListContent = ''
- for Resp in RespDict.keys():
+ for Resp in RespDict:
RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt')
StrList = RespDict[Resp].split(' ')
UnexpandMacro = []
@@ -794,7 +794,7 @@ cleanlib:
SingleCommandLength = len(SingleCommand)
SingleCommandList = SingleCommand.split()
if len(SingleCommandList) > 0:
- for Flag in FlagDict.keys():
+ for Flag in FlagDict:
if '$('+ Flag +')' in SingleCommandList[0]:
Tool = Flag
break
@@ -807,12 +807,12 @@ cleanlib:
if 'FLAGS' not in self._AutoGenObject._BuildOption[Tool]:
EdkLogger.error("build", AUTOGEN_ERROR, "%s_FLAGS doesn't exist in %s ToolChain and %s Arch." %(Tool, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch), ExtraData="[%s]" % str(self._AutoGenObject))
Str = self._AutoGenObject._BuildOption[Tool]['FLAGS']
- for Option in self._AutoGenObject.BuildOption.keys():
+ for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]:
if Str.find(Option + '_' + Attr) != -1:
Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while(Str.find('$(') != -1):
- for macro in self._AutoGenObject.Macros.keys():
+ for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')'
if (Str.find(MacroName) != -1):
Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
@@ -824,12 +824,12 @@ cleanlib:
SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList)
elif item.find('$(') != -1:
Str = item
- for Option in self._AutoGenObject.BuildOption.keys():
+ for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]:
if Str.find(Option + '_' + Attr) != -1:
Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while(Str.find('$(') != -1):
- for macro in self._AutoGenObject.Macros.keys():
+ for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')'
if (Str.find(MacroName) != -1):
Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
@@ -842,19 +842,19 @@ cleanlib:
FlagDict[Tool]['Value'] = True
# 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 = Flag + '_RESP'
RespMacro = FlagDict[Flag]['Macro'].replace('FLAGS', 'RESP')
Value = self._AutoGenObject.BuildOption[Flag]['FLAGS']
for inc in self._AutoGenObject._IncludePathList:
Value += ' ' + IncPrefix + inc
- for Option in self._AutoGenObject.BuildOption.keys():
+ for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]:
if Value.find(Option + '_' + Attr) != -1:
Value = Value.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while (Value.find('$(') != -1):
- for macro in self._AutoGenObject.Macros.keys():
+ for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')'
if (Value.find(MacroName) != -1):
Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro])
diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/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 = [item[0] for item in indexedvarinfo.values()]
def assemble_variable(self, valuelist):
- ordered_value = [valuelist[k] for k in sorted(valuelist.keys())]
ordered_offset = sorted(valuelist.keys())
+ ordered_value = [valuelist[k] for k in ordered_offset]
var_value = []
num = 0
for offset in ordered_offset:
diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be 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 = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
SubSectionList = [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() == "[depex]" or key.lower().startswith("[depex."):
SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
SubSectionList = [SectionLine]
diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/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:
#
#
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 size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno))
diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspace.py b/BaseTools/Source/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 = []
Keys = Dictionary.keys()
- MaxLength = 0
- for Key in Keys:
- if len(Key) > MaxLength:
- MaxLength = len(Key)
+ MaxLength = max(map(len,Keys))
Index = 0
for Line in Lines:
LineList = Line.split(KeySplitCharacter, 1)
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/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 = None):
InQuote = True
MacroStartPos = 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 valid c variable name' % Label)
- if Label not in LabelDict.keys():
+ if Label not in LabelDict:
LabelDict[Label] = str(LabelOffset)
if Item.startswith('UINT8'):
LabelOffset = LabelOffset + 1
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 23c1a4a0b236..7caf74db5eeb 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 = min([int(value_str) for value_str in self.DefaultStores.keys()])
+ minvalue = min([int(value_str) for value_str in self.DefaultStores])
return (str(minvalue), self.DefaultStores[str(minvalue)])
def GetMin(self,DefaultSIdList):
if not DefaultSIdList:
diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/Python/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] = GlobalMacro[Key]
+ Macros.update(GlobalMacro)
#
# Replace the Macros
#
- for Key in RecordSets.keys():
- if RecordSets[Key] != []:
- for Item in RecordSets[Key]:
- Item[0] = ReplaceMacro(Item[0], Macros)
+ for Value in (v for v in RecordSets.values() if v):
+ for Item in Value:
+ Item[0] = ReplaceMacro(Item[0], Macros)
## ParseDefineMacro
#
@@ -79,8 +77,7 @@ def ParseDefineMacro(Table, GlobalMacro):
#
# Overrided by Global Macros
#
- for Key in GlobalMacro.keys():
- Macros[Key] = GlobalMacro[Key]
+ Macros.update(GlobalMacro)
#
# Found all defined macro and replaced
diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/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=DataType.TAB_VALUE_SPLIT, MaxSplit= -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] = Arch.split()
diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/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
#
#
-# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -107,7 +107,7 @@ class VpdInfoFile:
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
"Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))
- 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
#
@@ -180,12 +180,12 @@ class VpdInfoFile:
if (TokenSpaceName, PcdTokenName) not in self._VpdInfo:
self._VpdInfo[(TokenSpaceName, PcdTokenName)] = []
self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId,Offset, Value))
- for VpdObject in self._VpdArray.keys():
+ for VpdObject in self._VpdArray:
VpdObjectTokenCName = VpdObject.TokenCName
for PcdItem in GlobalData.MixedPcd:
if (VpdObject.TokenCName, VpdObject.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
VpdObjectTokenCName = PcdItem[0]
- for sku in VpdObject.SkuInfoList.keys():
+ for sku in VpdObject.SkuInfoList:
if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObjectTokenCName == PcdTokenName.strip() and sku == SkuId:
if self._VpdArray[VpdObject][sku] == "*":
if Offset == "*":
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD 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']
GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName)
@@ -251,11 +251,11 @@ class Capsule (CapsuleClassObject) :
CapInfFile.writelines("[options]" + T_CHAR_LF)
- for Item in self.TokensDict.keys():
+ for Item in self.TokensDict:
CapInfFile.writelines("EFI_" + \
Item + \
' = ' + \
- self.TokensDict.get(Item) + \
+ self.TokensDict[Item] + \
T_CHAR_LF)
return CapInfFile
diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/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.<BR>
+# Copyright (c) 2007-2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -80,8 +80,8 @@ class CapsuleFv (CapsuleData):
#
def GenCapsuleSubItem(self):
if self.FvName.find('.fv') == -1:
- if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
- FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
+ if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
+ FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[self.FvName.upper()]
FdBuffer = StringIO.StringIO('')
FvObj.CapsuleName = self.CapsuleName
FvFile = FvObj.AddToBuffer(FdBuffer)
@@ -112,8 +112,8 @@ class CapsuleFd (CapsuleData):
#
def GenCapsuleSubItem(self):
if self.FdName.find('.fd') == -1:
- if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())
+ if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
+ FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[self.FdName.upper()]
FdFile = 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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -46,7 +46,7 @@ class FD(FDClassObject):
# @retval string Generated FD file name
#
def GenFd (self, Flag = 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']
#
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.CurrentLineNumber)
- 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.CurrentLineNumber)
CapsuleFv = CapsuleData.CapsuleFv()
@@ -3435,7 +3435,7 @@ class FdfParser:
if not self.__GetNextToken():
raise Warning("expected FD name", self.FileName, self.CurrentLineNumber)
- 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.CurrentLineNumber)
CapsuleFd = CapsuleData.CapsuleFd()
@@ -4531,7 +4531,7 @@ class FdfParser:
def __GetCapInFd (self, FdName):
CapList = []
- if FdName.upper() in self.Profile.FdDict.keys():
+ if FdName.upper() in self.Profile.FdDict:
FdObj = self.Profile.FdDict[FdName.upper()]
for elementRegion in FdObj.RegionList:
if elementRegion.RegionType == 'CAPSULE':
@@ -4578,7 +4578,7 @@ class FdfParser:
def __GetFvInFd (self, FdName):
FvList = []
- if FdName.upper() in self.Profile.FdDict.keys():
+ if FdName.upper() in self.Profile.FdDict:
FdObj = self.Profile.FdDict[FdName.upper()]
for elementRegion in FdObj.RegionList:
if elementRegion.RegionType == 'FV':
@@ -4647,7 +4647,7 @@ class FdfParser:
# Check the cycle between FV and FD image
#
MaxLength = len (self.Profile.FvDict)
- for FvName in self.Profile.FvDict.keys():
+ for FvName in self.Profile.FvDict:
LogStr = "\nCycle Reference Checking for FV: %s\n" % FvName
RefFvStack = []
RefFvStack.append(FvName)
@@ -4657,7 +4657,7 @@ class FdfParser:
while RefFvStack != [] and Index < MaxLength:
Index = Index + 1
FvNameFromStack = RefFvStack.pop()
- if FvNameFromStack.upper() in self.Profile.FvDict.keys():
+ if FvNameFromStack.upper() in self.Profile.FvDict:
FvObj = self.Profile.FvDict[FvNameFromStack.upper()]
else:
continue
@@ -4696,7 +4696,7 @@ class FdfParser:
# Check the cycle between Capsule and FD image
#
MaxLength = 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 != [] and Index < MaxLength:
Index = Index + 1
CapNameFromStack = RefCapStack.pop()
- if CapNameFromStack.upper() in self.Profile.CapsuleDict.keys():
+ if CapNameFromStack.upper() in self.Profile.CapsuleDict:
CapObj = self.Profile.CapsuleDict[CapNameFromStack.upper()]
else:
continue
@@ -4755,7 +4755,7 @@ class FdfParser:
if RefFvName in FvAnalyzedList:
continue
LogStr += "Capsule %s contains FV %s\n" % (CapNameFromStack, RefFvName)
- if RefFvName.upper() in self.Profile.FvDict.keys():
+ if RefFvName.upper() in self.Profile.FvDict:
FvObj = 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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -83,14 +83,14 @@ class FileStatement (FileStatementClassObject) :
SectionAlignments = None
if self.FvName is not None :
Buffer = StringIO.StringIO('')
- if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
+ if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
FileName = Fv.AddToBuffer(Buffer)
SectionFiles = [FileName]
elif self.FdName is not None:
- if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
+ if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName))
Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())
FileName = 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 PlatformDataBase.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 == 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=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :
- 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']
#
@@ -78,14 +78,13 @@ class FV (FvClassObject):
# If yes, return error. Doesn't support FV in Capsule image is also in FD flash region.
#
if self.CapsuleName is not None:
- for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
+ for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
for RegionObj in FdObj.RegionList:
if RegionObj.RegionType == 'FV':
for RegionData in RegionObj.RegionDataList:
if RegionData.endswith(".fv"):
continue
- elif RegionData.upper() + 'fv' in GenFds.ImageBinDict.keys():
+ elif RegionData.upper() + 'fv' in GenFds.ImageBinDict:
continue
elif self.UiFvName.upper() == RegionData.upper():
GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))
@@ -235,8 +234,7 @@ class FV (FvClassObject):
if self.BlockSizeList:
return True
- for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
+ for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
for RegionObj in FdObj.RegionList:
if RegionObj.RegionType != '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 = " + \
- VtfDict.get(self.UiFvName) + \
+ VtfDict[self.UiFvName] + \
T_CHAR_LF)
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/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 = os.path.normcase(Options.Workspace)
GenFdsGlobalVariable.WorkSpaceDir = Workspace
- if 'EDK_SOURCE' in os.environ.keys():
+ if 'EDK_SOURCE' in os.environ:
GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE'])
if (Options.debug):
GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace)
@@ -156,7 +156,7 @@ def main():
# This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf
ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath)
else:
- if "CONF_PATH" in os.environ.keys():
+ if "CONF_PATH" in os.environ:
ConfDirectoryPath = os.path.normcase(os.environ["CONF_PATH"])
else:
# Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf
@@ -216,11 +216,11 @@ def main():
os.environ["WORKSPACE"] = Workspace
# Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGET if they are not defined
- if "TARGET" not in GlobalData.gGlobalDefines.keys():
+ if "TARGET" not in GlobalData.gGlobalDefines:
GlobalData.gGlobalDefines["TARGET"] = GenFdsGlobalVariable.TargetName
- if "TOOLCHAIN" not in GlobalData.gGlobalDefines.keys():
+ if "TOOLCHAIN" not in GlobalData.gGlobalDefines:
GlobalData.gGlobalDefines["TOOLCHAIN"] = GenFdsGlobalVariable.ToolChainTag
- if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines.keys():
+ if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines:
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = GenFdsGlobalVariable.ToolChainTag
"""call Workspace build create database"""
@@ -278,21 +278,21 @@ def main():
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file")
if (Options.uiFdName) :
- if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict.keys():
+ if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict:
GenFds.OnlyGenerateThisFd = Options.uiFdName
else:
EdkLogger.error("GenFds", OPTION_VALUE_INVALID,
"No such an FD in FDF file: %s" % Options.uiFdName)
if (Options.uiFvName) :
- if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict.keys():
+ if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict:
GenFds.OnlyGenerateThisFv = Options.uiFvName
else:
EdkLogger.error("GenFds", OPTION_VALUE_INVALID,
"No such an FV in FDF file: %s" % Options.uiFvName)
if (Options.uiCapName) :
- if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict.keys():
+ if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict:
GenFds.OnlyGenerateThisCap = Options.uiCapName
else:
EdkLogger.error("GenFds", OPTION_VALUE_INVALID,
@@ -388,7 +388,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
KeyStringList.append(Target + '_' + ToolChain + '_' + Arch)
if GenFdsGlobalVariable.GuidToolDefinition:
- if NameGuid in GenFdsGlobalVariable.GuidToolDefinition.keys():
+ if NameGuid in GenFdsGlobalVariable.GuidToolDefinition:
return GenFdsGlobalVariable.GuidToolDefinition[NameGuid]
ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary
@@ -450,10 +450,10 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
if Key in KeyStringList and KeyList[4] == 'GUID':
ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
- if ToolPathKey in BuildOption.keys():
- ToolPathTmp = BuildOption.get(ToolPathKey)
- if ToolOptionKey in BuildOption.keys():
- ToolOption = BuildOption.get(ToolOptionKey)
+ if ToolPathKey in BuildOption:
+ ToolPathTmp = BuildOption[ToolPathKey]
+ if ToolOptionKey in BuildOption:
+ ToolOption = BuildOption[ToolOptionKey]
GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)
return ToolPathTmp, ToolOption
@@ -522,63 +522,56 @@ class GenFds :
GenFdsGlobalVariable.SetDir ('', FdfParser, WorkSpace, ArchList)
GenFdsGlobalVariable.VerboseLogger(" Generate all Fd images and their required FV and Capsule images!")
- if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():
- CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.get(GenFds.OnlyGenerateThisCap.upper())
+ if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict:
+ CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[GenFds.OnlyGenerateThisCap.upper()]
if CapsuleObj is not None:
CapsuleObj.GenCapsule()
return
- if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(GenFds.OnlyGenerateThisFd.upper())
+ if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
+ FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()]
if FdObj is not None:
FdObj.GenFd()
return
elif GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisFv is None:
- for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
+ for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
FdObj.GenFd()
GenFdsGlobalVariable.VerboseLogger("\n Generate other FV images! ")
- if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
- FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(GenFds.OnlyGenerateThisFv.upper())
+ if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
+ FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[GenFds.OnlyGenerateThisFv.upper()]
if FvObj is not None:
Buffer = StringIO.StringIO()
FvObj.AddToBuffer(Buffer)
Buffer.close()
return
elif GenFds.OnlyGenerateThisFv is None:
- for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
+ for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():
Buffer = StringIO.StringIO('')
- FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]
FvObj.AddToBuffer(Buffer)
Buffer.close()
if GenFds.OnlyGenerateThisFv is None and GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisCap is None:
if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict != {}:
GenFdsGlobalVariable.VerboseLogger("\n Generate other Capsule images!")
- for CapsuleName in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():
- CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[CapsuleName]
+ for CapsuleObj in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.values():
CapsuleObj.GenCapsule()
if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}:
GenFdsGlobalVariable.VerboseLogger("\n Generate all Option ROM!")
- for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys():
- OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]
+ for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.values():
OptRomObj.AddToBuffer(None)
@staticmethod
def GenFfsMakefile(OutputDir, FdfParser, WorkSpace, ArchList, GlobalData):
GenFdsGlobalVariable.SetEnv(FdfParser, WorkSpace, ArchList, GlobalData)
- for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
+ for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
FdObj.GenFd(Flag=True)
- for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
- FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]
+ for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():
FvObj.AddToBuffer(Buffer=None, Flag=True)
if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}:
- for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys():
- OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]
+ for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.values():
OptRomObj.AddToBuffer(Buffer=None, Flag=True)
return GenFdsGlobalVariable.FfsCmdDict
@@ -591,7 +584,7 @@ class GenFds :
def GetFvBlockSize(FvObj):
DefaultBlockSize = 0x1
FdObj = None
- if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
+ if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
FdObj = 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/BaseTools/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:
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
if MakefilePath:
- if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict.keys():
+ if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict:
GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGlobalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] = MakefilePath
GenFdsGlobalVariable.SecCmdList = []
GenFdsGlobalVariable.CopyList = []
@@ -779,7 +779,7 @@ class GenFdsGlobalVariable:
if MacroDict is not None and len (MacroDict) != 0:
Dict.update(MacroDict)
- for key in Dict.keys():
+ for key in Dict:
if Str.find(key) >= 0 :
Str = Str.replace (key, Dict[key])
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -102,7 +102,7 @@ class Region(RegionClassObject):
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData)
FileName = RegionData
- elif RegionData.upper() + 'fv' in ImageBinDict.keys():
+ elif RegionData.upper() + 'fv' in ImageBinDict:
if not Flag:
GenFdsGlobalVariable.InfLogger(' Region Name = FV')
FileName = ImageBinDict[RegionData.upper() + 'fv']
@@ -111,8 +111,8 @@ class Region(RegionClassObject):
# Generate FvImage.
#
FvObj = None
- if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
- FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(RegionData.upper())
+ if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
+ FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[RegionData.upper()]
if FvObj is not None :
if not Flag:
@@ -182,7 +182,7 @@ class Region(RegionClassObject):
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData)
FileName = RegionData
- elif RegionData.upper() + 'cap' in ImageBinDict.keys():
+ elif RegionData.upper() + 'cap' in ImageBinDict:
GenFdsGlobalVariable.InfLogger(' Region Name = CAPSULE')
FileName = ImageBinDict[RegionData.upper() + 'cap']
else:
@@ -190,7 +190,7 @@ class Region(RegionClassObject):
# Generate Capsule image and Put it into FD buffer
#
CapsuleObj = None
- if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():
+ if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict:
CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[RegionData.upper()]
if CapsuleObj is not None :
diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/Source/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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -65,7 +65,7 @@ class TargetTool():
LineList = Line.split(KeySplitCharacter,1)
if len(LineList) >= 2:
Key = LineList[0].strip()
- if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():
+ if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary:
if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM or Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF \
or Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER \
or Key == TAB_TAT_DEFINES_ACTIVE_MODULE:
@@ -105,7 +105,7 @@ class TargetTool():
LineList = Line.split(KeySplitCharacter,1)
if len(LineList) >= 2:
Key = LineList[0].strip()
- if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():
+ if Key.startswith(CommentCharacter) == False and 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 = 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 configuration file" % key
Line = 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 = int(GlobalData.gCommandLineDefines['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0)
except:
@@ -1210,7 +1210,7 @@ class DscBuildData(PlatformBuildClassObject):
for item in GlobalData.BuildOptionPcd:
if len(item) == 5 and (item[1],item[0]) in StruPcds:
StructurePcdInCom[(item[0],item[1],item[2] )] = (item[3],item[4])
- GlobalPcds = set([(item[0],item[1]) for item in StructurePcdInCom.keys()])
+ GlobalPcds = {(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 = DefaultStore(self.DefaultStores)
SkuIds = self.SkuIdMgr.AvailableSkuIdSet
SkuIds.update({'DEFAULT':0})
- DefaultStores = set([storename for pcdobj in AllPcds.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
+ DefaultStores = {storename for pcdobj in AllPcds.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict}
S_PcdSet = []
# Find out all possible PCD candidates for self._Arch
@@ -1430,10 +1430,10 @@ 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():
+ 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])
@@ -1883,7 +1883,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 +2261,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,14 +2294,14 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if not sku.DefaultValue:
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():
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
del(pcd.SkuInfoList['COMMON'])
map(self.FilterSkuSettings,Pcds.values())
@@ -2311,7 +2311,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'
@@ -2352,7 +2352,7 @@ class DscBuildData(PlatformBuildClassObject):
Pcds = {}
DefaultStoreObj = DefaultStore(self._GetDefaultStores())
SkuIds = {skuname:skuid for skuname,skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skuname !='COMMON'}
- DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
+ DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict])
for PcdCName, TokenSpaceGuid in PcdSet:
PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)]
self.CopyDscRawValue(PcdObj)
@@ -2465,7 +2465,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,14 +2503,14 @@ 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():
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
del(pcd.SkuInfoList['COMMON'])
if pcd.MaxDatumSize.strip():
@@ -2592,7 +2592,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,14 +2626,14 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if not sku.DefaultValue:
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():
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
del(pcd.SkuInfoList['COMMON'])
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)
Macros = self._Macros
- if 'PROCESSOR' in GlobalData.gEdkGlobal.keys():
- Macros['PROCESSOR'] = GlobalData.gEdkGlobal['PROCESSOR']
- else:
- Macros['PROCESSOR'] = self._Arch
+ Macros['PROCESSOR'] = GlobalData.gEdkGlobal.get('PROCESSOR', self._Arch)
RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch, self._Platform]
for Record in RecordList:
if Record[0].find('EDK_SOURCE') > -1:
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/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 !include
#
__IncludeMacros['WORKSPACE'] = GlobalData.gGlobalDefines['WORKSPACE']
- if "ECP_SOURCE" in GlobalData.gGlobalDefines.keys():
+ if "ECP_SOURCE" in GlobalData.gGlobalDefines:
__IncludeMacros['ECP_SOURCE'] = GlobalData.gGlobalDefines['ECP_SOURCE']
#
# During GenFds phase call DSC parser, will go into this branch.
#
- elif "ECP_SOURCE" in GlobalData.gCommandLineDefines.keys():
+ elif "ECP_SOURCE" in GlobalData.gCommandLineDefines:
__IncludeMacros['ECP_SOURCE'] = GlobalData.gCommandLineDefines['ECP_SOURCE']
__IncludeMacros['EFI_SOURCE'] = GlobalData.gGlobalDefines['EFI_SOURCE']
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/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, Target, Toolchain,additionalPk
PcdCName = Pcd[0]
PcdTokenName = Pcd[1]
if GlobalData.MixedPcd:
- for PcdItem in GlobalData.MixedPcd.keys():
+ for PcdItem in GlobalData.MixedPcd:
if (PcdCName, PcdTokenName) in GlobalData.MixedPcd[PcdItem]:
PcdCName = PcdItem[0]
break
- if (PcdCName, PcdTokenName) not in DecPcds.keys():
+ if (PcdCName, PcdTokenName) not in DecPcds:
DecPcds[PcdCName, PcdTokenName] = Pkg.Pcds[Pcd]
return DecPcds, GuidDict
@@ -243,7 +243,7 @@ def _ResolveLibraryReference(Module, Platform):
for LibraryName in M.Libraries:
Library = Platform.LibraryClasses[LibraryName, ':dummy:']
if Library is None:
- for Key in Platform.LibraryClasses.data.keys():
+ for Key in Platform.LibraryClasses.data:
if LibraryName.upper() == Key.upper():
Library = Platform.LibraryClasses[Key, ':dummy:']
break
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/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) = PcdItem.split('.')
- if (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds.keys():
+ if (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds:
Pcd = Pa.Platform.Pcds[(TokenCName, TokenSpaceGuidCName)]
PcdList = self.ConditionalPcds.setdefault(Pcd.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, [])
if Pcd not in PcdList:
@@ -1043,7 +1043,7 @@ class PcdReport(object):
DscMatch = (DscDefaultValue.strip() == PcdValue.strip())
IsStructure = False
- if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd.keys()) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]):
+ if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]):
IsStructure = True
if TypeName in ('DYNVPD', 'DEXVPD'):
SkuInfoList = Pcd.SkuInfoList
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/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
-from collections import OrderedDict
+from collections import OrderedDict,defaultdict
# Version and Copyright
VersionNumber = "0.60" + ' ' + gBUILD_VERSION
@@ -524,8 +524,7 @@ class BuildTask:
BuildTask._Thread.acquire(True)
# start a new build thread
- Bo = BuildTask._ReadyQueue.keys()[0]
- Bt = BuildTask._ReadyQueue.pop(Bo)
+ Bo,Bt = BuildTask._ReadyQueue.popitem()
# move into running queue
BuildTask._RunningQueueLock.acquire()
@@ -1000,7 +999,7 @@ class Build():
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = self.ToolChainList[0]
if self.ToolChainFamily:
GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[0]
- if 'PREBUILD' in GlobalData.gCommandLineDefines.keys():
+ if 'PREBUILD' in GlobalData.gCommandLineDefines:
self.Prebuild = GlobalData.gCommandLineDefines.get('PREBUILD')
else:
self.Db.InitDatabase()
@@ -1041,7 +1040,7 @@ class Build():
self.Prebuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList, self.PlatformFile, self.Target)
def InitPostBuild(self):
- if 'POSTBUILD' in GlobalData.gCommandLineDefines.keys():
+ if 'POSTBUILD' in GlobalData.gCommandLineDefines:
self.Postbuild = GlobalData.gCommandLineDefines.get('POSTBUILD')
else:
Platform = self.Db._MapPlatform(str(self.PlatformFile))
@@ -1524,7 +1523,7 @@ class Build():
# First get the XIP base address for FV map file.
GuidPattern = re.compile("[-a-fA-F0-9]+")
GuidName = re.compile("\(GUID=[-a-fA-F0-9]+")
- for FvName in Wa.FdfProfile.FvDict.keys():
+ for FvName in Wa.FdfProfile.FvDict:
FvMapBuffer = 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)
def _GenFfsCmd(self):
- CmdListDict = {}
+ # convert dictionary of Cmd:(Inf,Arch)
+ # to a new dictionary of (Inf,Arch):Cmd,Cmd,Cmd...
+ CmdSetDict = defaultdict(set)
GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData)
for Cmd in GenFfsDict:
tmpInf, tmpArch = GenFfsDict[Cmd]
- if (tmpInf, tmpArch) not in CmdListDict.keys():
- CmdListDict[tmpInf, tmpArch] = [Cmd]
- else:
- CmdListDict[tmpInf, tmpArch].append(Cmd)
- return CmdListDict
+ CmdSetDict[tmpInf, tmpArch].add(Cmd)
+ return CmdSetDict
## Build a platform in multi-thread mode
#
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3 2/2] BaseTools: refactor and remove un-needed use of .keys() on dictionaries
2018-04-17 14:40 ` [PATCH v3 2/2] BaseTools: refactor and remove un-needed use of .keys() on dictionaries Jaben Carsey
@ 2018-04-18 8:44 ` Zhu, Yonghong
0 siblings, 0 replies; 2+ messages in thread
From: Zhu, Yonghong @ 2018-04-18 8:44 UTC (permalink / raw)
To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Best Regards,
Zhu Yonghong
-----Original Message-----
From: Carsey, Jaben
Sent: Tuesday, April 17, 2018 10:40 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v3 2/2] BaseTools: refactor and remove un-needed use of .keys() on dictionaries
From: Jaben <jaben.carsey@intel.com>
sometimes just delete it.
sometimes the loop needed .values() instead
v2 was my error
v3 fix error per Yonghong's review.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
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 | 2 +-
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, 153 insertions(+), 175 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) == path.normpath(FfsFile.InfFileName):
InfFoundFlag = True
- if not Module.Guid.upper() in _GuidDict.keys():
+ if Module.Guid.upper() not in _GuidDict:
_GuidDict[Module.Guid.upper()] = FfsFile
break
else:
@@ -796,7 +796,7 @@ class WorkspaceAutoGen(AutoGen):
# BuildObject from one of AutoGenObjectList is enough.
#
InfObj = self.AutoGenObjectList[0].BuildDatabase.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()] = 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.DefaultValue),
ExtraData=self.FdfFile)
- if not _PcdGuidString.upper() in _GuidDict.keys():
+ if _PcdGuidString.upper() not in _GuidDict:
_GuidDict[_PcdGuidString.upper()] = FfsFile
PcdFoundFlag = True
break
@@ -858,7 +858,7 @@ class WorkspaceAutoGen(AutoGen):
FfsFile.NameGuid.upper()),
ExtraData=self.FdfFile)
- if not FfsFile.NameGuid.upper() in _GuidDict.keys():
+ if FfsFile.NameGuid.upper() not in _GuidDict:
_GuidDict[FfsFile.NameGuid.upper()] = FfsFile
else:
#
@@ -1409,10 +1409,8 @@ class PlatformAutoGen(AutoGen):
PcdFromModule.IsFromBinaryInf = True
# Check the PCD from DSC or not
- if (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds.keys():
- PcdFromModule.IsFromDsc = True
- else:
- PcdFromModule.IsFromDsc = False
+ PcdFromModule.IsFromDsc = (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds
+
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
@@ -1542,8 +1540,8 @@ class PlatformAutoGen(AutoGen):
VpdFile = VpdInfoFile.VpdInfoFile()
NeedProcessVpdMapFile = False
- 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] = self.Platform.Pcds[pcd]
for item in self._PlatformPcds:
@@ -1553,7 +1551,7 @@ class PlatformAutoGen(AutoGen):
if (self.Workspace.ArchList[-1] == self.Arch):
for Pcd in self._DynamicPcdList:
# just pick the a value to determine whether is unicode string type
- Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
+ Sku = Pcd.SkuInfoList.values()[0]
Sku.VpdOffset = Sku.VpdOffset.strip()
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_DYNAMIC_EX_VPD]:
if not (self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == ''):
FoundFlag = False
- for VpdPcd in VpdFile._VpdArray.keys():
+ for VpdPcd in VpdFile._VpdArray:
# This PCD has been referenced by module
if (VpdPcd.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \
(VpdPcd.TokenCName == DscPcdEntry.TokenCName):
@@ -1752,7 +1750,7 @@ class PlatformAutoGen(AutoGen):
# Delete the DynamicPcdList At the last time enter into this function
for Pcd in self._DynamicPcdList:
# just pick the a value to determine whether is unicode string type
- Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
+ Sku = Pcd.SkuInfoList.values()[0]
Sku.VpdOffset = Sku.VpdOffset.strip()
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 = self.Platform.LibraryClasses[LibraryName, ':dummy:']
if Library is None:
- for Key in self.Platform.LibraryClasses.data.keys():
+ for Key in self.Platform.LibraryClasses.data:
if LibraryName.upper() == Key.upper():
Library = self.Platform.LibraryClasses[Key, ':dummy:']
break
@@ -3115,7 +3113,7 @@ class ModuleAutoGen(AutoGen):
InfObj = InfSectionParser.InfSectionParser(Filename)
DepexExpresionList = InfObj.GetDepexExpresionList()
for DepexExpresion in DepexExpresionList:
- for key in DepexExpresion.keys():
+ for key in DepexExpresion:
Arch, ModuleType = key
DepexExpr = [x for x in DepexExpresion[key] if not str(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() == SUP_MODULE_USER_DEFINED:
for Depex in DepexList:
- for key in Depex.keys():
+ for key in Depex:
DepexStr += '[Depex.%s.%s]\n' % key
DepexStr += '\n'.join(['# '+ val for val in Depex[key]])
DepexStr += '\n\n'
@@ -3243,7 +3241,7 @@ class ModuleAutoGen(AutoGen):
InfObj = InfSectionParser.InfSectionParser(Filename)
TianoCoreUserExtenList = InfObj.GetUserExtensionTianoCore()
for TianoCoreUserExtent in TianoCoreUserExtenList:
- for Section in TianoCoreUserExtent.keys():
+ for Section in TianoCoreUserExtent:
ItemList = Section.split(TAB_SPLIT)
Arch = self.Arch
if len(ItemList) == 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] = v
- 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'] = ModuleEntryPoint
- 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'] = ArchEntryPoint
- 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'] = ImageEntryPoint
PCI_COMPRESS_Flag = False
@@ -540,7 +540,7 @@ cleanlib:
RespFileList = os.path.join(self._AutoGenObject.OutputDir, 'respfilelist.txt')
if RespDict:
RespFileListContent = ''
- for Resp in RespDict.keys():
+ for Resp in RespDict:
RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt')
StrList = RespDict[Resp].split(' ')
UnexpandMacro = []
@@ -794,7 +794,7 @@ cleanlib:
SingleCommandLength = len(SingleCommand)
SingleCommandList = SingleCommand.split()
if len(SingleCommandList) > 0:
- for Flag in FlagDict.keys():
+ for Flag in FlagDict:
if '$('+ Flag +')' in SingleCommandList[0]:
Tool = Flag
break
@@ -807,12 +807,12 @@ cleanlib:
if 'FLAGS' not in self._AutoGenObject._BuildOption[Tool]:
EdkLogger.error("build", AUTOGEN_ERROR, "%s_FLAGS doesn't exist in %s ToolChain and %s Arch." %(Tool, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch), ExtraData="[%s]" % str(self._AutoGenObject))
Str = self._AutoGenObject._BuildOption[Tool]['FLAGS']
- for Option in self._AutoGenObject.BuildOption.keys():
+ for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]:
if Str.find(Option + '_' + Attr) != -1:
Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while(Str.find('$(') != -1):
- for macro in self._AutoGenObject.Macros.keys():
+ for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')'
if (Str.find(MacroName) != -1):
Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
@@ -824,12 +824,12 @@ cleanlib:
SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList)
elif item.find('$(') != -1:
Str = item
- for Option in self._AutoGenObject.BuildOption.keys():
+ for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]:
if Str.find(Option + '_' + Attr) != -1:
Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while(Str.find('$(') != -1):
- for macro in self._AutoGenObject.Macros.keys():
+ for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')'
if (Str.find(MacroName) != -1):
Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
@@ -842,19 +842,19 @@ cleanlib:
FlagDict[Tool]['Value'] = True
# 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 = Flag + '_RESP'
RespMacro = FlagDict[Flag]['Macro'].replace('FLAGS', 'RESP')
Value = self._AutoGenObject.BuildOption[Flag]['FLAGS']
for inc in self._AutoGenObject._IncludePathList:
Value += ' ' + IncPrefix + inc
- for Option in self._AutoGenObject.BuildOption.keys():
+ for Option in self._AutoGenObject.BuildOption:
for Attr in self._AutoGenObject.BuildOption[Option]:
if Value.find(Option + '_' + Attr) != -1:
Value = Value.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while (Value.find('$(') != -1):
- for macro in self._AutoGenObject.Macros.keys():
+ for macro in self._AutoGenObject.Macros:
MacroName = '$('+ macro + ')'
if (Value.find(MacroName) != -1):
Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro])
diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/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 = [item[0] for item in indexedvarinfo.values()]
def assemble_variable(self, valuelist):
- ordered_value = [valuelist[k] for k in sorted(valuelist.keys())]
ordered_offset = sorted(valuelist.keys())
+ ordered_value = [valuelist[k] for k in ordered_offset]
var_value = []
num = 0
for offset in ordered_offset:
diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be 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 = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
SubSectionList = [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() == "[depex]" or key.lower().startswith("[depex."):
SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
SubSectionList = [SectionLine]
diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/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:
#
#
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 size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno))
diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspace.py b/BaseTools/Source/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 = []
Keys = Dictionary.keys()
- MaxLength = 0
- for Key in Keys:
- if len(Key) > MaxLength:
- MaxLength = len(Key)
+ MaxLength = max(map(len,Keys))
Index = 0
for Line in Lines:
LineList = Line.split(KeySplitCharacter, 1)
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/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 = None):
InQuote = True
MacroStartPos = 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 valid c variable name' % Label)
- if Label not in LabelDict.keys():
+ if Label not in LabelDict:
LabelDict[Label] = str(LabelOffset)
if Item.startswith('UINT8'):
LabelOffset = LabelOffset + 1
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 23c1a4a0b236..7caf74db5eeb 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 = min([int(value_str) for value_str in self.DefaultStores.keys()])
+ minvalue = min([int(value_str) for value_str in self.DefaultStores])
return (str(minvalue), self.DefaultStores[str(minvalue)])
def GetMin(self,DefaultSIdList):
if not DefaultSIdList:
diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/Python/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] = GlobalMacro[Key]
+ Macros.update(GlobalMacro)
#
# Replace the Macros
#
- for Key in RecordSets.keys():
- if RecordSets[Key] != []:
- for Item in RecordSets[Key]:
- Item[0] = ReplaceMacro(Item[0], Macros)
+ for Value in (v for v in RecordSets.values() if v):
+ for Item in Value:
+ Item[0] = ReplaceMacro(Item[0], Macros)
## ParseDefineMacro
#
@@ -79,8 +77,7 @@ def ParseDefineMacro(Table, GlobalMacro):
#
# Overrided by Global Macros
#
- for Key in GlobalMacro.keys():
- Macros[Key] = GlobalMacro[Key]
+ Macros.update(GlobalMacro)
#
# Found all defined macro and replaced
diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/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=DataType.TAB_VALUE_SPLIT, MaxSplit= -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] = Arch.split()
diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/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
#
#
-# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -107,7 +107,7 @@ class VpdInfoFile:
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
"Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))
- 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
#
@@ -180,12 +180,12 @@ class VpdInfoFile:
if (TokenSpaceName, PcdTokenName) not in self._VpdInfo:
self._VpdInfo[(TokenSpaceName, PcdTokenName)] = []
self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId,Offset, Value))
- for VpdObject in self._VpdArray.keys():
+ for VpdObject in self._VpdArray:
VpdObjectTokenCName = VpdObject.TokenCName
for PcdItem in GlobalData.MixedPcd:
if (VpdObject.TokenCName, VpdObject.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
VpdObjectTokenCName = PcdItem[0]
- for sku in VpdObject.SkuInfoList.keys():
+ for sku in VpdObject.SkuInfoList:
if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObjectTokenCName == PcdTokenName.strip() and sku == SkuId:
if self._VpdArray[VpdObject][sku] == "*":
if Offset == "*":
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD 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']
GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName)
@@ -251,11 +251,11 @@ class Capsule (CapsuleClassObject) :
CapInfFile.writelines("[options]" + T_CHAR_LF)
- for Item in self.TokensDict.keys():
+ for Item in self.TokensDict:
CapInfFile.writelines("EFI_" + \
Item + \
' = ' + \
- self.TokensDict.get(Item) + \
+ self.TokensDict[Item] + \
T_CHAR_LF)
return CapInfFile
diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/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.<BR>
+# Copyright (c) 2007-2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -80,8 +80,8 @@ class CapsuleFv (CapsuleData):
#
def GenCapsuleSubItem(self):
if self.FvName.find('.fv') == -1:
- if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
- FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
+ if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
+ FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[self.FvName.upper()]
FdBuffer = StringIO.StringIO('')
FvObj.CapsuleName = self.CapsuleName
FvFile = FvObj.AddToBuffer(FdBuffer)
@@ -112,8 +112,8 @@ class CapsuleFd (CapsuleData):
#
def GenCapsuleSubItem(self):
if self.FdName.find('.fd') == -1:
- if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())
+ if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
+ FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[self.FdName.upper()]
FdFile = 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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -46,7 +46,7 @@ class FD(FDClassObject):
# @retval string Generated FD file name
#
def GenFd (self, Flag = 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']
#
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.CurrentLineNumber)
- 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.CurrentLineNumber)
CapsuleFv = CapsuleData.CapsuleFv()
@@ -3435,7 +3435,7 @@ class FdfParser:
if not self.__GetNextToken():
raise Warning("expected FD name", self.FileName, self.CurrentLineNumber)
- 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.CurrentLineNumber)
CapsuleFd = CapsuleData.CapsuleFd()
@@ -4531,7 +4531,7 @@ class FdfParser:
def __GetCapInFd (self, FdName):
CapList = []
- if FdName.upper() in self.Profile.FdDict.keys():
+ if FdName.upper() in self.Profile.FdDict:
FdObj = self.Profile.FdDict[FdName.upper()]
for elementRegion in FdObj.RegionList:
if elementRegion.RegionType == 'CAPSULE':
@@ -4578,7 +4578,7 @@ class FdfParser:
def __GetFvInFd (self, FdName):
FvList = []
- if FdName.upper() in self.Profile.FdDict.keys():
+ if FdName.upper() in self.Profile.FdDict:
FdObj = self.Profile.FdDict[FdName.upper()]
for elementRegion in FdObj.RegionList:
if elementRegion.RegionType == 'FV':
@@ -4647,7 +4647,7 @@ class FdfParser:
# Check the cycle between FV and FD image
#
MaxLength = len (self.Profile.FvDict)
- for FvName in self.Profile.FvDict.keys():
+ for FvName in self.Profile.FvDict:
LogStr = "\nCycle Reference Checking for FV: %s\n" % FvName
RefFvStack = []
RefFvStack.append(FvName)
@@ -4657,7 +4657,7 @@ class FdfParser:
while RefFvStack != [] and Index < MaxLength:
Index = Index + 1
FvNameFromStack = RefFvStack.pop()
- if FvNameFromStack.upper() in self.Profile.FvDict.keys():
+ if FvNameFromStack.upper() in self.Profile.FvDict:
FvObj = self.Profile.FvDict[FvNameFromStack.upper()]
else:
continue
@@ -4696,7 +4696,7 @@ class FdfParser:
# Check the cycle between Capsule and FD image
#
MaxLength = 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 != [] and Index < MaxLength:
Index = Index + 1
CapNameFromStack = RefCapStack.pop()
- if CapNameFromStack.upper() in self.Profile.CapsuleDict.keys():
+ if CapNameFromStack.upper() in self.Profile.CapsuleDict:
CapObj = self.Profile.CapsuleDict[CapNameFromStack.upper()]
else:
continue
@@ -4755,7 +4755,7 @@ class FdfParser:
if RefFvName in FvAnalyzedList:
continue
LogStr += "Capsule %s contains FV %s\n" % (CapNameFromStack, RefFvName)
- if RefFvName.upper() in self.Profile.FvDict.keys():
+ if RefFvName.upper() in self.Profile.FvDict:
FvObj = 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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -83,14 +83,14 @@ class FileStatement (FileStatementClassObject) :
SectionAlignments = None
if self.FvName is not None :
Buffer = StringIO.StringIO('')
- if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
+ if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
FileName = Fv.AddToBuffer(Buffer)
SectionFiles = [FileName]
elif self.FdName is not None:
- if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
+ if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName))
Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())
FileName = 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 PlatformDataBase.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 == 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=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :
- 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']
#
@@ -78,14 +78,13 @@ class FV (FvClassObject):
# If yes, return error. Doesn't support FV in Capsule image is also in FD flash region.
#
if self.CapsuleName is not None:
- for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
+ for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
for RegionObj in FdObj.RegionList:
if RegionObj.RegionType == 'FV':
for RegionData in RegionObj.RegionDataList:
if RegionData.endswith(".fv"):
continue
- elif RegionData.upper() + 'fv' in GenFds.ImageBinDict.keys():
+ elif RegionData.upper() + 'fv' in GenFds.ImageBinDict:
continue
elif self.UiFvName.upper() == RegionData.upper():
GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))
@@ -235,8 +234,7 @@ class FV (FvClassObject):
if self.BlockSizeList:
return True
- for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
+ for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
for RegionObj in FdObj.RegionList:
if RegionObj.RegionType != '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 = " + \
- VtfDict.get(self.UiFvName) + \
+ VtfDict[self.UiFvName] + \
T_CHAR_LF)
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/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 = os.path.normcase(Options.Workspace)
GenFdsGlobalVariable.WorkSpaceDir = Workspace
- if 'EDK_SOURCE' in os.environ.keys():
+ if 'EDK_SOURCE' in os.environ:
GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE'])
if (Options.debug):
GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace)
@@ -156,7 +156,7 @@ def main():
# This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf
ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath)
else:
- if "CONF_PATH" in os.environ.keys():
+ if "CONF_PATH" in os.environ:
ConfDirectoryPath = os.path.normcase(os.environ["CONF_PATH"])
else:
# Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf
@@ -216,11 +216,11 @@ def main():
os.environ["WORKSPACE"] = Workspace
# Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGET if they are not defined
- if "TARGET" not in GlobalData.gGlobalDefines.keys():
+ if "TARGET" not in GlobalData.gGlobalDefines:
GlobalData.gGlobalDefines["TARGET"] = GenFdsGlobalVariable.TargetName
- if "TOOLCHAIN" not in GlobalData.gGlobalDefines.keys():
+ if "TOOLCHAIN" not in GlobalData.gGlobalDefines:
GlobalData.gGlobalDefines["TOOLCHAIN"] = GenFdsGlobalVariable.ToolChainTag
- if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines.keys():
+ if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines:
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = GenFdsGlobalVariable.ToolChainTag
"""call Workspace build create database"""
@@ -278,21 +278,21 @@ def main():
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file")
if (Options.uiFdName) :
- if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict.keys():
+ if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict:
GenFds.OnlyGenerateThisFd = Options.uiFdName
else:
EdkLogger.error("GenFds", OPTION_VALUE_INVALID,
"No such an FD in FDF file: %s" % Options.uiFdName)
if (Options.uiFvName) :
- if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict.keys():
+ if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict:
GenFds.OnlyGenerateThisFv = Options.uiFvName
else:
EdkLogger.error("GenFds", OPTION_VALUE_INVALID,
"No such an FV in FDF file: %s" % Options.uiFvName)
if (Options.uiCapName) :
- if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict.keys():
+ if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict:
GenFds.OnlyGenerateThisCap = Options.uiCapName
else:
EdkLogger.error("GenFds", OPTION_VALUE_INVALID,
@@ -388,7 +388,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
KeyStringList.append(Target + '_' + ToolChain + '_' + Arch)
if GenFdsGlobalVariable.GuidToolDefinition:
- if NameGuid in GenFdsGlobalVariable.GuidToolDefinition.keys():
+ if NameGuid in GenFdsGlobalVariable.GuidToolDefinition:
return GenFdsGlobalVariable.GuidToolDefinition[NameGuid]
ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary
@@ -450,10 +450,10 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
if Key in KeyStringList and KeyList[4] == 'GUID':
ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
- if ToolPathKey in BuildOption.keys():
- ToolPathTmp = BuildOption.get(ToolPathKey)
- if ToolOptionKey in BuildOption.keys():
- ToolOption = BuildOption.get(ToolOptionKey)
+ if ToolPathKey in BuildOption:
+ ToolPathTmp = BuildOption[ToolPathKey]
+ if ToolOptionKey in BuildOption:
+ ToolOption = BuildOption[ToolOptionKey]
GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)
return ToolPathTmp, ToolOption
@@ -522,63 +522,56 @@ class GenFds :
GenFdsGlobalVariable.SetDir ('', FdfParser, WorkSpace, ArchList)
GenFdsGlobalVariable.VerboseLogger(" Generate all Fd images and their required FV and Capsule images!")
- if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():
- CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.get(GenFds.OnlyGenerateThisCap.upper())
+ if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict:
+ CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[GenFds.OnlyGenerateThisCap.upper()]
if CapsuleObj is not None:
CapsuleObj.GenCapsule()
return
- if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(GenFds.OnlyGenerateThisFd.upper())
+ if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
+ FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()]
if FdObj is not None:
FdObj.GenFd()
return
elif GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisFv is None:
- for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
+ for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
FdObj.GenFd()
GenFdsGlobalVariable.VerboseLogger("\n Generate other FV images! ")
- if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
- FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(GenFds.OnlyGenerateThisFv.upper())
+ if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
+ FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[GenFds.OnlyGenerateThisFv.upper()]
if FvObj is not None:
Buffer = StringIO.StringIO()
FvObj.AddToBuffer(Buffer)
Buffer.close()
return
elif GenFds.OnlyGenerateThisFv is None:
- for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
+ for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():
Buffer = StringIO.StringIO('')
- FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]
FvObj.AddToBuffer(Buffer)
Buffer.close()
if GenFds.OnlyGenerateThisFv is None and GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisCap is None:
if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict != {}:
GenFdsGlobalVariable.VerboseLogger("\n Generate other Capsule images!")
- for CapsuleName in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():
- CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[CapsuleName]
+ for CapsuleObj in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.values():
CapsuleObj.GenCapsule()
if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}:
GenFdsGlobalVariable.VerboseLogger("\n Generate all Option ROM!")
- for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys():
- OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]
+ for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.values():
OptRomObj.AddToBuffer(None)
@staticmethod
def GenFfsMakefile(OutputDir, FdfParser, WorkSpace, ArchList, GlobalData):
GenFdsGlobalVariable.SetEnv(FdfParser, WorkSpace, ArchList, GlobalData)
- for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
- FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
+ for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
FdObj.GenFd(Flag=True)
- for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
- FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]
+ for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():
FvObj.AddToBuffer(Buffer=None, Flag=True)
if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}:
- for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys():
- OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]
+ for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.values():
OptRomObj.AddToBuffer(Buffer=None, Flag=True)
return GenFdsGlobalVariable.FfsCmdDict
@@ -591,7 +584,7 @@ class GenFds :
def GetFvBlockSize(FvObj):
DefaultBlockSize = 0x1
FdObj = None
- if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
+ if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
FdObj = 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/BaseTools/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:
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
if MakefilePath:
- if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict.keys():
+ if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict:
GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGlobalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] = MakefilePath
GenFdsGlobalVariable.SecCmdList = []
GenFdsGlobalVariable.CopyList = []
@@ -779,7 +779,7 @@ class GenFdsGlobalVariable:
if MacroDict is not None and len (MacroDict) != 0:
Dict.update(MacroDict)
- for key in Dict.keys():
+ for key in Dict:
if Str.find(key) >= 0 :
Str = Str.replace (key, Dict[key])
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -102,7 +102,7 @@ class Region(RegionClassObject):
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData)
FileName = RegionData
- elif RegionData.upper() + 'fv' in ImageBinDict.keys():
+ elif RegionData.upper() + 'fv' in ImageBinDict:
if not Flag:
GenFdsGlobalVariable.InfLogger(' Region Name = FV')
FileName = ImageBinDict[RegionData.upper() + 'fv']
@@ -111,8 +111,8 @@ class Region(RegionClassObject):
# Generate FvImage.
#
FvObj = None
- if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
- FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(RegionData.upper())
+ if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
+ FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[RegionData.upper()]
if FvObj is not None :
if not Flag:
@@ -182,7 +182,7 @@ class Region(RegionClassObject):
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData)
FileName = RegionData
- elif RegionData.upper() + 'cap' in ImageBinDict.keys():
+ elif RegionData.upper() + 'cap' in ImageBinDict:
GenFdsGlobalVariable.InfLogger(' Region Name = CAPSULE')
FileName = ImageBinDict[RegionData.upper() + 'cap']
else:
@@ -190,7 +190,7 @@ class Region(RegionClassObject):
# Generate Capsule image and Put it into FD buffer
#
CapsuleObj = None
- if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():
+ if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict:
CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[RegionData.upper()]
if CapsuleObj is not None :
diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/Source/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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -65,7 +65,7 @@ class TargetTool():
LineList = Line.split(KeySplitCharacter,1)
if len(LineList) >= 2:
Key = LineList[0].strip()
- if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():
+ if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary:
if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM or Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF \
or Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER \
or Key == TAB_TAT_DEFINES_ACTIVE_MODULE:
@@ -105,7 +105,7 @@ class TargetTool():
LineList = Line.split(KeySplitCharacter,1)
if len(LineList) >= 2:
Key = LineList[0].strip()
- if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():
+ if Key.startswith(CommentCharacter) == False and 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 = 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 configuration file" % key
Line = 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 = int(GlobalData.gCommandLineDefines['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0)
except:
@@ -1210,7 +1210,7 @@ class DscBuildData(PlatformBuildClassObject):
for item in GlobalData.BuildOptionPcd:
if len(item) == 5 and (item[1],item[0]) in StruPcds:
StructurePcdInCom[(item[0],item[1],item[2] )] = (item[3],item[4])
- GlobalPcds = set([(item[0],item[1]) for item in StructurePcdInCom.keys()])
+ GlobalPcds = {(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 = DefaultStore(self.DefaultStores)
SkuIds = self.SkuIdMgr.AvailableSkuIdSet
SkuIds.update({'DEFAULT':0})
- DefaultStores = set([storename for pcdobj in AllPcds.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
+ DefaultStores = {storename for pcdobj in AllPcds.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict}
S_PcdSet = []
# Find out all possible PCD candidates for self._Arch
@@ -1430,10 +1430,10 @@ 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():
+ 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])
@@ -1883,7 +1883,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 +2261,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,14 +2294,14 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if not sku.DefaultValue:
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():
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
del(pcd.SkuInfoList['COMMON'])
map(self.FilterSkuSettings,Pcds.values())
@@ -2311,7 +2311,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'
@@ -2352,7 +2352,7 @@ class DscBuildData(PlatformBuildClassObject):
Pcds = {}
DefaultStoreObj = DefaultStore(self._GetDefaultStores())
SkuIds = {skuname:skuid for skuname,skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skuname !='COMMON'}
- DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
+ DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict])
for PcdCName, TokenSpaceGuid in PcdSet:
PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)]
self.CopyDscRawValue(PcdObj)
@@ -2465,7 +2465,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,14 +2503,14 @@ 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():
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
del(pcd.SkuInfoList['COMMON'])
if pcd.MaxDatumSize.strip():
@@ -2592,7 +2592,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,14 +2626,14 @@ class DscBuildData(PlatformBuildClassObject):
for sku in pcd.SkuInfoList.values():
if not sku.DefaultValue:
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():
+ elif 'DEFAULT' in pcd.SkuInfoList and 'COMMON' in pcd.SkuInfoList:
del(pcd.SkuInfoList['COMMON'])
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)
Macros = self._Macros
- if 'PROCESSOR' in GlobalData.gEdkGlobal.keys():
- Macros['PROCESSOR'] = GlobalData.gEdkGlobal['PROCESSOR']
- else:
- Macros['PROCESSOR'] = self._Arch
+ Macros['PROCESSOR'] = GlobalData.gEdkGlobal.get('PROCESSOR', self._Arch)
RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch, self._Platform]
for Record in RecordList:
if Record[0].find('EDK_SOURCE') > -1:
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/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 !include
#
__IncludeMacros['WORKSPACE'] = GlobalData.gGlobalDefines['WORKSPACE']
- if "ECP_SOURCE" in GlobalData.gGlobalDefines.keys():
+ if "ECP_SOURCE" in GlobalData.gGlobalDefines:
__IncludeMacros['ECP_SOURCE'] = GlobalData.gGlobalDefines['ECP_SOURCE']
#
# During GenFds phase call DSC parser, will go into this branch.
#
- elif "ECP_SOURCE" in GlobalData.gCommandLineDefines.keys():
+ elif "ECP_SOURCE" in GlobalData.gCommandLineDefines:
__IncludeMacros['ECP_SOURCE'] = GlobalData.gCommandLineDefines['ECP_SOURCE']
__IncludeMacros['EFI_SOURCE'] = GlobalData.gGlobalDefines['EFI_SOURCE']
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/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, Target, Toolchain,additionalPk
PcdCName = Pcd[0]
PcdTokenName = Pcd[1]
if GlobalData.MixedPcd:
- for PcdItem in GlobalData.MixedPcd.keys():
+ for PcdItem in GlobalData.MixedPcd:
if (PcdCName, PcdTokenName) in GlobalData.MixedPcd[PcdItem]:
PcdCName = PcdItem[0]
break
- if (PcdCName, PcdTokenName) not in DecPcds.keys():
+ if (PcdCName, PcdTokenName) not in DecPcds:
DecPcds[PcdCName, PcdTokenName] = Pkg.Pcds[Pcd]
return DecPcds, GuidDict
@@ -243,7 +243,7 @@ def _ResolveLibraryReference(Module, Platform):
for LibraryName in M.Libraries:
Library = Platform.LibraryClasses[LibraryName, ':dummy:']
if Library is None:
- for Key in Platform.LibraryClasses.data.keys():
+ for Key in Platform.LibraryClasses.data:
if LibraryName.upper() == Key.upper():
Library = Platform.LibraryClasses[Key, ':dummy:']
break
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/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) = PcdItem.split('.')
- if (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds.keys():
+ if (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds:
Pcd = Pa.Platform.Pcds[(TokenCName, TokenSpaceGuidCName)]
PcdList = self.ConditionalPcds.setdefault(Pcd.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, [])
if Pcd not in PcdList:
@@ -1043,7 +1043,7 @@ class PcdReport(object):
DscMatch = (DscDefaultValue.strip() == PcdValue.strip())
IsStructure = False
- if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd.keys()) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]):
+ if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]):
IsStructure = True
if TypeName in ('DYNVPD', 'DEXVPD'):
SkuInfoList = Pcd.SkuInfoList
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/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
-from collections import OrderedDict
+from collections import OrderedDict,defaultdict
# Version and Copyright
VersionNumber = "0.60" + ' ' + gBUILD_VERSION
@@ -524,8 +524,7 @@ class BuildTask:
BuildTask._Thread.acquire(True)
# start a new build thread
- Bo = BuildTask._ReadyQueue.keys()[0]
- Bt = BuildTask._ReadyQueue.pop(Bo)
+ Bo,Bt = BuildTask._ReadyQueue.popitem()
# move into running queue
BuildTask._RunningQueueLock.acquire()
@@ -1000,7 +999,7 @@ class Build():
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = self.ToolChainList[0]
if self.ToolChainFamily:
GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[0]
- if 'PREBUILD' in GlobalData.gCommandLineDefines.keys():
+ if 'PREBUILD' in GlobalData.gCommandLineDefines:
self.Prebuild = GlobalData.gCommandLineDefines.get('PREBUILD')
else:
self.Db.InitDatabase()
@@ -1041,7 +1040,7 @@ class Build():
self.Prebuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList, self.PlatformFile, self.Target)
def InitPostBuild(self):
- if 'POSTBUILD' in GlobalData.gCommandLineDefines.keys():
+ if 'POSTBUILD' in GlobalData.gCommandLineDefines:
self.Postbuild = GlobalData.gCommandLineDefines.get('POSTBUILD')
else:
Platform = self.Db._MapPlatform(str(self.PlatformFile))
@@ -1524,7 +1523,7 @@ class Build():
# First get the XIP base address for FV map file.
GuidPattern = re.compile("[-a-fA-F0-9]+")
GuidName = re.compile("\(GUID=[-a-fA-F0-9]+")
- for FvName in Wa.FdfProfile.FvDict.keys():
+ for FvName in Wa.FdfProfile.FvDict:
FvMapBuffer = 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)
def _GenFfsCmd(self):
- CmdListDict = {}
+ # convert dictionary of Cmd:(Inf,Arch)
+ # to a new dictionary of (Inf,Arch):Cmd,Cmd,Cmd...
+ CmdSetDict = defaultdict(set)
GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData)
for Cmd in GenFfsDict:
tmpInf, tmpArch = GenFfsDict[Cmd]
- if (tmpInf, tmpArch) not in CmdListDict.keys():
- CmdListDict[tmpInf, tmpArch] = [Cmd]
- else:
- CmdListDict[tmpInf, tmpArch].append(Cmd)
- return CmdListDict
+ CmdSetDict[tmpInf, tmpArch].add(Cmd)
+ return CmdSetDict
## Build a platform in multi-thread mode
#
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-18 8:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1523975965.git.jaben.carsey@intel.com>
2018-04-17 14:40 ` [PATCH v3 2/2] BaseTools: refactor and remove un-needed use of .keys() on dictionaries Jaben Carsey
2018-04-18 8:44 ` Zhu, Yonghong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox