]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: refactor and remove un-needed use of .keys() on dictionaries
authorCarsey, Jaben <jaben.carsey@intel.com>
Tue, 17 Apr 2018 14:40:15 +0000 (22:40 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 18 Apr 2018 14:15:36 +0000 (22:15 +0800)
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>
27 files changed:
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools/Source/Python/AutoGen/GenVar.py
BaseTools/Source/Python/AutoGen/InfSectionParser.py
BaseTools/Source/Python/BPDG/GenVpd.py
BaseTools/Source/Python/Common/EdkIIWorkspace.py
BaseTools/Source/Python/Common/Expression.py
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/Common/Parsing.py
BaseTools/Source/Python/Common/String.py
BaseTools/Source/Python/Common/VpdInfoFile.py
BaseTools/Source/Python/GenFds/Capsule.py
BaseTools/Source/Python/GenFds/CapsuleData.py
BaseTools/Source/Python/GenFds/Fd.py
BaseTools/Source/Python/GenFds/FdfParser.py
BaseTools/Source/Python/GenFds/FfsFileStatement.py
BaseTools/Source/Python/GenFds/FfsInfStatement.py
BaseTools/Source/Python/GenFds/Fv.py
BaseTools/Source/Python/GenFds/GenFds.py
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
BaseTools/Source/Python/GenFds/Region.py
BaseTools/Source/Python/TargetTool/TargetTool.py
BaseTools/Source/Python/Workspace/InfBuildData.py
BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools/Source/Python/Workspace/WorkspaceCommon.py
BaseTools/Source/Python/build/BuildReport.py
BaseTools/Source/Python/build/build.py

index bd443fe6261aefc0cf68112569e082e1e04790ba..6152225943cf51a0f52b161ffd887a98237c1f1d 100644 (file)
@@ -762,7 +762,7 @@ class WorkspaceAutoGen(AutoGen):
                         for Module in Pa.ModuleAutoGenList:\r
                             if path.normpath(Module.MetaFile.File) == path.normpath(FfsFile.InfFileName):\r
                                 InfFoundFlag = True\r
-                                if not Module.Guid.upper() in _GuidDict.keys():\r
+                                if Module.Guid.upper() not in _GuidDict:\r
                                     _GuidDict[Module.Guid.upper()] = FfsFile\r
                                     break\r
                                 else:\r
@@ -789,7 +789,7 @@ class WorkspaceAutoGen(AutoGen):
                             # BuildObject from one of AutoGenObjectList is enough.\r
                             #\r
                             InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_COMMON, self.BuildTarget, self.ToolChain]\r
-                            if not InfObj.Guid.upper() in _GuidDict.keys():\r
+                            if InfObj.Guid.upper() not in _GuidDict:\r
                                 _GuidDict[InfObj.Guid.upper()] = FfsFile\r
                             else:\r
                                 EdkLogger.error("build",\r
@@ -837,7 +837,7 @@ class WorkspaceAutoGen(AutoGen):
                                                             "The format of PCD value is incorrect. PCD: %s , Value: %s\n" % (_PcdName, PcdItem.DefaultValue),\r
                                                             ExtraData=self.FdfFile)\r
 \r
-                                        if not _PcdGuidString.upper() in _GuidDict.keys():\r
+                                        if _PcdGuidString.upper() not in _GuidDict:\r
                                             _GuidDict[_PcdGuidString.upper()] = FfsFile\r
                                             PcdFoundFlag = True\r
                                             break\r
@@ -851,7 +851,7 @@ class WorkspaceAutoGen(AutoGen):
                                                                                                                                            FfsFile.NameGuid.upper()),\r
                                                             ExtraData=self.FdfFile)\r
 \r
-                    if not FfsFile.NameGuid.upper() in _GuidDict.keys():\r
+                    if FfsFile.NameGuid.upper() not in _GuidDict:\r
                         _GuidDict[FfsFile.NameGuid.upper()] = FfsFile\r
                     else:\r
                         #\r
@@ -1402,10 +1402,8 @@ class PlatformAutoGen(AutoGen):
                     PcdFromModule.IsFromBinaryInf = True\r
 \r
                 # Check the PCD from DSC or not \r
