]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/InfSectionParser.py
BaseTools: AutoGen - use dafultdict instead of dict
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / InfSectionParser.py
index 7f782365480e7d1e4d5bada4adc805ed3833113f..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
@@ -62,6 +62,24 @@ class InfSectionParser():
                 SectionData = []\r
                 SectionLine = ''\r
     \r
+    # Get user extension TianoCore data\r
+    #\r
+    # @return: a list include some dictionary that key is section and value is a list contain all data.\r
+    def GetUserExtensionTianoCore(self):\r
+        UserExtensionTianoCore = []\r
+        if not self._FileSectionDataList:\r
+            return UserExtensionTianoCore\r
+        for SectionDataDict in self._FileSectionDataList:\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
+                    if str(SectionLine).find(TAB_COMMA_SPLIT) > -1:\r
+                        SubSectionList = str(SectionLine).split(TAB_COMMA_SPLIT)\r
+                    for SubSection in SubSectionList:\r
+                        if SubSection.lower().find('.tianocore.') > -1:\r
+                            UserExtensionTianoCore.append({SubSection: SectionDataDict[key]})\r
+        return UserExtensionTianoCore\r
 \r
     # Get depex expresion\r
     #\r
@@ -71,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