]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/InfSectionParser.py
BaseTools: remove including Base.h if the module type is not BASE
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / InfSectionParser.py
index cdc9e5e8a849808b6bbc8677c1a69fefc5b23be8..2cd5a6667a0259e60a787df6bf29d32779735489 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
@@ -26,7 +26,6 @@ class InfSectionParser():
         self._ParserInf()\r
     \r
     def _ParserInf(self):\r
-        Filename = self._FilePath\r
         FileLinesList = []\r
         UserExtFind = False\r
         FindEnd = True\r
@@ -35,9 +34,9 @@ class InfSectionParser():
         SectionData = []\r
         \r
         try:\r
-            FileLinesList = open(Filename, "r", 0).readlines()\r
+            FileLinesList = open(self._FilePath, "r", 0).readlines()\r
         except BaseException:\r
-            EdkLogger.error("build", AUTOGEN_ERROR, 'File %s is opened failed.' % Filename)\r
+            EdkLogger.error("build", AUTOGEN_ERROR, 'File %s is opened failed.' % self._FilePath)\r
         \r
         for Index in range(0, len(FileLinesList)):\r
             line = str(FileLinesList[Index]).strip()\r
@@ -49,7 +48,7 @@ class InfSectionParser():
             if UserExtFind and FindEnd == False:\r
                 if line:\r
                     SectionData.append(line)\r
-            if line.lower().startswith(TAB_SECTION_START) and line.lower().endswith(TAB_SECTION_END):\r
+            if line.startswith(TAB_SECTION_START) and line.endswith(TAB_SECTION_END):\r
                 SectionLine = line\r
                 UserExtFind = True\r
                 FindEnd = False\r
@@ -59,7 +58,7 @@ class InfSectionParser():
                 UserExtFind = False\r
                 FindEnd = True\r
                 self._FileSectionDataList.append({SectionLine: SectionData[:]})\r
-                SectionData = []\r
+                del SectionData[:]\r
                 SectionLine = ''\r
     \r
     # Get user extension TianoCore data\r
@@ -70,7 +69,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 +88,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