-                if (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds.keys():\r
-                    PcdFromModule.IsFromDsc = True\r
-                else:\r
-                    PcdFromModule.IsFromDsc = False\r
+                PcdFromModule.IsFromDsc = (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds\r
+\r
                 if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule.Type in GenC.gDynamicExPcd:\r
                     if F.Path not in FdfModuleList:\r
                         # If one of the Source built modules listed in the DSC is not listed \r
@@ -1532,8 +1530,8 @@ class PlatformAutoGen(AutoGen):
         VpdFile               = VpdInfoFile.VpdInfoFile()\r
         NeedProcessVpdMapFile = False\r
 \r
-        for pcd in self.Platform.Pcds.keys():\r
-            if pcd not in self._PlatformPcds.keys():\r
+        for pcd in self.Platform.Pcds:\r
+            if pcd not in self._PlatformPcds:\r
                 self._PlatformPcds[pcd] = self.Platform.Pcds[pcd]\r
 \r
         for item in self._PlatformPcds:\r
@@ -1543,7 +1541,7 @@ class PlatformAutoGen(AutoGen):
         if (self.Workspace.ArchList[-1] == self.Arch): \r
             for Pcd in self._DynamicPcdList:\r
                 # just pick the a value to determine whether is unicode string type\r
-                Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
+                Sku = Pcd.SkuInfoList.values()[0]\r
                 Sku.VpdOffset = Sku.VpdOffset.strip()\r
 \r
                 if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
@@ -1630,7 +1628,7 @@ class PlatformAutoGen(AutoGen):
                 if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
                     if not (self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == ''):\r
                         FoundFlag = False\r
-                        for VpdPcd in VpdFile._VpdArray.keys():\r
+                        for VpdPcd in VpdFile._VpdArray:\r
                             # This PCD has been referenced by module\r
                             if (VpdPcd.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \\r
                                (VpdPcd.TokenCName == DscPcdEntry.TokenCName):\r
@@ -1742,7 +1740,7 @@ class PlatformAutoGen(AutoGen):
             # Delete the DynamicPcdList At the last time enter into this function\r
             for Pcd in self._DynamicPcdList:\r
                 # just pick the a value to determine whether is unicode string type\r
-                Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
+                Sku = Pcd.SkuInfoList.values()[0]\r
                 Sku.VpdOffset = Sku.VpdOffset.strip()\r
 \r
                 if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
@@ -2482,7 +2480,7 @@ class PlatformAutoGen(AutoGen):
             for LibraryName in M.Libraries:\r
                 Library = self.Platform.LibraryClasses[LibraryName, ':dummy:']\r
                 if Library is None:\r
-                    for Key in self.Platform.LibraryClasses.data.keys():\r
+                    for Key in self.Platform.LibraryClasses.data:\r
                         if LibraryName.upper() == Key.upper():\r
                             Library = self.Platform.LibraryClasses[Key, ':dummy:']\r
                             break\r
@@ -3105,7 +3103,7 @@ class ModuleAutoGen(AutoGen):
             InfObj = InfSectionParser.InfSectionParser(Filename)\r
             DepexExpresionList = InfObj.GetDepexExpresionList()\r
             for DepexExpresion in DepexExpresionList:\r
-                for key in DepexExpresion.keys():\r
+                for key in DepexExpresion:\r
                     Arch, ModuleType = key\r
                     DepexExpr = [x for x in DepexExpresion[key] if not str(x).startswith('#')]\r
                     # the type of build module is USER_DEFINED.\r
@@ -3123,7 +3121,7 @@ class ModuleAutoGen(AutoGen):
         #the type of build module is USER_DEFINED.\r
         if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:\r
             for Depex in DepexList:\r
-                for key in Depex.keys():\r
+                for key in Depex:\r
                     DepexStr += '[Depex.%s.%s]\n' % key\r
                     DepexStr += '\n'.join(['# '+ val for val in Depex[key]])\r
                     DepexStr += '\n\n'\r
@@ -3233,7 +3231,7 @@ class ModuleAutoGen(AutoGen):
             InfObj = InfSectionParser.InfSectionParser(Filename)\r
             TianoCoreUserExtenList = InfObj.GetUserExtensionTianoCore()\r
             for TianoCoreUserExtent in TianoCoreUserExtenList:\r
-                for Section in TianoCoreUserExtent.keys():\r
+                for Section in TianoCoreUserExtent:\r
                     ItemList = Section.split(TAB_SPLIT)\r
                     Arch = self.Arch\r
                     if len(ItemList) == 4:\r
index b7594d8988da5a10ec6d35676a80de8670ed16ab..1bb5163e73e015ec5471653c03f3beae1f1f0a22 100644 (file)
@@ -495,11 +495,11 @@ cleanlib:
             if k not in self._AutoGenObject.Macros:\r
                 self._AutoGenObject.Macros[k] = v\r
 \r
-        if 'MODULE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():\r
+        if 'MODULE_ENTRY_POINT' not in self._AutoGenObject.Macros:\r
             self._AutoGenObject.Macros['MODULE_ENTRY_POINT'] = ModuleEntryPoint\r
-        if 'ARCH_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():\r
+        if 'ARCH_ENTRY_POINT' not in self._AutoGenObject.Macros:\r
             self._AutoGenObject.Macros['ARCH_ENTRY_POINT'] = ArchEntryPoint\r
-        if 'IMAGE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():\r
+        if 'IMAGE_ENTRY_POINT' not in self._AutoGenObject.Macros:\r
             self._AutoGenObject.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint\r
 \r
         PCI_COMPRESS_Flag = False\r
@@ -540,7 +540,7 @@ cleanlib:
         RespFileList = os.path.join(self._AutoGenObject.OutputDir, 'respfilelist.txt')\r
         if RespDict:\r
             RespFileListContent = ''\r
-            for Resp in RespDict.keys():\r
+            for Resp in RespDict:\r
                 RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt')\r
                 StrList = RespDict[Resp].split(' ')\r
                 UnexpandMacro = []\r
@@ -794,7 +794,7 @@ cleanlib:
                         SingleCommandLength = len(SingleCommand)\r
                         SingleCommandList = SingleCommand.split()\r
                         if len(SingleCommandList) > 0:\r
-                            for Flag in FlagDict.keys():\r
+                            for Flag in FlagDict:\r
                                 if '$('+ Flag +')' in SingleCommandList[0]:\r
                                     Tool = Flag\r
                                     break\r
@@ -807,12 +807,12 @@ cleanlib:
                                     if 'FLAGS' not in self._AutoGenObject._BuildOption[Tool]:\r
                                         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))\r
                                     Str = self._AutoGenObject._BuildOption[Tool]['FLAGS']\r
-                                    for Option in self._AutoGenObject.BuildOption.keys():\r
+                                    for Option in self._AutoGenObject.BuildOption:\r
                                         for Attr in self._AutoGenObject.BuildOption[Option]:\r
                                             if Str.find(Option + '_' + Attr) != -1:\r
                                                 Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])\r
                                     while(Str.find('$(') != -1):\r
-                                        for macro in self._AutoGenObject.Macros.keys():\r
+                                        for macro in self._AutoGenObject.Macros:\r
                                             MacroName = '$('+ macro + ')'\r
                                             if (Str.find(MacroName) != -1):\r
                                                 Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])\r
@@ -824,12 +824,12 @@ cleanlib:
                                     SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList)\r
                                 elif item.find('$(') != -1:\r
                                     Str = item\r
-                                    for Option in self._AutoGenObject.BuildOption.keys():\r
+                                    for Option in self._AutoGenObject.BuildOption:\r
                                         for Attr in self._AutoGenObject.BuildOption[Option]:\r
                                             if Str.find(Option + '_' + Attr) != -1:\r
                                                 Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])\r
                                     while(Str.find('$(') != -1):\r
-                                        for macro in self._AutoGenObject.Macros.keys():\r
+                                        for macro in self._AutoGenObject.Macros:\r
                                             MacroName = '$('+ macro + ')'\r
                                             if (Str.find(MacroName) != -1):\r
                                                 Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])\r
@@ -842,19 +842,19 @@ cleanlib:
                                 FlagDict[Tool]['Value'] = True\r
 \r
                 # generate the response file content by combine the FLAGS and INC\r
-                for Flag in FlagDict.keys():\r
+                for Flag in FlagDict:\r
                     if FlagDict[Flag]['Value']:\r
                         Key = Flag + '_RESP'\r
                         RespMacro = FlagDict[Flag]['Macro'].replace('FLAGS', 'RESP')\r
                         Value = self._AutoGenObject.BuildOption[Flag]['FLAGS']\r
                         for inc in self._AutoGenObject._IncludePathList:\r
                             Value += ' ' + IncPrefix + inc\r
-                        for Option in self._AutoGenObject.BuildOption.keys():\r
+                        for Option in self._AutoGenObject.BuildOption:\r
                             for Attr in self._AutoGenObject.BuildOption[Option]:\r
                                 if Value.find(Option + '_' + Attr) != -1:\r
                                     Value = Value.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])\r
                         while (Value.find('$(') != -1):\r
