BaseTools: the list and iterator translation

In python3,The keys of the dictionary not a list,It needs to be converted

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
Feng, Bob C
2019-01-28 15:06:30 +08:00
parent 7fa0e68afd
commit f8d11e5a4a
13 changed files with 47 additions and 46 deletions

View File

@ -929,7 +929,7 @@ class WorkspaceAutoGen(AutoGen):
def _CheckAllPcdsTokenValueConflict(self):
for Pa in self.AutoGenObjectList:
for Package in Pa.PackageList:
PcdList = Package.Pcds.values()
PcdList = list(Package.Pcds.values())
PcdList.sort(key=lambda x: int(x.TokenValue, 0))
Count = 0
while (Count < len(PcdList) - 1) :
@ -975,7 +975,7 @@ class WorkspaceAutoGen(AutoGen):
Count += SameTokenValuePcdListCount
Count += 1
PcdList = Package.Pcds.values()
PcdList = list(Package.Pcds.values())
PcdList.sort(key=lambda x: "%s.%s" % (x.TokenSpaceGuidCName, x.TokenCName))
Count = 0
while (Count < len(PcdList) - 1) :
@ -1300,7 +1300,7 @@ class PlatformAutoGen(AutoGen):
if os.path.exists(VpdMapFilePath):
OrgVpdFile.Read(VpdMapFilePath)
PcdItems = OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0])
NvStoreOffset = PcdItems.values()[0].strip() if PcdItems else '0'
NvStoreOffset = list(PcdItems.values())[0].strip() if PcdItems else '0'
else:
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
@ -1499,7 +1499,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.values()[0]
Sku = Pcd.SkuInfoList.get(TAB_DEFAULT)
Sku.VpdOffset = Sku.VpdOffset.strip()
if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
@ -1605,7 +1605,7 @@ class PlatformAutoGen(AutoGen):
if not FoundFlag :
# just pick the a value to determine whether is unicode string type
SkuValueMap = {}
SkuObjList = DscPcdEntry.SkuInfoList.items()
SkuObjList = list(DscPcdEntry.SkuInfoList.items())
DefaultSku = DscPcdEntry.SkuInfoList.get(TAB_DEFAULT)
if DefaultSku:
defaultindex = SkuObjList.index((TAB_DEFAULT, DefaultSku))
@ -1631,7 +1631,7 @@ class PlatformAutoGen(AutoGen):
DscPcdEntry.TokenSpaceGuidValue = eachDec.Guids[DecPcdEntry.TokenSpaceGuidCName]
# Only fix the value while no value provided in DSC file.
if not Sku.DefaultValue:
DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue
DscPcdEntry.SkuInfoList[list(DscPcdEntry.SkuInfoList.keys())[0]].DefaultValue = DecPcdEntry.DefaultValue
if DscPcdEntry not in self._DynamicPcdList:
self._DynamicPcdList.append(DscPcdEntry)
@ -1713,7 +1713,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.values()[0]
Sku = Pcd.SkuInfoList.get(TAB_DEFAULT)
Sku.VpdOffset = Sku.VpdOffset.strip()
if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
@ -2286,7 +2286,7 @@ class PlatformAutoGen(AutoGen):
Pcd.MaxDatumSize = str(len(Value.split(',')))
else:
Pcd.MaxDatumSize = str(len(Value) - 1)
return Pcds.values()
return list(Pcds.values())
@ -2355,7 +2355,7 @@ class PlatformAutoGen(AutoGen):
# Use the highest priority value.
#
if (len(OverrideList) >= 2):
KeyList = OverrideList.keys()
KeyList = list(OverrideList.keys())
for Index in range(len(KeyList)):
NowKey = KeyList[Index]
Target1, ToolChain1, Arch1, CommandType1, Attr1 = NowKey.split("_")
@ -2473,9 +2473,9 @@ class PlatformAutoGen(AutoGen):
if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:
BuildRuleOrder = Options[Tool][Attr]
AllTools = set(ModuleOptions.keys() + PlatformOptions.keys() +
PlatformModuleOptions.keys() + ModuleTypeOptions.keys() +
self.ToolDefinition.keys())
AllTools = set(list(ModuleOptions.keys()) + list(PlatformOptions.keys()) +
list(PlatformModuleOptions.keys()) + list(ModuleTypeOptions.keys()) +
list(self.ToolDefinition.keys()))
BuildOptions = defaultdict(lambda: defaultdict(str))
for Tool in AllTools:
for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, ModuleTypeOptions, PlatformModuleOptions]:
@ -3519,7 +3519,7 @@ class ModuleAutoGen(AutoGen):
return None
MapFileName = os.path.join(self.OutputDir, self.Name + ".map")
EfiFileName = os.path.join(self.OutputDir, self.Name + ".efi")
VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName, VfrUniBaseName.values())
VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName, list(VfrUniBaseName.values()))
if not VfrUniOffsetList:
return None

View File

@ -2050,7 +2050,7 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer,
if Guid in Info.Module.GetGuidsUsedByPcd():
continue
GuidMacros.append('#define %s %s' % (Guid, Info.Module.Guids[Guid]))
for Guid, Value in Info.Module.Protocols.items() + Info.Module.Ppis.items():
for Guid, Value in list(Info.Module.Protocols.items()) + list(Info.Module.Ppis.items()):
GuidMacros.append('#define %s %s' % (Guid, Value))
# supports FixedAtBuild and FeaturePcd usage in VFR file
if Info.VfrFileList and Info.ModulePcdList:

