]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/InfSectionParser.py
BaseTool: Add cache for the result of SkipAutogen.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / InfSectionParser.py
index cf4e76159e81daafaf0c59a18499f3f4840a03ef..d98508973841ed61ec9562151dd3cc3d2d5983d7 100644 (file)
 import Common.EdkLogger as EdkLogger\r
 from Common.BuildToolError import *\r
 from Common.DataType import *\r
\r
+\r
 \r
 class InfSectionParser():\r
     def __init__(self, FilePath):\r
         self._FilePath = FilePath\r
         self._FileSectionDataList = []\r
         self._ParserInf()\r
-    \r
+\r
     def _ParserInf(self):\r
-        Filename = self._FilePath\r
         FileLinesList = []\r
         UserExtFind = False\r
         FindEnd = True\r
         FileLastLine = False\r
         SectionLine = ''\r
         SectionData = []\r
-        \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
-        \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
             if Index + 1 == len(FileLinesList):\r
@@ -49,19 +48,19 @@ 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
-            \r
+\r
             if (NextLine != '' and NextLine[0] == TAB_SECTION_START and \\r
                 NextLine[-1] == TAB_SECTION_END) or FileLastLine:\r
                 UserExtFind = False\r
                 FindEnd = True\r
                 self._FileSectionDataList.append({SectionLine: SectionData[:]})\r
-                SectionData = []\r
+                del SectionData[:]\r
                 SectionLine = ''\r
-    \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