-                            for macro in self._AutoGenObject.Macros.keys():\r
+                            for macro in self._AutoGenObject.Macros:\r
                                 MacroName = '$('+ macro + ')'\r
                                 if (Value.find(MacroName) != -1):\r
                                     Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro])\r
index 1c66a9eb050f6f150f9899afa6defa7d58dcbdd0..37c168a84b4389a4b9049ae08d048b514f278ce5 100644 (file)
@@ -114,8 +114,8 @@ class VariableMgr(object):
         self.VarInfo = [item[0] for item in indexedvarinfo.values()]\r
 \r
     def assemble_variable(self, valuelist):\r
-        ordered_value = [valuelist[k] for k in sorted(valuelist.keys())]\r
         ordered_offset = sorted(valuelist.keys())\r
+        ordered_value = [valuelist[k] for k in ordered_offset]\r
         var_value = []\r
         num = 0\r
         for offset in ordered_offset:\r
index cdc9e5e8a849808b6bbc8677c1a69fefc5b23be8..cf4e76159e81daafaf0c59a18499f3f4840a03ef 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Parser a Inf file and Get specify section data.\r
 #\r
-# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -70,7 +70,7 @@ class InfSectionParser():
         if not self._FileSectionDataList:\r
             return UserExtensionTianoCore\r
         for SectionDataDict in self._FileSectionDataList:\r
-            for key in SectionDataDict.keys():\r
+            for key in SectionDataDict:\r
                 if key.lower().startswith("[userextensions") and key.lower().find('.tianocore.') > -1:\r
                     SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)\r
                     SubSectionList = [SectionLine]\r
@@ -89,7 +89,7 @@ class InfSectionParser():
         if not self._FileSectionDataList:\r
             return DepexExpresionList\r
         for SectionDataDict in self._FileSectionDataList:\r
-            for key in SectionDataDict.keys():\r
+            for key in SectionDataDict:\r
                 if key.lower() == "[depex]" or key.lower().startswith("[depex."):\r
                     SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)\r
                     SubSectionList = [SectionLine]\r
index 887240e94cb4147bd25bafe0d1e1a3977f9f13b0..69a9665f5a761f3a38f2acac022359d545b6c446 100644 (file)
@@ -120,7 +120,7 @@ class PcdEntry:
     # \r
     #                                \r
     def _PackIntValue(self, IntValue, Size):\r
-        if Size not in _FORMAT_CHAR.keys():\r
+        if Size not in _FORMAT_CHAR:\r
             EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,\r
                             "Invalid size %d for PCD %s in integer datum size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno))\r
 \r
index c14b4eb52d50f32a9c3e3fbac94de958327b4174..d75b9f8025b3e7ac7ff1f7c3516abef5ade21bb0 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This is the base class for applications that operate on an EDK II Workspace \r
 #\r
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -259,10 +259,7 @@ def ConvertDictionaryToTextFile(FileName, Dictionary, CommentCharacter, KeySplit
     except:\r
         Lines = []\r
     Keys = Dictionary.keys()\r
-    MaxLength = 0\r
-    for Key in Keys:\r
-        if len(Key) > MaxLength:\r
-            MaxLength = len(Key)\r
+    MaxLength = max(map(len,Keys))\r
     Index = 0\r
     for Line in Lines:\r
         LineList = Line.split(KeySplitCharacter, 1)\r
index 462e8f93f883e3d765ccf4fefac02ff1e849bd6b..9a3415ccaabe03bd29749f33a2895f88a91729a8 100644 (file)
@@ -151,7 +151,7 @@ def ReplaceExprMacro(String, Macros, ExceptionList = None):
             InQuote = True\r
         MacroStartPos = String.find('$(')\r
         if MacroStartPos < 0:\r
-            for Pcd in gPlatformPcds.keys():\r
+            for Pcd in gPlatformPcds:\r
                 if Pcd in String:\r
                     if Pcd not in gConditionalPcds:\r
                         gConditionalPcds.append(Pcd)\r
@@ -908,7 +908,7 @@ class ValueExpressionEx(ValueExpression):
                                 for Label in LabelList:\r
                                     if not IsValidCName(Label):\r
                                         raise BadExpression('%s is not a valid c variable name' % Label)\r
-                                    if Label not in LabelDict.keys():\r
+                                    if Label not in LabelDict:\r
                                         LabelDict[Label] = str(LabelOffset)\r
                             if Item.startswith('UINT8'):\r
                                 LabelOffset = LabelOffset + 1\r
index 5ffd8cd0223dbeb12f8f0428153de5509da0ea00..4f2bfd63cfc326b71481a0785d28659723652463 100644 (file)
@@ -1918,7 +1918,7 @@ class DefaultStore():
         if not self.DefaultStores or "0" in self.DefaultStores:\r
             return "0",TAB_DEFAULT_STORES_DEFAULT\r
         else:\r
-            minvalue = min([int(value_str) for value_str in self.DefaultStores.keys()])\r
+            minvalue = min([int(value_str) for value_str in self.DefaultStores])\r
             return (str(minvalue), self.DefaultStores[str(minvalue)])\r
     def GetMin(self,DefaultSIdList):\r
         if not DefaultSIdList:\r
index d199d1e40d8e0605de8fb8dd886e79908e8e68a6..453c2039e3d9a71b4058f70838dfe59b6e6afa4a 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to define common parsing related functions used in parsing INF/DEC/DSC process\r
 #\r
-# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -37,16 +37,14 @@ def ParseDefineMacro2(Table, RecordSets, GlobalMacro):
     #\r
     # Overrided by Global Macros\r
     #\r
-    for Key in GlobalMacro.keys():\r
-        Macros[Key] = GlobalMacro[Key]\r
+    Macros.update(GlobalMacro)\r
 \r
     #\r
     # Replace the Macros\r
     #\r
-    for Key in RecordSets.keys():\r
-        if RecordSets[Key] != []:\r
-            for Item in RecordSets[Key]:\r
-                Item[0] = ReplaceMacro(Item[0], Macros)\r
+    for Value in (v for v in RecordSets.values() if v):\r
+        for Item in Value:\r
+            Item[0] = ReplaceMacro(Item[0], Macros)\r
 \r
 ## ParseDefineMacro\r
 #\r
@@ -79,8 +77,7 @@ def ParseDefineMacro(Table, GlobalMacro):
     #\r
     # Overrided by Global Macros\r
     #\r
-    for Key in GlobalMacro.keys():\r
-        Macros[Key] = GlobalMacro[Key]\r
+    Macros.update(GlobalMacro)\r
 \r
     #\r
     # Found all defined macro and replaced\r
index 5dc5b85dc5a459fb03358fd9ff07571cdc1de3b1..ee26d7f7b1b07dc64cec01437af6b0adcda7bb78 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to define common string related functions used in parsing process\r
 #\r
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -110,7 +110,7 @@ def GetSplitList(String, SplitStr=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
 # @param Arch:  The Arch to be added or merged\r
 #\r
 def MergeArches(Dict, Key, Arch):\r
-    if Key in Dict.keys():\r
+    if Key in Dict:\r
         Dict[Key].append(Arch)\r
     else:\r
         Dict[Key] = Arch.split()\r
index b1baf06b9ccd40a4f86b14965b271df980afd7b3..5559a88b97f2765fe669c62d2c8641151d7aba75 100644 (file)
@@ -6,7 +6,7 @@
 # is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt \r
 #\r
 #\r
-# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -107,7 +107,7 @@ class VpdInfoFile:
                 EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,\r
                                 "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))\r
             \r
-        if Vpd not in self._VpdArray.keys():\r
+        if Vpd not in self._VpdArray:\r
             #\r
             # If there is no Vpd instance in dict, that imply this offset for a given SKU is a new one \r
             #\r
@@ -180,12 +180,12 @@ class VpdInfoFile:
             if (TokenSpaceName, PcdTokenName) not in self._VpdInfo:\r
                 self._VpdInfo[(TokenSpaceName, PcdTokenName)] = []\r
             self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId,Offset, Value))\r
