BaseTools: refactor and remove un-needed use of .keys() on dictionaries
sometimes just delete it. sometimes the loop needed .values() instead 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> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
committed by
Yonghong Zhu
parent
55c84777ee
commit
9eb87141ec
@ -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
|
||||
|
@ -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
|
||||
@ -1961,15 +1960,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
|
||||
#
|
||||
|
Reference in New Issue
Block a user