From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CA25F211BB8BC for ; Thu, 24 Jan 2019 21:05:23 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2019 21:05:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,519,1539673200"; d="scan'208";a="294272639" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.47]) by orsmga005.jf.intel.com with ESMTP; 24 Jan 2019 21:05:22 -0800 From: "Feng, Bob C" To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao , Yonghong Zhu , "Zhiju . Fan" Date: Fri, 25 Jan 2019 12:56:23 +0800 Message-Id: <20190125045626.14700-31-bob.c.feng@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 In-Reply-To: <20190125045626.14700-1-bob.c.feng@intel.com> References: <20190125045626.14700-1-bob.c.feng@intel.com> MIME-Version: 1.0 Subject: [Patch 30/33] BaseTools: the list and iterator translation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2019 05:05:24 -0000 Content-Transfer-Encoding: 8bit In python3,The keys of the dictionary not a list,It needs to be converted Cc: Bob Feng Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan --- BaseTools/Source/Python/AutoGen/AutoGen.py | 26 +++++++++++++------------- BaseTools/Source/Python/AutoGen/GenC.py | 2 +- BaseTools/Source/Python/AutoGen/GenMake.py | 16 ++++++++-------- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 4 ++-- BaseTools/Source/Python/AutoGen/StrGather.py | 4 ++-- BaseTools/Source/Python/Common/Misc.py | 5 +++-- BaseTools/Source/Python/Common/StringUtils.py | 6 +++--- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 2 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 16 ++++++++-------- BaseTools/Source/Python/Workspace/InfBuildData.py | 4 ++-- BaseTools/Source/Python/Workspace/MetaDataTable.py | 2 +- BaseTools/Source/Python/build/BuildReport.py | 4 ++-- BaseTools/Source/Python/build/build.py | 2 +- 13 files changed, 47 insertions(+), 46 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 5f0da5a815..baa1842667 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -927,11 +927,11 @@ class WorkspaceAutoGen(AutoGen): # @return None # 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) : Item = PcdList[Count] ItemNext = PcdList[Count + 1] @@ -973,11 +973,11 @@ class WorkspaceAutoGen(AutoGen): ) SameTokenValuePcdListCount += 1 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) : Item = PcdList[Count] ItemNext = PcdList[Count + 1] @@ -1298,11 +1298,11 @@ class PlatformAutoGen(AutoGen): if PcdNvStoreDfBuffer: 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) NvStoreOffset = int(NvStoreOffset, 16) if NvStoreOffset.upper().startswith("0X") else int(NvStoreOffset) default_skuobj = PcdNvStoreDfBuffer[0].SkuInfoList.get(TAB_DEFAULT) @@ -1497,11 +1497,11 @@ class PlatformAutoGen(AutoGen): self._PlatformPcds[item].DatumType = TAB_VOID 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"]: Pcd.DatumType = TAB_VOID @@ -1603,11 +1603,11 @@ class PlatformAutoGen(AutoGen): # Not found, it should be signature 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)) SkuObjList[0], SkuObjList[defaultindex] = SkuObjList[defaultindex], SkuObjList[0] for (SkuName, Sku) in SkuObjList: @@ -1629,11 +1629,11 @@ class PlatformAutoGen(AutoGen): DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue DscPcdEntry.TokenValue = DecPcdEntry.TokenValue 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) Sku.VpdOffset = Sku.VpdOffset.strip() PcdValue = Sku.DefaultValue @@ -1711,11 +1711,11 @@ class PlatformAutoGen(AutoGen): EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath) # 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"]: Pcd.DatumType = TAB_VOID @@ -2284,11 +2284,11 @@ class PlatformAutoGen(AutoGen): Pcd.MaxDatumSize = str((len(Value) - 2) * 2) elif Value[0] == '{': Pcd.MaxDatumSize = str(len(Value.split(','))) else: Pcd.MaxDatumSize = str(len(Value) - 1) - return Pcds.values() + return list(Pcds.values()) ## Calculate the priority value of the build option # @@ -2353,11 +2353,11 @@ 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("_") for Index1 in range(len(KeyList) - Index - 1): NextKey = KeyList[Index1 + Index + 1] @@ -2471,13 +2471,13 @@ class PlatformAutoGen(AutoGen): for Tool in Options: for Attr in Options[Tool]: 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]: if Tool not in Options: continue @@ -3517,11 +3517,11 @@ class ModuleAutoGen(AutoGen): if not VfrUniBaseName: 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 OutputName = '%sOffset.bin' % self.Name UniVfrOffsetFileName = os.path.join( self.OutputDir, OutputName) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index f1f3b6f359..700c94b3a7 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -2048,11 +2048,11 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer, GuidMacros = [] for Guid in Info.Module.Guids: 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: GuidMacros.append('#define %s %s' % ('FixedPcdGetBool(TokenName)', '_PCD_VALUE_##TokenName')) GuidMacros.append('#define %s %s' % ('FixedPcdGet8(TokenName)', '_PCD_VALUE_##TokenName')) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 3094a555e0..c42053eb4c 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -673,12 +673,12 @@ cleanlib: "module_debug_directory" : MyAgo.DebugDir, "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, "arch_entry_point" : ArchEntryPoint, "remaining_build_target" : self.ResultFileList, @@ -1273,12 +1273,12 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\ "module_debug_directory" : MyAgo.DebugDir, "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 } @@ -1447,12 +1447,12 @@ cleanlib: "platform_build_directory" : MyAgo.BuildDir, "platform_dir" : MyAgo.Macros["PLATFORM_DIR"], "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, "create_directory_command" : self.GetCreateDirectoryCommand(self.IntermediateDirectoryList), "cleanall_command" : self.GetRemoveDirectoryCommand(self.IntermediateDirectoryList), @@ -1579,12 +1579,12 @@ class TopLevelMakefile(BuildFile): "platform_build_directory" : MyAgo.BuildDir, "conf_directory" : GlobalData.gConfDirectory, "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, "create_directory_command" : self.GetCreateDirectoryCommand(self.IntermediateDirectoryList), "cleanall_command" : self.GetRemoveDirectoryCommand(self.IntermediateDirectoryList), diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index d3e85293d2..2cb1745823 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -613,11 +613,11 @@ def BuildExDataBase(Dict): DbInitValueUint32 = DbComItemList(4, RawDataList = InitValueUint32) VardefValueUint32 = Dict['VARDEF_DB_VALUE_UINT32'] 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) GuidTable = Dict['GUID_STRUCTURE'] DbGuidTable = DbItemList(16, RawDataList = GuidTable) @@ -647,11 +647,11 @@ def BuildExDataBase(Dict): DbPcdCNameTable = DbStringItemList(0, RawDataList = PcdCNameTableValue, LenList = PcdCNameLen) 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) VardefValueUint16 = Dict['VARDEF_DB_VALUE_UINT16'] DbVardefValueUint16 = DbItemList(2, RawDataList = VardefValueUint16) diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py index d34a9e9447..d87680b2e7 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -549,13 +549,13 @@ def GetStringFiles(UniFilList, SourceFileList, IncludeList, IncludePathList, Ski if len(UniFilList) > 0: if ShellMode: # # 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') FileList = GetFileList(SourceFileList, IncludeList, SkipList) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index f29bc604a0..3b228f2f32 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -599,17 +599,18 @@ def RealPath2(File, Dir='', OverrideDir=''): # @retval GuidValue if the CName is found in any given package # @retval None if the CName is not found in all given packages # def GuidValue(CName, PackageList, Inffile = None): for P in PackageList: - GuidKeys = P.Guids.keys() + GuidKeys = list(P.Guids.keys()) if Inffile and P._PrivateGuids: if not Inffile.startswith(P.MetaFile.Dir): GuidKeys = [x for x in P.Guids if x not in P._PrivateGuids] if CName in GuidKeys: return P.Guids[CName] return None + return None ## A string template class # # This class implements a template for string replacement. A string template # looks like following @@ -1674,11 +1675,11 @@ class SkuClass(): self._SkuIdentifier = SkuIdentifier if SkuIdentifier == '' or SkuIdentifier is None: self.SkuIdSet = ['DEFAULT'] self.SkuIdNumberSet = ['0U'] elif SkuIdentifier == 'ALL': - self.SkuIdSet = SkuIds.keys() + self.SkuIdSet = list(SkuIds.keys()) self.SkuIdNumberSet = [num[0].strip() + 'U' for num in SkuIds.values()] else: r = SkuIdentifier.split('|') self.SkuIdSet=[(r[k].strip()).upper() for k in range(len(r))] k = None diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py index d5afde7a95..0fa51f365b 100644 --- a/BaseTools/Source/Python/Common/StringUtils.py +++ b/BaseTools/Source/Python/Common/StringUtils.py @@ -97,11 +97,11 @@ def GetSplitValueList(String, SplitTag=DataType.TAB_VALUE_SPLIT, MaxSplit= -1): # @param MaxSplit: The max number of split values, default is -1 # # @retval list() A list for splitted string # def GetSplitList(String, SplitStr=DataType.TAB_VALUE_SPLIT, MaxSplit= -1): - return map(lambda l: l.strip(), String.split(SplitStr, MaxSplit)) + return list(map(lambda l: l.strip(), String.split(SplitStr, MaxSplit))) ## MergeArches # # Find a key's all arches in dict, add the new arch to the list # If not exist any arch, set the arch directly @@ -543,11 +543,11 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, CommentCharacter, KeySplitCh # # Remove comments and white spaces # LineList[1] = CleanString(LineList[1], CommentCharacter) if ValueSplitFlag: - Value = map(string.strip, LineList[1].split(ValueSplitCharacter)) + Value = list(map(string.strip, LineList[1].split(ValueSplitCharacter))) else: Value = CleanString(LineList[1], CommentCharacter).splitlines() if Key[0] in Dictionary: if Key[0] not in Keys: @@ -749,11 +749,11 @@ def SplitString(String): # 1. Replace "'" with "''" in each item of StringList # # @param StringList: A list for strings to be converted # def ConvertToSqlString(StringList): - return map(lambda s: s.replace("'", "''"), StringList) + return list(map(lambda s: s.replace("'", "''"), StringList)) ## Convert To Sql String # # 1. Replace "'" with "''" in the String # diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index a7298a6daf..80257923f0 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -1073,11 +1073,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # @retval RetValue A list contain offset of UNI/INF object. # def __GetBuildOutputMapFileVfrUniInfo(self, VfrUniBaseName): MapFileName = os.path.join(self.EfiOutputPath, self.BaseName + ".map") EfiFileName = os.path.join(self.EfiOutputPath, self.BaseName + ".efi") - return GetVariableOffset(MapFileName, EfiFileName, VfrUniBaseName.values()) + return GetVariableOffset(MapFileName, EfiFileName, list(VfrUniBaseName.values())) ## __GenUniVfrOffsetFile() method # # Generate the offset file for the module which contain VFR or UNI file. # diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index c2bc705091..13b2cef59d 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1604,11 +1604,11 @@ class DscBuildData(PlatformBuildClassObject): pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON] del pcd.SkuInfoList[TAB_COMMON] elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList: del pcd.SkuInfoList[TAB_COMMON] - map(self.FilterSkuSettings, [Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType]) + list((self.FilterSkuSettings, [Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType])) return Pcds @cached_property def PlatformUsedPcds(self): FdfInfList = [] if GlobalData.gFdfParser: @@ -2558,11 +2558,11 @@ class DscBuildData(PlatformBuildClassObject): BuildOptions[Arch] |= self.ParseCCFlags(self.BuildOptions[Options]) if BuildOptions: ArchBuildOptions = {arch:flags for arch,flags in BuildOptions.items() if arch != 'COMMON'} if len(ArchBuildOptions.keys()) == 1: - BuildOptions['COMMON'] |= (ArchBuildOptions.values()[0]) + BuildOptions['COMMON'] |= (list(ArchBuildOptions.values())[0]) elif len(ArchBuildOptions.keys()) > 1: CommonBuildOptions = reduce(lambda x,y: x&y, ArchBuildOptions.values()) BuildOptions['COMMON'] |= CommonBuildOptions ValueList = list(BuildOptions['COMMON']) CC_FLAGS += " ".join(ValueList) @@ -2776,11 +2776,11 @@ class DscBuildData(PlatformBuildClassObject): pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON] del pcd.SkuInfoList[TAB_COMMON] elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList: del pcd.SkuInfoList[TAB_COMMON] - map(self.FilterSkuSettings, Pcds.values()) + list(map(self.FilterSkuSettings, Pcds.values())) return Pcds def FilterSkuSettings(self, PcdObj): @@ -2841,11 +2841,11 @@ class DscBuildData(PlatformBuildClassObject): nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid) PcdObj.SkuInfoList[skuname] = copy.deepcopy(PcdObj.SkuInfoList[nextskuid]) PcdObj.SkuInfoList[skuname].SkuId = skuid PcdObj.SkuInfoList[skuname].SkuIdName = skuname if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: - PcdObj.DefaultValue = PcdObj.SkuInfoList.values()[0].HiiDefaultValue if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE else PcdObj.SkuInfoList[TAB_DEFAULT].HiiDefaultValue + PcdObj.DefaultValue = list(PcdObj.SkuInfoList.values())[0].HiiDefaultValue if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE else PcdObj.SkuInfoList[TAB_DEFAULT].HiiDefaultValue Pcds[PcdCName, TokenSpaceGuid]= PcdObj return Pcds ## Retrieve dynamic HII PCD settings # # @param Type PCD type @@ -2962,21 +2962,21 @@ class DscBuildData(PlatformBuildClassObject): Pcds[PcdCName, TokenSpaceGuid].CustomAttribute['DscPosition'] = int(Dummy4) if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue: Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] = {} Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][DefaultStore] = DefaultValue for pcd in Pcds.values(): - SkuInfoObj = pcd.SkuInfoList.values()[0] pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName] pcd.DatumType = pcdDecObject.DatumType # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): if (sku.HiiDefaultValue == "" or sku.HiiDefaultValue is None): sku.HiiDefaultValue = pcdDecObject.DefaultValue for default_store in sku.DefaultStoreDict: sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue pcd.DefaultValue = pcdDecObject.DefaultValue if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pcd.SkuInfoList: + SkuInfoObj = list(pcd.SkuInfoList.values())[0] valuefromDec = pcdDecObject.DefaultValue SkuInfo = SkuInfoClass(TAB_DEFAULT, '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec, VariableAttribute=SkuInfoObj.VariableAttribute, DefaultStore={DefaultStore:valuefromDec}) pcd.SkuInfoList[TAB_DEFAULT] = SkuInfo elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList: pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON] @@ -3002,11 +3002,11 @@ class DscBuildData(PlatformBuildClassObject): rt, invalidhii = DscBuildData.CheckVariableNameAssignment(Pcds) if not rt: invalidpcd = ",".join(invalidhii) EdkLogger.error('build', PCD_VARIABLE_INFO_ERROR, Message='The same HII PCD must map to the same EFI variable for all SKUs', File=self.MetaFile, ExtraData=invalidpcd) - map(self.FilterSkuSettings, Pcds.values()) + list(map(self.FilterSkuSettings, Pcds.values())) return Pcds @staticmethod def CheckVariableNameAssignment(Pcds): @@ -3100,18 +3100,18 @@ class DscBuildData(PlatformBuildClassObject): if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue: Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] = {} Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][TAB_DEFAULT_STORES_DEFAULT] = InitialValue for pcd in Pcds.values(): - SkuInfoObj = pcd.SkuInfoList.values()[0] pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName] pcd.DatumType = pcdDecObject.DatumType # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): if not sku.DefaultValue: sku.DefaultValue = pcdDecObject.DefaultValue if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pcd.SkuInfoList: + SkuInfoObj = list(pcd.SkuInfoList.values())[0] valuefromDec = pcdDecObject.DefaultValue SkuInfo = SkuInfoClass(TAB_DEFAULT, '0', '', '', '', '', SkuInfoObj.VpdOffset, valuefromDec) pcd.SkuInfoList[TAB_DEFAULT] = SkuInfo elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList: pcd.SkuInfoList[TAB_DEFAULT] = pcd.SkuInfoList[TAB_COMMON] @@ -3127,11 +3127,11 @@ class DscBuildData(PlatformBuildClassObject): PcdValueTypeSet.add("UnicodeString" if sku.DefaultValue.startswith(('L"',"L'")) else "OtherVOID*") if len(PcdValueTypeSet) > 1: for sku in pcd.SkuInfoList.values(): sku.DefaultValue = StringToArray(sku.DefaultValue) if sku.DefaultValue.startswith(('L"',"L'")) else sku.DefaultValue - map(self.FilterSkuSettings, Pcds.values()) + list(map(self.FilterSkuSettings, Pcds.values())) return Pcds ## Add external modules # # The external modules are mostly those listed in FDF file, which don't diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index f0c7e6ddd4..fc779a9d25 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -30,11 +30,11 @@ from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObjec # @retval GuidValue if the CName is found in any given package # @retval None if the CName is not found in all given packages # def _ProtocolValue(CName, PackageList, Inffile = None): for P in PackageList: - ProtocolKeys = P.Protocols.keys() + ProtocolKeys = list(P.Protocols.keys()) if Inffile and P._PrivateProtocols: if not Inffile.startswith(P.MetaFile.Dir): ProtocolKeys = [x for x in P.Protocols if x not in P._PrivateProtocols] if CName in ProtocolKeys: return P.Protocols[CName] @@ -49,11 +49,11 @@ def _ProtocolValue(CName, PackageList, Inffile = None): # @retval GuidValue if the CName is found in any given package # @retval None if the CName is not found in all given packages # def _PpiValue(CName, PackageList, Inffile = None): for P in PackageList: - PpiKeys = P.Ppis.keys() + PpiKeys = list(P.Ppis.keys()) if Inffile and P._PrivatePpis: if not Inffile.startswith(P.MetaFile.Dir): PpiKeys = [x for x in P.Ppis if x not in P._PrivatePpis] if CName in PpiKeys: return P.Ppis[CName] diff --git a/BaseTools/Source/Python/Workspace/MetaDataTable.py b/BaseTools/Source/Python/Workspace/MetaDataTable.py index 8becddbe08..c5be0ab10c 100644 --- a/BaseTools/Source/Python/Workspace/MetaDataTable.py +++ b/BaseTools/Source/Python/Workspace/MetaDataTable.py @@ -20,11 +20,11 @@ import Common.EdkLogger as EdkLogger from CommonDataClass import DataClass from CommonDataClass.DataClass import FileClass ## Convert to SQL required string format def ConvertToSqlString(StringList): - return map(lambda s: "'" + s.replace("'", "''") + "'", StringList) + return list(map(lambda s: "'" + s.replace("'", "''") + "'", StringList)) ## TableFile # # This class defined a common table # diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index ffc5c237a2..86c4c5bf7f 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -1207,11 +1207,11 @@ class PcdReport(object): FileWrite(File, gSubSectionEnd) def ParseStruct(self, struct): HasDscOverride = False if struct: - for _, Values in struct.items(): + for _, Values in list(struct.items()): if Values[1] and Values[1].endswith('.dsc'): HasDscOverride = True break return HasDscOverride @@ -1420,11 +1420,11 @@ class PcdReport(object): VPDPcdList.append(VPDPcdItem) if IsStructure: FiledOverrideFlag = False OverrideValues = Pcd.SkuOverrideValues[Sku] if OverrideValues: - Keys = OverrideValues.keys() + Keys = list(OverrideValues.keys()) OverrideFieldStruct = self.OverrideFieldValue(Pcd, OverrideValues[Keys[0]]) self.PrintStructureInfo(File, OverrideFieldStruct) FiledOverrideFlag = True if not FiledOverrideFlag and (Pcd.PcdFieldValueFromComm or Pcd.PcdFieldValueFromFdf): OverrideFieldStruct = self.OverrideFieldValue(Pcd, {}) diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index 26d1df2245..8d3761313f 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -478,11 +478,11 @@ class BuildTask: EdkLogger.debug(EdkLogger.DEBUG_8, "Pending Queue (%d), Ready Queue (%d)" % (len(BuildTask._PendingQueue), len(BuildTask._ReadyQueue))) # get all pending tasks BuildTask._PendingQueueLock.acquire() - BuildObjectList = BuildTask._PendingQueue.keys() + BuildObjectList = list(BuildTask._PendingQueue.keys()) # # check if their dependency is resolved, and if true, move them # into ready queue # for BuildObject in BuildObjectList: -- 2.20.1.windows.1