-            for VpdObject in self._VpdArray.keys():\r
+            for VpdObject in self._VpdArray:\r
                 VpdObjectTokenCName = VpdObject.TokenCName\r
                 for PcdItem in GlobalData.MixedPcd:\r
                     if (VpdObject.TokenCName, VpdObject.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r
                         VpdObjectTokenCName = PcdItem[0]\r
-                for sku in VpdObject.SkuInfoList.keys():\r
+                for sku in VpdObject.SkuInfoList:\r
                     if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObjectTokenCName == PcdTokenName.strip() and sku == SkuId:\r
                         if self._VpdArray[VpdObject][sku] == "*":\r
                             if Offset == "*":\r
index 9332f016f7da8db4d4727fa650f82cafd2269751..fbd48f3c6d7663bb37633f8a923190fc6274f05c 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # generate capsule\r
 #\r
-#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -201,7 +201,7 @@ class Capsule (CapsuleClassObject) :
     #   @retval string      Generated Capsule file path\r
     #\r
     def GenCapsule(self):\r
-        if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict.keys():\r
+        if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict:\r
             return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap']\r
 \r
         GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName)\r
@@ -251,11 +251,11 @@ class Capsule (CapsuleClassObject) :
 \r
         CapInfFile.writelines("[options]" + T_CHAR_LF)\r
 \r
-        for Item in self.TokensDict.keys():\r
+        for Item in self.TokensDict:\r
             CapInfFile.writelines("EFI_"                    + \\r
                                   Item                      + \\r
                                   ' = '                     + \\r
-                                  self.TokensDict.get(Item) + \\r
+                                  self.TokensDict[Item]     + \\r
                                   T_CHAR_LF)\r
 \r
         return CapInfFile\r
index 5b806d9e44825a6a1a4d20cd05cbc365f9e73004..b376d6b2e9be560a4f0cf71043a1576ab99c65ae 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # generate capsule\r
 #\r
-#  Copyright (c) 2007-2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007-2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -80,8 +80,8 @@ class CapsuleFv (CapsuleData):
     #\r
     def GenCapsuleSubItem(self):\r
         if self.FvName.find('.fv') == -1:\r
-            if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():\r
-                FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())\r
+            if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:\r
+                FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[self.FvName.upper()]\r
                 FdBuffer = StringIO.StringIO('')\r
                 FvObj.CapsuleName = self.CapsuleName\r
                 FvFile = FvObj.AddToBuffer(FdBuffer)\r
@@ -112,8 +112,8 @@ class CapsuleFd (CapsuleData):
     #\r
     def GenCapsuleSubItem(self):\r
         if self.FdName.find('.fd') == -1:\r
-            if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
-                FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())\r
+            if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:\r
+                FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[self.FdName.upper()]\r
                 FdFile = FdObj.GenFd()\r
                 return FdFile\r
         else:\r
index f735d3b5b015bc679c6b0fc8a3dfed895d1870f9..cc4124ad902e6905b82976cc0cf7745bd04a3e09 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process FD generation\r
 #\r
-#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -46,7 +46,7 @@ class FD(FDClassObject):
     #   @retval string      Generated FD file name\r
     #\r
     def GenFd (self, Flag = False):\r
-        if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict.keys():\r
+        if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict:\r
             return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd']\r
 \r
         #\r
index bff1d4739355af0d95264c16dd13cb5e4b44ad34..a106253527c4c97c15d16f46c73b0ae4c524d6d8 100644 (file)
@@ -3402,7 +3402,7 @@ class FdfParser:
         if not self.__GetNextToken():\r
             raise Warning("expected FV name", self.FileName, self.CurrentLineNumber)\r
 \r
-        if self.__Token.upper() not in self.Profile.FvDict.keys():\r
+        if self.__Token.upper() not in self.Profile.FvDict:\r
             raise Warning("FV name does not exist", self.FileName, self.CurrentLineNumber)\r
 \r
         CapsuleFv = CapsuleData.CapsuleFv()\r
@@ -3436,7 +3436,7 @@ class FdfParser:
         if not self.__GetNextToken():\r
             raise Warning("expected FD name", self.FileName, self.CurrentLineNumber)\r
 \r
-        if self.__Token.upper() not in self.Profile.FdDict.keys():\r
+        if self.__Token.upper() not in self.Profile.FdDict:\r
             raise Warning("FD name does not exist", self.FileName, self.CurrentLineNumber)\r
 \r
         CapsuleFd = CapsuleData.CapsuleFd()\r
@@ -4532,7 +4532,7 @@ class FdfParser:
     def __GetCapInFd (self, FdName):\r
 \r
         CapList = []\r
-        if FdName.upper() in self.Profile.FdDict.keys():\r
+        if FdName.upper() in self.Profile.FdDict:\r
             FdObj = self.Profile.FdDict[FdName.upper()]\r
             for elementRegion in FdObj.RegionList:\r
                 if elementRegion.RegionType == 'CAPSULE':\r