View File

@ -675,8 +675,8 @@ cleanlib:
"separator" : Separator,
"module_tool_definitions" : ToolsDef,
"shell_command_code" : self._SHELL_CMD_[self._FileType].keys(),
"shell_command" : self._SHELL_CMD_[self._FileType].values(),
"shell_command_code" : list(self._SHELL_CMD_[self._FileType].keys()),
"shell_command" : list(self._SHELL_CMD_[self._FileType].values()),
"module_entry_point" : ModuleEntryPoint,
"image_entry_point" : ImageEntryPoint,
@ -1275,8 +1275,8 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\
"separator" : Separator,
"module_tool_definitions" : ToolsDef,
"shell_command_code" : self._SHELL_CMD_[self._FileType].keys(),
"shell_command" : self._SHELL_CMD_[self._FileType].values(),
"shell_command_code" : list(self._SHELL_CMD_[self._FileType].keys()),
"shell_command" : list(self._SHELL_CMD_[self._FileType].values()),
"create_directory_command" : self.GetCreateDirectoryCommand(self.IntermediateDirectoryList),
"custom_makefile_content" : CustomMakefile
@ -1449,8 +1449,8 @@ cleanlib:
"toolchain_tag" : MyAgo.ToolChain,
"build_target" : MyAgo.BuildTarget,
"shell_command_code" : self._SHELL_CMD_[self._FileType].keys(),
"shell_command" : self._SHELL_CMD_[self._FileType].values(),
"shell_command_code" : list(self._SHELL_CMD_[self._FileType].keys()),
"shell_command" : list(self._SHELL_CMD_[self._FileType].values()),
"build_architecture_list" : MyAgo.Arch,
"architecture" : MyAgo.Arch,
"separator" : Separator,
@ -1581,8 +1581,8 @@ class TopLevelMakefile(BuildFile):
"toolchain_tag" : MyAgo.ToolChain,
"build_target" : MyAgo.BuildTarget,
"shell_command_code" : self._SHELL_CMD_[self._FileType].keys(),
"shell_command" : self._SHELL_CMD_[self._FileType].values(),
"shell_command_code" : list(self._SHELL_CMD_[self._FileType].keys()),
"shell_command" : list(self._SHELL_CMD_[self._FileType].values()),
'arch' : list(MyAgo.ArchList),
"build_architecture_list" : ','.join(MyAgo.ArchList),
"separator" : Separator,

View File

@ -615,7 +615,7 @@ def BuildExDataBase(Dict):
DbVardefValueUint32 = DbItemList(4, RawDataList = VardefValueUint32)
VpdHeadValue = Dict['VPD_DB_VALUE']
DbVpdHeadValue = DbComItemList(4, RawDataList = VpdHeadValue)
ExMapTable = zip(Dict['EXMAPPING_TABLE_EXTOKEN'], Dict['EXMAPPING_TABLE_LOCAL_TOKEN'], Dict['EXMAPPING_TABLE_GUID_INDEX'])
ExMapTable = list(zip(Dict['EXMAPPING_TABLE_EXTOKEN'], Dict['EXMAPPING_TABLE_LOCAL_TOKEN'], Dict['EXMAPPING_TABLE_GUID_INDEX']))
DbExMapTable = DbExMapTblItemList(8, RawDataList = ExMapTable)
LocalTokenNumberTable = Dict['LOCAL_TOKEN_NUMBER_DB_VALUE']
DbLocalTokenNumberTable = DbItemList(4, RawDataList = LocalTokenNumberTable)
@ -649,7 +649,7 @@ def BuildExDataBase(Dict):
PcdNameOffsetTable = Dict['PCD_NAME_OFFSET']
DbPcdNameOffsetTable = DbItemList(4, RawDataList = PcdNameOffsetTable)
SizeTableValue = zip(Dict['SIZE_TABLE_MAXIMUM_LENGTH'], Dict['SIZE_TABLE_CURRENT_LENGTH'])
SizeTableValue = list(zip(Dict['SIZE_TABLE_MAXIMUM_LENGTH'], Dict['SIZE_TABLE_CURRENT_LENGTH']))
DbSizeTableValue = DbSizeTableItemList(2, RawDataList = SizeTableValue)
InitValueUint16 = Dict['INIT_DB_VALUE_UINT16']
DbInitValueUint16 = DbComItemList(2, RawDataList = InitValueUint16)

View File

@ -551,9 +551,9 @@ def GetStringFiles(UniFilList, SourceFileList, IncludeList, IncludePathList, Ski
#
# support ISO 639-2 codes in .UNI files of EDK Shell
#
Uni = UniFileClassObject(sorted (UniFilList), True, IncludePathList)
Uni = UniFileClassObject(sorted(UniFilList, key=lambda x: x.File), True, IncludePathList)
else:
Uni = UniFileClassObject(sorted (UniFilList), IsCompatibleMode, IncludePathList)
Uni = UniFileClassObject(sorted(UniFilList, key=lambda x: x.File), IsCompatibleMode, IncludePathList)
else:
EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR, 'No unicode files given')