]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Parser/InfParser.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Parser / InfParser.py
index 7bea49e0e8616d68d9950aa726da868e28362937..2072be6e42f968266752f5832394a7757be7cf3f 100644 (file)
@@ -1,15 +1,9 @@
 ## @file\r
 # This file contained the parser for INF file\r
 #\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
-# This program and the accompanying materials are licensed and made available \r
-# under the terms and conditions of the BSD License which accompanies this \r
-# distribution. The full text of the license may be found at \r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 \r
 '''\r
@@ -23,8 +17,8 @@ import re
 import os\r
 from copy import deepcopy\r
 \r
-from Library.String import GetSplitValueList\r
-from Library.String import ConvertSpecialChar\r
+from Library.StringUtils import GetSplitValueList\r
+from Library.StringUtils import ConvertSpecialChar\r
 from Library.Misc import ProcessLineExtender\r
 from Library.Misc import ProcessEdkComment\r
 from Library.Parsing import NormPath\r
@@ -49,24 +43,24 @@ from Parser.InfParserMisc import IsBinaryInf
 #\r
 def OpenInfFile(Filename):\r
     FileLinesList = []\r
-    \r
+\r
     try:\r
-        FInputfile = open(Filename, "rb", 0)\r
+        FInputfile = open(Filename, "r")\r
         try:\r
             FileLinesList = FInputfile.readlines()\r
         except BaseException:\r
-            Logger.Error("InfParser", \r
-                         FILE_READ_FAILURE, \r
+            Logger.Error("InfParser",\r
+                         FILE_READ_FAILURE,\r
                          ST.ERR_FILE_OPEN_FAILURE,\r
                          File=Filename)\r
         finally:\r
             FInputfile.close()\r
     except BaseException:\r
-        Logger.Error("InfParser", \r
-                     FILE_READ_FAILURE, \r
+        Logger.Error("InfParser",\r
+                     FILE_READ_FAILURE,\r
                      ST.ERR_FILE_OPEN_FAILURE,\r
                      File=Filename)\r
-        \r
+\r
     return FileLinesList\r
 \r
 ## InfParser\r
@@ -74,20 +68,20 @@ def OpenInfFile(Filename):
 # This class defined the structure used in InfParser object\r
 #\r
 # @param InfObject:         Inherited from InfSectionParser class\r
-# @param Filename:          Input value for Filename of INF file, default is \r
+# @param Filename:          Input value for Filename of INF file, default is\r
 #                           None\r
-# @param WorkspaceDir:      Input value for current workspace directory, \r
+# @param WorkspaceDir:      Input value for current workspace directory,\r
 #                           default is None\r
 #\r
 class InfParser(InfSectionParser):\r
 \r
     def __init__(self, Filename = None, WorkspaceDir = None):\r
-        \r
+\r
         #\r
         # Call parent class construct function\r
         #\r
-        super(InfParser, self).__init__()\r
-        \r
+        InfSectionParser.__init__()\r
+\r
         self.WorkspaceDir    = WorkspaceDir\r
         self.SupArchList     = DT.ARCH_LIST\r
         self.EventList    = []\r
@@ -107,7 +101,7 @@ class InfParser(InfSectionParser):
     # @param Filename:  Input value for filename of INF file\r
     #\r
     def ParseInfFile(self, Filename):\r
-        \r
+\r
         Filename = NormPath(Filename)\r
         (Path, Name) = os.path.split(Filename)\r
         self.FullPath = Filename\r
@@ -120,30 +114,30 @@ class InfParser(InfSectionParser):
         # Initialize common data\r
         #\r
         LineNo             = 0\r
-        CurrentSection     = DT.MODEL_UNKNOWN \r
+        CurrentSection     = DT.MODEL_UNKNOWN\r
         SectionLines       = []\r
-        \r
+\r
         #\r
         # Flags\r
         #\r
-        HeaderCommentStart = False \r
+        HeaderCommentStart = False\r
         HeaderCommentEnd   = False\r
         HeaderStarLineNo = -1\r
-        BinaryHeaderCommentStart = False \r
+        BinaryHeaderCommentStart = False\r
         BinaryHeaderCommentEnd   = False\r
         BinaryHeaderStarLineNo = -1\r
-        \r
+\r
         #\r
         # While Section ends. parse whole section contents.\r
         #\r
         NewSectionStartFlag = False\r
         FirstSectionStartFlag = False\r
-        \r
+\r
         #\r
         # Parse file content\r
         #\r
         CommentBlock       = []\r
\r
+\r
         #\r
         # Variables for Event/Hob/BootMode\r
         #\r
@@ -151,44 +145,44 @@ class InfParser(InfSectionParser):
         self.HobList      = []\r
         self.BootModeList = []\r
         SectionType = ''\r
-        \r
+\r
         FileLinesList = OpenInfFile (Filename)\r
-        \r
+\r
         #\r
         # One INF file can only has one [Defines] section.\r
         #\r
         DefineSectionParsedFlag = False\r
-        \r
+\r
         #\r
         # Convert special characters in lines to space character.\r
         #\r
         FileLinesList = ConvertSpecialChar(FileLinesList)\r
-        \r
+\r
         #\r
         # Process Line Extender\r
         #\r
         FileLinesList = ProcessLineExtender(FileLinesList)\r
-        \r
+\r
         #\r
         # Process EdkI INF style comment if found\r
         #\r
         OrigLines = [Line for Line in FileLinesList]\r
         FileLinesList, EdkCommentStartPos = ProcessEdkComment(FileLinesList)\r
-        \r
+\r
         #\r
         # Judge whether the INF file is Binary INF or not\r
         #\r
         if IsBinaryInf(FileLinesList):\r
             GlobalData.gIS_BINARY_INF = True\r
-            \r
+\r
         InfSectionCommonDefObj = None\r
-        \r
+\r
         for Line in FileLinesList:\r
             LineNo   = LineNo + 1\r
             Line     = Line.strip()\r
             if (LineNo < len(FileLinesList) - 1):\r
                 NextLine = FileLinesList[LineNo].strip()\r
-            \r
+\r
             #\r
             # blank line\r
             #\r
@@ -209,7 +203,7 @@ class InfParser(InfSectionParser):
                 HeaderStarLineNo = LineNo\r
                 SectionLines.append((Line, LineNo))\r
                 HeaderCommentStart = True\r
-                continue        \r
+                continue\r
 \r
             #\r
             # Collect Header content.\r
@@ -225,11 +219,11 @@ class InfParser(InfSectionParser):
             if (Line.startswith(DT.TAB_SPECIAL_COMMENT) or not Line.strip().startswith("#")) and HeaderCommentStart \\r
                 and not HeaderCommentEnd:\r
                 HeaderCommentEnd = True\r
-                BinaryHeaderCommentStart = False \r
+                BinaryHeaderCommentStart = False\r
                 BinaryHeaderCommentEnd   = False\r
-                HeaderCommentStart = False      \r
+                HeaderCommentStart = False\r
                 if Line.find(DT.TAB_BINARY_HEADER_COMMENT) > -1:\r
-                    self.InfHeaderParser(SectionLines, self.InfHeader, self.FileName) \r
+                    self.InfHeaderParser(SectionLines, self.InfHeader, self.FileName)\r
                     SectionLines = []\r
                 else:\r
                     SectionLines.append((Line, LineNo))\r
@@ -255,8 +249,8 @@ class InfParser(InfSectionParser):
                 SectionLines.append((Line, LineNo))\r
                 BinaryHeaderCommentStart = True\r
                 HeaderCommentEnd = True\r
-                continue   \r
-            \r
+                continue\r
+\r
             #\r
             # check whether there are more than one binary header exist\r
             #\r
@@ -266,7 +260,7 @@ class InfParser(InfSectionParser):
                              FORMAT_INVALID,\r
                              ST.ERR_MULTIPLE_BINARYHEADER_EXIST,\r
                              File=Filename)\r
-            \r
+\r
             #\r
             # Collect Binary Header content.\r
             #\r
@@ -287,17 +281,17 @@ class InfParser(InfSectionParser):
                 #\r
                 self.InfHeaderParser(SectionLines, self.InfBinaryHeader, self.FileName, True)\r
                 SectionLines = []\r
-                BinaryHeaderCommentEnd   = True               \r
-                continue                   \r
+                BinaryHeaderCommentEnd   = True\r
+                continue\r
             #\r
             # Find a new section tab\r
-            # Or at the last line of INF file, \r
+            # Or at the last line of INF file,\r
             # need to process the last section.\r
             #\r
             LastSectionFalg = False\r
             if LineNo == len(FileLinesList):\r
                 LastSectionFalg = True\r
-                             \r
+\r
             if Line.startswith(DT.TAB_COMMENT_SPLIT) and not Line.startswith(DT.TAB_SPECIAL_COMMENT):\r
                 SectionLines.append((Line, LineNo))\r
                 if not LastSectionFalg:\r
@@ -307,23 +301,23 @@ class InfParser(InfSectionParser):
             # Encountered a section. start with '[' and end with ']'\r
             #\r
             if (Line.startswith(DT.TAB_SECTION_START) and \\r
-               Line.find(DT.TAB_SECTION_END) > -1) or LastSectionFalg:   \r
-                \r
-                HeaderCommentEnd = True        \r
-                BinaryHeaderCommentEnd = True       \r
-                \r
+               Line.find(DT.TAB_SECTION_END) > -1) or LastSectionFalg:\r
+\r
+                HeaderCommentEnd = True\r
+                BinaryHeaderCommentEnd = True\r
+\r
                 if not LastSectionFalg:\r
                     #\r
                     # check to prevent '#' inside section header\r
                     #\r
                     HeaderContent = Line[1:Line.find(DT.TAB_SECTION_END)]\r
                     if HeaderContent.find(DT.TAB_COMMENT_SPLIT) != -1:\r
-                        Logger.Error("InfParser", \r
+                        Logger.Error("InfParser",\r
                                      FORMAT_INVALID,\r
                                      ST.ERR_INF_PARSER_DEFINE_SECTION_HEADER_INVALID,\r
                                      File=self.FullPath,\r
-                                     Line=LineNo, \r
-                                     ExtraData=Line)                        \r
+                                     Line=LineNo,\r
+                                     ExtraData=Line)\r
 \r
                     #\r
                     # Keep last time section header content for section parser\r
@@ -339,7 +333,7 @@ class InfParser(InfSectionParser):
                     if  CommentIndex > -1:\r
                         TailComments = Line[CommentIndex:]\r
                         Line = Line[:CommentIndex]\r
-                    \r
+\r
                     InfSectionCommonDefObj = InfSectionCommonDef()\r
                     if TailComments != '':\r
                         InfSectionCommonDefObj.SetTailComments(TailComments)\r
@@ -350,8 +344,8 @@ class InfParser(InfSectionParser):
                     # Call section parser before section header parer to avoid encounter EDKI INF file\r
                     #\r
                     if CurrentSection == DT.MODEL_META_DATA_DEFINE:\r
-                        DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection, \r
-                                                                   DefineSectionParsedFlag, SectionLines, \r
+                        DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection,\r
+                                                                   DefineSectionParsedFlag, SectionLines,\r
                                                                    InfSectionCommonDefObj, LineNo)\r
                     #\r
                     # Compare the new section name with current\r
@@ -377,52 +371,52 @@ class InfParser(InfSectionParser):
             #\r
             # End of section content collect.\r
             # Parser the section content collected previously.\r
-            #  \r
+            #\r
             if NewSectionStartFlag or LastSectionFalg:\r
                 if CurrentSection != DT.MODEL_META_DATA_DEFINE or \\r
-                    (LastSectionFalg and CurrentSection == DT.MODEL_META_DATA_DEFINE):     \r
-                    DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection, \r
-                                                                       DefineSectionParsedFlag, SectionLines, \r
+                    (LastSectionFalg and CurrentSection == DT.MODEL_META_DATA_DEFINE):\r
+                    DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection,\r
+                                                                       DefineSectionParsedFlag, SectionLines,\r
                                                                        InfSectionCommonDefObj, LineNo)\r
-                \r
+\r
                 CurrentSection = SectionType\r
                 #\r
                 # Clear section lines\r
                 #\r
-                SectionLines = []                                             \r
-        \r
+                SectionLines = []\r
+\r
         if HeaderStarLineNo == -1:\r
-            Logger.Error("InfParser", \r
+            Logger.Error("InfParser",\r
                         FORMAT_INVALID,\r
                         ST.ERR_NO_SOURCE_HEADER,\r
-                        File=self.FullPath) \r
+                        File=self.FullPath)\r
         if BinaryHeaderStarLineNo > -1 and HeaderStarLineNo > -1  and HeaderStarLineNo > BinaryHeaderStarLineNo:\r
-            Logger.Error("InfParser", \r
+            Logger.Error("InfParser",\r
                         FORMAT_INVALID,\r
                         ST.ERR_BINARY_HEADER_ORDER,\r
-                        File=self.FullPath)         \r
+                        File=self.FullPath)\r
         #\r
         # EDKII INF should not have EDKI style comment\r
         #\r
         if EdkCommentStartPos != -1:\r
-            Logger.Error("InfParser", \r
-                         FORMAT_INVALID, \r
-                         ST.ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII, \r
+            Logger.Error("InfParser",\r
+                         FORMAT_INVALID,\r
+                         ST.ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII,\r
                          File=self.FullPath,\r
                          Line=EdkCommentStartPos + 1,\r
                          ExtraData=OrigLines[EdkCommentStartPos])\r
-        \r
+\r
+        #\r
+        # extract [Event] [Hob] [BootMode] sections\r
         #\r
-        # extract [Event] [Hob] [BootMode] sections \r
-        #            \r
         self._ExtractEventHobBootMod(FileLinesList)\r
-    \r
+\r
     ## _CheckSectionHeaders\r
     #\r
     #\r
     def _CheckSectionHeaders(self, Line, LineNo):\r
         if len(self.SectionHeaderContent) == 0:\r
-            Logger.Error("InfParser", \r
+            Logger.Error("InfParser",\r
                          FORMAT_INVALID,\r
                          ST.ERR_INF_PARSER_DEFINE_SECTION_HEADER_INVALID,\r
                          File=self.FullPath,\r
@@ -431,7 +425,7 @@ class InfParser(InfSectionParser):
             for SectionItem in self.SectionHeaderContent:\r
                 ArchList = []\r
                 #\r
-                # Not cover Depex/UserExtension section header \r
+                # Not cover Depex/UserExtension section header\r
                 # check.\r
                 #\r
                 if SectionItem[0].strip().upper() == DT.TAB_INF_FIXED_PCD.upper() or \\r
@@ -442,15 +436,15 @@ class InfParser(InfSectionParser):
                     ArchList = GetSplitValueList(SectionItem[1].strip(), ' ')\r
                 else:\r
                     ArchList = [SectionItem[1].strip()]\r
-                    \r
+\r
                 for Arch in ArchList:\r
                     if (not IsValidArch(Arch)) and \\r
                         (SectionItem[0].strip().upper() != DT.TAB_DEPEX.upper()) and \\r
                         (SectionItem[0].strip().upper() != DT.TAB_USER_EXTENSIONS.upper()) and \\r
                         (SectionItem[0].strip().upper() != DT.TAB_COMMON_DEFINES.upper()):\r
-                        Logger.Error("InfParser", \r
+                        Logger.Error("InfParser",\r
                                      FORMAT_INVALID,\r
-                                     ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[1]), \r
+                                     ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[1]),\r
                                      File=self.FullPath,\r
                                      Line=LineNo, ExtraData=Line)\r
                 #\r
@@ -467,11 +461,11 @@ class InfParser(InfSectionParser):
                                          ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[2]),\r
                                          File=self.FullPath, Line=LineNo,\r
                                          ExtraData=Line)\r
-                              \r
+\r
     ## _CallSectionParsers\r
     #\r
     #\r
-    def _CallSectionParsers(self, CurrentSection, DefineSectionParsedFlag, \r
+    def _CallSectionParsers(self, CurrentSection, DefineSectionParsedFlag,\r
                             SectionLines, InfSectionCommonDefObj, LineNo):\r
         if CurrentSection == DT.MODEL_META_DATA_DEFINE:\r
             if not DefineSectionParsedFlag:\r
@@ -481,22 +475,22 @@ class InfParser(InfSectionParser):
                                      InfSectionCommonDefObj)\r
                 DefineSectionParsedFlag = True\r
             else:\r
-                Logger.Error("Parser", \r
-                             PARSER_ERROR, \r
-                             ST.ERR_INF_PARSER_MULTI_DEFINE_SECTION, \r
-                             File=self.FullPath, \r
+                Logger.Error("Parser",\r
+                             PARSER_ERROR,\r
+                             ST.ERR_INF_PARSER_MULTI_DEFINE_SECTION,\r
+                             File=self.FullPath,\r
                              RaiseError = Logger.IS_RAISE_ERROR)\r
-            \r
+\r
         elif CurrentSection == DT.MODEL_META_DATA_BUILD_OPTION:\r
             self.InfBuildOptionParser(SectionLines,\r
                                       self.InfBuildOptionSection,\r
                                       self.FullPath)\r
-            \r
+\r
         elif CurrentSection == DT.MODEL_EFI_LIBRARY_CLASS:\r
             self.InfLibraryParser(SectionLines,\r
                                   self.InfLibraryClassSection,\r
                                   self.FullPath)\r
-            \r
+\r
         elif CurrentSection == DT.MODEL_META_DATA_PACKAGE:\r
             self.InfPackageParser(SectionLines,\r
                                   self.InfPackageSection,\r
@@ -512,37 +506,37 @@ class InfParser(InfSectionParser):
             self.InfPcdParser(SectionLines,\r
                               self.InfPcdSection,\r
                               self.FullPath)\r
-            \r
+\r
         elif CurrentSection == DT.MODEL_EFI_SOURCE_FILE:\r
             self.InfSourceParser(SectionLines,\r
                                  self.InfSourcesSection,\r
                                  self.FullPath)\r
-            \r
+\r
         elif CurrentSection == DT.MODEL_META_DATA_USER_EXTENSION:\r
             self.InfUserExtensionParser(SectionLines,\r
                                         self.InfUserExtensionSection,\r
                                         self.FullPath)\r
-            \r
+\r
         elif CurrentSection == DT.MODEL_EFI_PROTOCOL:\r
             self.InfProtocolParser(SectionLines,\r
                                    self.InfProtocolSection,\r
                                    self.FullPath)\r
-            \r
+\r
         elif CurrentSection == DT.MODEL_EFI_PPI:\r
             self.InfPpiParser(SectionLines,\r
                               self.InfPpiSection,\r
                               self.FullPath)\r
-            \r
+\r
         elif CurrentSection == DT.MODEL_EFI_GUID:\r
             self.InfGuidParser(SectionLines,\r
                                self.InfGuidSection,\r
                                self.FullPath)\r
-            \r
+\r
         elif CurrentSection == DT.MODEL_EFI_DEPEX:\r
             self.InfDepexParser(SectionLines,\r
                                 self.InfDepexSection,\r
                                 self.FullPath)\r
-            \r
+\r
         elif CurrentSection == DT.MODEL_EFI_BINARY_FILE:\r
             self.InfBinaryParser(SectionLines,\r
                                  self.InfBinariesSection,\r
@@ -552,20 +546,20 @@ class InfParser(InfSectionParser):
         #\r
         else:\r
             if len(self.SectionHeaderContent) >= 1:\r
-                Logger.Error("Parser", \r
-                             PARSER_ERROR, \r
-                             ST.ERR_INF_PARSER_UNKNOWN_SECTION, \r
-                             File=self.FullPath, Line=LineNo, \r
+                Logger.Error("Parser",\r
+                             PARSER_ERROR,\r
+                             ST.ERR_INF_PARSER_UNKNOWN_SECTION,\r
+                             File=self.FullPath, Line=LineNo,\r
                              RaiseError = Logger.IS_RAISE_ERROR)\r
             else:\r
-                Logger.Error("Parser", \r
-                             PARSER_ERROR, \r
-                             ST.ERR_INF_PARSER_NO_SECTION_ERROR, \r
-                             File=self.FullPath, Line=LineNo, \r
+                Logger.Error("Parser",\r
+                             PARSER_ERROR,\r
+                             ST.ERR_INF_PARSER_NO_SECTION_ERROR,\r
+                             File=self.FullPath, Line=LineNo,\r
                              RaiseError = Logger.IS_RAISE_ERROR)\r
-                \r
-        return DefineSectionParsedFlag   \r
-        \r
+\r
+        return DefineSectionParsedFlag\r
+\r
     def _ExtractEventHobBootMod(self, FileLinesList):\r
         SpecialSectionStart = False\r
         CheckLocation = False\r
@@ -607,43 +601,43 @@ class InfParser(InfSectionParser):
                     elif not Line:\r
                         SpecialSectionStart = False\r
                         CheckLocation = True\r
-                        Element = []                        \r
+                        Element = []\r
                     else:\r
                         if not Line.startswith(DT.TAB_COMMENT_SPLIT):\r
-                            Logger.Warn("Parser", \r
-                                         ST.WARN_SPECIAL_SECTION_LOCATION_WRONG, \r
+                            Logger.Warn("Parser",\r
+                                         ST.WARN_SPECIAL_SECTION_LOCATION_WRONG,\r
                                          File=self.FullPath, Line=LineNum)\r
                             SpecialSectionStart = False\r
                             CheckLocation = False\r
                             Element = []\r
                         else:\r
-                            Element.append([Line, LineNum]) \r
+                            Element.append([Line, LineNum])\r
                 else:\r
                     if CheckLocation:\r
                         if MatchObject:\r
                             CheckLocation = False\r
                         elif Line:\r
-                            Logger.Warn("Parser", \r
-                                         ST.WARN_SPECIAL_SECTION_LOCATION_WRONG, \r
-                                         File=self.FullPath, Line=LineNum)    \r
+                            Logger.Warn("Parser",\r
+                                         ST.WARN_SPECIAL_SECTION_LOCATION_WRONG,\r
+                                         File=self.FullPath, Line=LineNum)\r
                             CheckLocation = False\r
-                    \r
+\r
         if len(self.BootModeList) >= 1:\r
-            self.InfSpecialCommentParser(self.BootModeList, \r
-                                         self.InfSpecialCommentSection, \r
-                                         self.FileName, \r
+            self.InfSpecialCommentParser(self.BootModeList,\r
+                                         self.InfSpecialCommentSection,\r
+                                         self.FileName,\r
                                          DT.TYPE_BOOTMODE_SECTION)\r
-        \r
+\r
         if len(self.EventList) >= 1:\r
-            self.InfSpecialCommentParser(self.EventList, \r
+            self.InfSpecialCommentParser(self.EventList,\r
                                          self.InfSpecialCommentSection,\r
-                                         self.FileName, \r
+                                         self.FileName,\r
                                          DT.TYPE_EVENT_SECTION)\r
-            \r
+\r
         if len(self.HobList) >= 1:\r
-            self.InfSpecialCommentParser(self.HobList, \r
-                                         self.InfSpecialCommentSection, \r
-                                         self.FileName, \r
+            self.InfSpecialCommentParser(self.HobList,\r
+                                         self.InfSpecialCommentSection,\r
+                                         self.FileName,\r
                                          DT.TYPE_HOB_SECTION)\r
     ## _ProcessLastSection\r
     #\r
@@ -652,35 +646,35 @@ class InfParser(InfSectionParser):
         #\r
         # The last line is a section header. will discard it.\r
         #\r
-        if not (Line.startswith(DT.TAB_SECTION_START) and Line.find(DT.TAB_SECTION_END) > -1):                      \r
+        if not (Line.startswith(DT.TAB_SECTION_START) and Line.find(DT.TAB_SECTION_END) > -1):\r
             SectionLines.append((Line, LineNo))\r
-            \r
+\r
         if len(self.SectionHeaderContent) >= 1:\r
             TemSectionName = self.SectionHeaderContent[0][0].upper()\r
             if TemSectionName.upper() not in gINF_SECTION_DEF.keys():\r
-                Logger.Error("InfParser", \r
-                             FORMAT_INVALID, \r
-                             ST.ERR_INF_PARSER_UNKNOWN_SECTION, \r
-                             File=self.FullPath, \r
-                             Line=LineNo, \r
+                Logger.Error("InfParser",\r
+                             FORMAT_INVALID,\r
+                             ST.ERR_INF_PARSER_UNKNOWN_SECTION,\r
+                             File=self.FullPath,\r
+                             Line=LineNo,\r
                              ExtraData=Line,\r
                              RaiseError = Logger.IS_RAISE_ERROR\r
-                             ) \r
+                             )\r
             else:\r
                 CurrentSection = gINF_SECTION_DEF[TemSectionName]\r
                 self.LastSectionHeaderContent = self.SectionHeaderContent\r
-            \r
+\r
         return SectionLines, CurrentSection\r
 \r
 ## _ConvertSecNameToType\r
 #\r
 #\r
-def _ConvertSecNameToType(SectionName): \r
+def _ConvertSecNameToType(SectionName):\r
     SectionType = ''\r
     if SectionName.upper() not in gINF_SECTION_DEF.keys():\r
-        SectionType = DT.MODEL_UNKNOWN                    \r
+        SectionType = DT.MODEL_UNKNOWN\r
     else:\r
-        SectionType = gINF_SECTION_DEF[SectionName.upper()]  \r
-    \r
-    return SectionType      \r
-        \r
+        SectionType = gINF_SECTION_DEF[SectionName.upper()]\r
+\r
+    return SectionType\r
+\r