@@ -4579,7 +4579,7 @@ class FdfParser:
     def __GetFvInFd (self, FdName):\r
 \r
         FvList = []\r
-        if FdName.upper() in self.Profile.FdDict.keys():\r
+        if FdName.upper() in self.Profile.FdDict:\r
             FdObj = self.Profile.FdDict[FdName.upper()]\r
             for elementRegion in FdObj.RegionList:\r
                 if elementRegion.RegionType == 'FV':\r
@@ -4648,7 +4648,7 @@ class FdfParser:
         # Check the cycle between FV and FD image\r
         #\r
         MaxLength = len (self.Profile.FvDict)\r
-        for FvName in self.Profile.FvDict.keys():\r
+        for FvName in self.Profile.FvDict:\r
             LogStr = "\nCycle Reference Checking for FV: %s\n" % FvName\r
             RefFvStack = []\r
             RefFvStack.append(FvName)\r
@@ -4658,7 +4658,7 @@ class FdfParser:
             while RefFvStack != [] and Index < MaxLength:\r
                 Index = Index + 1\r
                 FvNameFromStack = RefFvStack.pop()\r
-                if FvNameFromStack.upper() in self.Profile.FvDict.keys():\r
+                if FvNameFromStack.upper() in self.Profile.FvDict:\r
                     FvObj = self.Profile.FvDict[FvNameFromStack.upper()]\r
                 else:\r
                     continue\r
@@ -4697,7 +4697,7 @@ class FdfParser:
         # Check the cycle between Capsule and FD image\r
         #\r
         MaxLength = len (self.Profile.CapsuleDict)\r
-        for CapName in self.Profile.CapsuleDict.keys():\r
+        for CapName in self.Profile.CapsuleDict:\r
             #\r
             # Capsule image to be checked.\r
             #\r
@@ -4711,7 +4711,7 @@ class FdfParser:
             while RefCapStack != [] and Index < MaxLength:\r
                 Index = Index + 1\r
                 CapNameFromStack = RefCapStack.pop()\r
-                if CapNameFromStack.upper() in self.Profile.CapsuleDict.keys():\r
+                if CapNameFromStack.upper() in self.Profile.CapsuleDict:\r
                     CapObj = self.Profile.CapsuleDict[CapNameFromStack.upper()]\r
                 else:\r
                     continue\r
@@ -4756,7 +4756,7 @@ class FdfParser:
                         if RefFvName in FvAnalyzedList:\r
                             continue\r
                         LogStr += "Capsule %s contains FV %s\n" % (CapNameFromStack, RefFvName)\r
-                        if RefFvName.upper() in self.Profile.FvDict.keys():\r
+                        if RefFvName.upper() in self.Profile.FvDict:\r
                             FvObj = self.Profile.FvDict[RefFvName.upper()]\r
                         else:\r
                             continue\r
index 3fd5a9c2158a6f7d3e20779d9cb2312a53432ccd..ba8e0465ef34721defca9355978dba5df7cc2691 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process FFS generation from FILE statement\r
 #\r
-#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -83,14 +83,14 @@ class FileStatement (FileStatementClassObject) :
         SectionAlignments = None\r
         if self.FvName is not None :\r
             Buffer = StringIO.StringIO('')\r
-            if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():\r
+            if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:\r
                 EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))\r
             Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())\r
             FileName = Fv.AddToBuffer(Buffer)\r
             SectionFiles = [FileName]\r
 \r
         elif self.FdName is not None:\r
-            if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
+            if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict:\r
                 EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName))\r
             Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())\r
             FileName = Fd.GenFd()\r
index 8f5a1bfd10294976e993815ae8354612f1a6d5a4..887619694df3ce00a6aeb6cca9625ec0af37d0e6 100644 (file)
@@ -613,7 +613,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                     # the file name FILE_GUIDmodule.inf, then PlatformDataBase.Modules use FILE_GUIDmodule.inf as key,\r
                     # but the path (self.MetaFile.Path) is the real path\r
                     #\r
-                    for key in PlatformDataBase.Modules.keys():\r
+                    for key in PlatformDataBase.Modules:\r
                         if InfFileKey == str((PlatformDataBase.Modules[key]).MetaFile.Path):\r
                             DscArchList.append (Arch)\r
                             break\r
index aae644bef9058d3a415b910584f236ca5705c41d..5228e155267f269cbb54acaf6347576873882f78 100644 (file)
@@ -70,7 +70,7 @@ class FV (FvClassObject):
     #\r
     def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :\r
 \r
-        if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys():\r
+        if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict:\r
             return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv']\r
         \r
         #\r
@@ -78,14 +78,13 @@ class FV (FvClassObject):
         # If yes, return error. Doesn't support FV in Capsule image is also in FD flash region.\r
         #\r
         if self.CapsuleName is not None:\r
-            for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
-                FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]\r
+            for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():\r
                 for RegionObj in FdObj.RegionList:\r
                     if RegionObj.RegionType == 'FV':\r
                         for RegionData in RegionObj.RegionDataList:\r
                             if RegionData.endswith(".fv"):\r
                                 continue\r
-                            elif RegionData.upper() + 'fv' in GenFds.ImageBinDict.keys():\r
+                            elif RegionData.upper() + 'fv' in GenFds.ImageBinDict:\r
                                 continue\r
                             elif self.UiFvName.upper() == RegionData.upper():\r
                                 GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))\r
@@ -235,8 +234,7 @@ class FV (FvClassObject):
         if self.BlockSizeList:\r
             return True\r
 \r
-        for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
-            FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]\r
+        for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():\r
             for RegionObj in FdObj.RegionList:\r
                 if RegionObj.RegionType != 'FV':\r
                     continue\r
@@ -441,7 +439,7 @@ class FV (FvClassObject):
         # Add [Files]\r
         #\r
         self.FvInfFile.writelines("[files]" + T_CHAR_LF)\r
-        if VtfDict is not None and self.UiFvName in VtfDict.keys():\r
+        if VtfDict is not None and self.UiFvName in VtfDict:\r
             self.FvInfFile.writelines("EFI_FILE_NAME = "                   + \\r
-                                       VtfDict.get(self.UiFvName)          + \\r
+                                       VtfDict[self.UiFvName]              + \\r
                                        T_CHAR_LF)\r
index c507b0148af0baccdd7e608e086a655d531d5310..54c7d828305f7c58a42378280e622daf9c47909f 100644 (file)
@@ -92,7 +92,7 @@ def main():
         else:\r
             Workspace = os.path.normcase(Options.Workspace)\r
             GenFdsGlobalVariable.WorkSpaceDir = Workspace\r
-            if 'EDK_SOURCE' in os.environ.keys():\r
+            if 'EDK_SOURCE' in os.environ:\r
                 GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE'])\r
             if (Options.debug):\r
                 GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace)\r
@@ -156,7 +156,7 @@ def main():
                 # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf\r
                 ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath)\r
         else:\r
-            if "CONF_PATH" in os.environ.keys():\r
+            if "CONF_PATH" in os.environ:\r
                 ConfDirectoryPath = os.path.normcase(os.environ["CONF_PATH"])\r
             else:\r
                 # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf\r
@@ -216,11 +216,11 @@ def main():
         os.environ["WORKSPACE"] = Workspace\r
 \r
         # Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGET if they are not defined\r
-        if "TARGET" not in GlobalData.gGlobalDefines.keys():\r
+        if "TARGET" not in GlobalData.gGlobalDefines:\r
             GlobalData.gGlobalDefines["TARGET"] = GenFdsGlobalVariable.TargetName\r
-        if "TOOLCHAIN" not in GlobalData.gGlobalDefines.keys():\r
+        if "TOOLCHAIN" not in GlobalData.gGlobalDefines:\r
             GlobalData.gGlobalDefines["TOOLCHAIN"] = GenFdsGlobalVariable.ToolChainTag\r
-        if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines.keys():\r
+        if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines:\r
             GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = GenFdsGlobalVariable.ToolChainTag\r
 \r
         """call Workspace build create database"""\r
@@ -278,21 +278,21 @@ def main():
             EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file")\r
 \r
         if (Options.uiFdName) :\r
-            if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict.keys():\r
+            if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict:\r
                 GenFds.OnlyGenerateThisFd = Options.uiFdName\r
             else:\r
                 EdkLogger.error("GenFds", OPTION_VALUE_INVALID,\r
                                 "No such an FD in FDF file: %s" % Options.uiFdName)\r
 \r
         if (Options.uiFvName) :\r
-            if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict.keys():\r
+            if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict:\r
                 GenFds.OnlyGenerateThisFv = Options.uiFvName\r
             else:\r
                 EdkLogger.error("GenFds", OPTION_VALUE_INVALID,\r
                                 "No such an FV in FDF file: %s" % Options.uiFvName)\r
 \r
         if (Options.uiCapName) :\r
-            if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict.keys():\r
+            if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict:\r
                 GenFds.OnlyGenerateThisCap = Options.uiCapName\r
             else:\r
                 EdkLogger.error("GenFds", OPTION_VALUE_INVALID,\r
@@ -388,7 +388,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
                 KeyStringList.append(Target + '_' + ToolChain + '_' + Arch)\r
 \r
     if GenFdsGlobalVariable.GuidToolDefinition:\r
-        if NameGuid in GenFdsGlobalVariable.GuidToolDefinition.keys():\r
+        if NameGuid in GenFdsGlobalVariable.GuidToolDefinition:\r
             return GenFdsGlobalVariable.GuidToolDefinition[NameGuid]\r
 \r
     ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary\r
@@ -450,10 +450,10 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
                     if Key in KeyStringList and KeyList[4] == 'GUID':\r
                         ToolPathKey   = Key + '_' + KeyList[3] + '_PATH'\r
                         ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'\r
-        if ToolPathKey in BuildOption.keys():\r
-            ToolPathTmp = BuildOption.get(ToolPathKey)\r
-        if ToolOptionKey in BuildOption.keys():\r
-            ToolOption = BuildOption.get(ToolOptionKey)\r
+        if ToolPathKey in BuildOption:\r
+            ToolPathTmp = BuildOption[ToolPathKey]\r
+        if ToolOptionKey in BuildOption:\r
+            ToolOption = BuildOption[ToolOptionKey]\r
 \r
     GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)\r
     return ToolPathTmp, ToolOption\r
@@ -522,63 +522,56 @@ class GenFds :
         GenFdsGlobalVariable.SetDir ('', FdfParser, WorkSpace, ArchList)\r
 \r
         GenFdsGlobalVariable.VerboseLogger(" Generate all Fd images and their required FV and Capsule images!")\r
-        if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():\r
-            CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.get(GenFds.OnlyGenerateThisCap.upper())\r
+        if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict:\r
+            CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[GenFds.OnlyGenerateThisCap.upper()]\r
             if CapsuleObj is not None:\r
                 CapsuleObj.GenCapsule()\r
                 return\r
 \r
-        if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
-            FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(GenFds.OnlyGenerateThisFd.upper())\r
+        if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:\r
+            FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()]\r
             if FdObj is not None:\r
                 FdObj.GenFd()\r
                 return\r
         elif GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisFv is None:\r
-            for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
-                FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]\r
+            for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():\r
                 FdObj.GenFd()\r
 \r
         GenFdsGlobalVariable.VerboseLogger("\n Generate other FV images! ")\r
-        if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():\r
-            FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(GenFds.OnlyGenerateThisFv.upper())\r
+        if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:\r
+            FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[GenFds.OnlyGenerateThisFv.upper()]\r
             if FvObj is not None:\r
                 Buffer = StringIO.StringIO()\r
                 FvObj.AddToBuffer(Buffer)\r
                 Buffer.close()\r
                 return\r
         elif GenFds.OnlyGenerateThisFv is None:\r
-            for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():\r
+            for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():\r
                 Buffer = StringIO.StringIO('')\r
-                FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]\r
                 FvObj.AddToBuffer(Buffer)\r
                 Buffer.close()\r
         \r
         if GenFds.OnlyGenerateThisFv is None and GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisCap is None:\r
             if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict != {}:\r
                 GenFdsGlobalVariable.VerboseLogger("\n Generate other Capsule images!")\r
-                for CapsuleName in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():\r
-                    CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[CapsuleName]\r
+                for CapsuleObj in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.values():\r
                     CapsuleObj.GenCapsule()\r
 \r
             if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}:\r
                 GenFdsGlobalVariable.VerboseLogger("\n Generate all Option ROM!")\r
-                for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys():\r
-                    OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]\r
+                for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.values():\r
                     OptRomObj.AddToBuffer(None)\r
     @staticmethod\r
     def GenFfsMakefile(OutputDir, FdfParser, WorkSpace, ArchList, GlobalData):\r
         GenFdsGlobalVariable.SetEnv(FdfParser, WorkSpace, ArchList, GlobalData)\r
-        for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
-            FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]\r
+        for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():\r
             FdObj.GenFd(Flag=True)\r
 \r
-        for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():\r
-            FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]\r
+        for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():\r
             FvObj.AddToBuffer(Buffer=None, Flag=True)\r
 \r
         if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}:\r
-            for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys():\r
-                OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]\r
+            for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.values():\r
                 OptRomObj.AddToBuffer(Buffer=None, Flag=True)\r
 \r
         return GenFdsGlobalVariable.FfsCmdDict\r
@@ -591,7 +584,7 @@ class GenFds :
     def GetFvBlockSize(FvObj):\r
         DefaultBlockSize = 0x1\r
         FdObj = None\r
-        if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
+        if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict:\r
             FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()]\r
         if FdObj is None:\r
             for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():\r
index 5e5dc4c948dcdb545d829af5845f317b09aea696..6a3873940ec01452a2bdcdb8181cb27efcccdeaf 100644 (file)
@@ -549,7 +549,7 @@ class GenFdsGlobalVariable:
 \r
         GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
         if MakefilePath:\r
-            if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict.keys():\r
+            if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict:\r
                 GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGlobalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] = MakefilePath\r
             GenFdsGlobalVariable.SecCmdList = []\r
             GenFdsGlobalVariable.CopyList = []\r
@@ -779,7 +779,7 @@ class GenFdsGlobalVariable:
         if MacroDict is not None  and len (MacroDict) != 0:\r
             Dict.update(MacroDict)\r
 \r
-        for key in Dict.keys():\r
+        for key in Dict:\r
             if Str.find(key) >= 0 :\r
                 Str = Str.replace (key, Dict[key])\r
 \r
index e639739b7e034e4ef31f057acade8524db18363d..44f122a712168b4153919f1164843a99aa150975 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process FD Region generation\r
 #\r
-#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -102,7 +102,7 @@ class Region(RegionClassObject):
                         EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData)\r
 \r
                     FileName = RegionData\r
-                elif RegionData.upper() + 'fv' in ImageBinDict.keys():\r
+                elif RegionData.upper() + 'fv' in ImageBinDict:\r
                     if not Flag:\r
                         GenFdsGlobalVariable.InfLogger('   Region Name = FV')\r
                     FileName = ImageBinDict[RegionData.upper() + 'fv']\r
@@ -111,8 +111,8 @@ class Region(RegionClassObject):
                     # Generate FvImage.\r
                     #\r
                     FvObj = None\r
-                    if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():\r
-                        FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(RegionData.upper())\r
+                    if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:\r
+                        FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[RegionData.upper()]\r
 \r
                     if FvObj is not None :\r
                         if not Flag:\r
@@ -182,7 +182,7 @@ class Region(RegionClassObject):
                         EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData)\r
 \r
                     FileName = RegionData\r
-                elif RegionData.upper() + 'cap' in ImageBinDict.keys():\r
+                elif RegionData.upper() + 'cap' in ImageBinDict:\r
                     GenFdsGlobalVariable.InfLogger('   Region Name = CAPSULE')\r
                     FileName = ImageBinDict[RegionData.upper() + 'cap']\r
                 else:\r
@@ -190,7 +190,7 @@ class Region(RegionClassObject):
                     # Generate Capsule image and Put it into FD buffer\r
                     #\r
                     CapsuleObj = None\r
-                    if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():\r
+                    if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict:\r
                         CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[RegionData.upper()]\r
 \r
                     if CapsuleObj is not None :\r
index 143b53ec35efb516647287608910a34de622c5c3..ecac316b7a3adb6451b8e42d5378bf4cd4995b7e 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Target Tool Parser\r
 #\r
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -65,7 +65,7 @@ class TargetTool():
                 LineList = Line.split(KeySplitCharacter,1)\r
                 if len(LineList) >= 2:\r
                     Key = LineList[0].strip()\r
-                    if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():\r
+                    if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary:\r
                         if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM or Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF \\r
                           or Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER \\r
                           or Key == TAB_TAT_DEFINES_ACTIVE_MODULE:\r
@@ -105,7 +105,7 @@ class TargetTool():
                     LineList = Line.split(KeySplitCharacter,1)\r
                     if len(LineList) >= 2:\r
                         Key = LineList[0].strip()\r
-                        if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():\r
+                        if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary:\r
                             if Key not in existKeys:\r
                                 existKeys.append(Key)\r
                             else:\r
@@ -118,7 +118,7 @@ class TargetTool():
                                 if ret is not None:\r
                                     Line = ret\r
                             fw.write(Line)\r
-            for key in self.TargetTxtDictionary.keys():\r
+            for key in self.TargetTxtDictionary:\r
                 if key not in existKeys:\r
                     print "Warning: %s does not exist in original configuration file" % key\r
                     Line = GetConfigureKeyValue(self, key)\r
index bf3da028c657eb08b6a5d61590497d4ea982d36b..a725a2a2a7720c089cb65d7e3ee87f2b8526ef9d 100644 (file)
@@ -788,10 +788,7 @@ class InfBuildData(ModuleBuildClassObject):
                 self._Includes.append(self._SourceOverridePath)\r
 \r
             Macros = self._Macros\r
-            if 'PROCESSOR' in GlobalData.gEdkGlobal.keys():\r
-                Macros['PROCESSOR'] = GlobalData.gEdkGlobal['PROCESSOR']\r
-            else:\r
-                Macros['PROCESSOR'] = self._Arch\r
+            Macros['PROCESSOR'] = GlobalData.gEdkGlobal.get('PROCESSOR', self._Arch)\r
             RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch, self._Platform]\r
             for Record in RecordList:\r
                 if Record[0].find('EDK_SOURCE') > -1:\r
index ae8cf57e389726561dd833e1893eacae1860d4f6..3d123147170932e5c220814b1d06c6bc553c84b7 100644 (file)
@@ -1504,12 +1504,12 @@ class DscParser(MetaFileParser):
             # Allow using system environment variables  in path after !include\r
             #\r
             __IncludeMacros['WORKSPACE'] = GlobalData.gGlobalDefines['WORKSPACE']\r
-            if "ECP_SOURCE" in GlobalData.gGlobalDefines.keys():\r
+            if "ECP_SOURCE" in GlobalData.gGlobalDefines:\r
                 __IncludeMacros['ECP_SOURCE'] = GlobalData.gGlobalDefines['ECP_SOURCE']\r
             #\r
             # During GenFds phase call DSC parser, will go into this branch.\r
             #\r
-            elif "ECP_SOURCE" in GlobalData.gCommandLineDefines.keys():\r
+            elif "ECP_SOURCE" in GlobalData.gCommandLineDefines:\r
                 __IncludeMacros['ECP_SOURCE'] = GlobalData.gCommandLineDefines['ECP_SOURCE']\r
 \r
             __IncludeMacros['EFI_SOURCE'] = GlobalData.gGlobalDefines['EFI_SOURCE']\r
index 17ac3b10543177669da4dc5505deb269e317e78e..736ef62534533ae2837e0f361bef9980978799de 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Common routines used by workspace\r
 #\r
-# Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -63,11 +63,11 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain,additionalPk
             PcdCName = Pcd[0]\r
             PcdTokenName = Pcd[1]\r
             if GlobalData.MixedPcd:\r
-                for PcdItem in GlobalData.MixedPcd.keys():\r
+                for PcdItem in GlobalData.MixedPcd:\r
                     if (PcdCName, PcdTokenName) in GlobalData.MixedPcd[PcdItem]:\r
                         PcdCName = PcdItem[0]\r
                         break\r
-            if (PcdCName, PcdTokenName) not in DecPcds.keys():\r
+            if (PcdCName, PcdTokenName) not in DecPcds:\r
                 DecPcds[PcdCName, PcdTokenName] = Pkg.Pcds[Pcd]\r
     return DecPcds, GuidDict\r
 \r
@@ -243,7 +243,7 @@ def _ResolveLibraryReference(Module, Platform):
         for LibraryName in M.Libraries:\r
             Library = Platform.LibraryClasses[LibraryName, ':dummy:']\r
             if Library is None:\r
-                for Key in Platform.LibraryClasses.data.keys():\r
+                for Key in Platform.LibraryClasses.data:\r
                     if LibraryName.upper() == Key.upper():\r
                         Library = Platform.LibraryClasses[Key, ':dummy:']\r
                         break\r
index f333279a5875a8cbb8f638212f4855502fcb2d72..635c311f1a4820036bb2aebfab46f25fcdb99bd1 100644 (file)
@@ -838,7 +838,7 @@ class PcdReport(object):
                 for PcdItem in GlobalData.gConditionalPcds:\r
                     if '.' in PcdItem:\r
                         (TokenSpaceGuidCName, TokenCName) = PcdItem.split('.')\r
-                        if (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds.keys():\r
+                        if (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds:\r
                             Pcd = Pa.Platform.Pcds[(TokenCName, TokenSpaceGuidCName)]\r
                             PcdList = self.ConditionalPcds.setdefault(Pcd.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, [])\r
                             if Pcd not in PcdList:\r
@@ -1043,7 +1043,7 @@ class PcdReport(object):
                             DscMatch = (DscDefaultValue.strip() == PcdValue.strip())\r
 \r
                     IsStructure = False\r
-                    if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd.keys()) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]):\r
+                    if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]):\r
                         IsStructure = True\r
                         if TypeName in ('DYNVPD', 'DEXVPD'):\r
                             SkuInfoList = Pcd.SkuInfoList\r
index ede963bc231ae7105d865f23b22f2dcfa0595ce5..36bb1fecf7e570143d11e0ac9f9c6568e13ba9b3 100644 (file)
@@ -53,7 +53,7 @@ import Common.EdkLogger
 import Common.GlobalData as GlobalData\r
 from GenFds.GenFds import GenFds\r
 \r
-from collections import OrderedDict\r
+from collections import OrderedDict,defaultdict\r
 \r
 # Version and Copyright\r
 VersionNumber = "0.60" + ' ' + gBUILD_VERSION\r
@@ -524,8 +524,7 @@ class BuildTask:
                     BuildTask._Thread.acquire(True)\r
 \r
                     # start a new build thread\r
-                    Bo = BuildTask._ReadyQueue.keys()[0]\r
-                    Bt = BuildTask._ReadyQueue.pop(Bo)\r
+                    Bo,Bt = BuildTask._ReadyQueue.popitem()\r
 \r
                     # move into running queue\r
                     BuildTask._RunningQueueLock.acquire()\r
@@ -1000,7 +999,7 @@ class Build():
             GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = self.ToolChainList[0]\r
         if self.ToolChainFamily:\r
             GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[0]\r
-        if 'PREBUILD' in GlobalData.gCommandLineDefines.keys():\r
+        if 'PREBUILD' in GlobalData.gCommandLineDefines:\r
             self.Prebuild   = GlobalData.gCommandLineDefines.get('PREBUILD')\r
         else:\r
             self.Db.InitDatabase()\r
@@ -1041,7 +1040,7 @@ class Build():
             self.Prebuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList, self.PlatformFile, self.Target)\r
 \r
     def InitPostBuild(self):\r
-        if 'POSTBUILD' in GlobalData.gCommandLineDefines.keys():\r
+        if 'POSTBUILD' in GlobalData.gCommandLineDefines:\r
             self.Postbuild = GlobalData.gCommandLineDefines.get('POSTBUILD')\r
         else:\r
             Platform = self.Db._MapPlatform(str(self.PlatformFile))\r
@@ -1524,7 +1523,7 @@ class Build():
             # First get the XIP base address for FV map file.\r
             GuidPattern = re.compile("[-a-fA-F0-9]+")\r
             GuidName = re.compile("\(GUID=[-a-fA-F0-9]+")\r
-            for FvName in Wa.FdfProfile.FvDict.keys():\r
+            for FvName in Wa.FdfProfile.FvDict:\r
                 FvMapBuffer = os.path.join(Wa.FvDir, FvName + '.Fv.map')\r
                 if not os.path.exists(FvMapBuffer):\r
                     continue\r
@@ -1961,15 +1960,14 @@ class Build():
                     self._SaveMapFile (MapBuffer, Wa)\r
 \r
     def _GenFfsCmd(self):\r
-        CmdListDict = {}\r
+        # convert dictionary of Cmd:(Inf,Arch) \r
+        # to a new dictionary of (Inf,Arch):Cmd,Cmd,Cmd...\r
+        CmdSetDict = defaultdict(set)\r
         GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData)\r
         for Cmd in GenFfsDict:\r
             tmpInf, tmpArch = GenFfsDict[Cmd]\r
-            if (tmpInf, tmpArch) not in CmdListDict.keys():\r
-                CmdListDict[tmpInf, tmpArch] = [Cmd]\r
-            else:\r
-                CmdListDict[tmpInf, tmpArch].append(Cmd)\r
-        return CmdListDict\r
+            CmdSetDict[tmpInf, tmpArch].add(Cmd)\r
+        return CmdSetDict\r
 \r
     ## Build a platform in multi-thread mode\r
     #\r