]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Parser/InfSourceSectionParser.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Parser / InfSourceSectionParser.py
index 51db7960353d8e327ac4d673dd59f0c0e48ecc84..916df7ee1a3464be3b460b395abf6e70d216c5a4 100644 (file)
@@ -1,15 +1,9 @@
 ## @file\r
-# This file contained the parser for [Sources] sections in INF file \r
+# This file contained the parser for [Sources] sections in INF file\r
 #\r
-# Copyright (c) 2011, 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
 InfSourceSectionParser\r
@@ -31,7 +25,7 @@ from Parser.InfParserMisc import InfParserSectionRoot
 class InfSourceSectionParser(InfParserSectionRoot):\r
     ## InfSourceParser\r
     #\r
-    #          \r
+    #\r
     def InfSourceParser(self, SectionString, InfSectionObject, FileName):\r
         SectionMacros = {}\r
         ValueList     = []\r
@@ -43,12 +37,12 @@ class InfSourceSectionParser(InfParserSectionRoot):
         for Line in SectionString:\r
             SrcLineContent = Line[0]\r
             SrcLineNo      = Line[1]\r
-            \r
+\r
             if SrcLineContent.strip() == '':\r
                 continue\r
-            \r
+\r
             #\r
-            # Found Header Comments \r
+            # Found Header Comments\r
             #\r
             if SrcLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):\r
                 #\r
@@ -59,7 +53,7 @@ class InfSourceSectionParser(InfParserSectionRoot):
                     SectionContent += SrcLineContent + DT.END_OF_LINE\r
                     continue\r
                 #\r
-                # First time encounter comment \r
+                # First time encounter comment\r
                 #\r
                 else:\r
                     #\r
@@ -68,78 +62,78 @@ class InfSourceSectionParser(InfParserSectionRoot):
                     HeaderComments = []\r
                     HeaderComments.append(Line)\r
                     StillCommentFalg = True\r
-                    SectionContent += SrcLineContent + DT.END_OF_LINE \r
+                    SectionContent += SrcLineContent + DT.END_OF_LINE\r
                     continue\r
             else:\r
                 StillCommentFalg = False\r
-                          \r
+\r
             if len(HeaderComments) >= 1:\r
                 LineComment = InfLineCommentObject()\r
                 LineCommentContent = ''\r
                 for Item in HeaderComments:\r
                     LineCommentContent += Item[0] + DT.END_OF_LINE\r
                 LineComment.SetHeaderComments(LineCommentContent)\r
-            \r
+\r
             #\r
             # Find Tail comment.\r
             #\r
             if SrcLineContent.find(DT.TAB_COMMENT_SPLIT) > -1:\r
                 TailComments = SrcLineContent[SrcLineContent.find(DT.TAB_COMMENT_SPLIT):]\r
                 SrcLineContent = SrcLineContent[:SrcLineContent.find(DT.TAB_COMMENT_SPLIT)]\r
-                if LineComment == None:\r
+                if LineComment is None:\r
                     LineComment = InfLineCommentObject()\r
                 LineComment.SetTailComments(TailComments)\r
-                               \r
+\r
             #\r
             # Find Macro\r
             #\r
-            Name, Value = MacroParser((SrcLineContent, SrcLineNo), \r
+            Name, Value = MacroParser((SrcLineContent, SrcLineNo),\r
                                       FileName,\r
                                       DT.MODEL_EFI_SOURCE_FILE,\r
                                       self.FileLocalMacros)\r
-            if Name != None:\r
+            if Name is not None:\r
                 SectionMacros[Name] = Value\r
                 LineComment = None\r
                 HeaderComments = []\r
                 continue\r
-            \r
+\r
             #\r
             # Replace with Local section Macro and [Defines] section Macro.\r
-            #            \r
-            SrcLineContent = InfExpandMacro(SrcLineContent, \r
-                                         (FileName, SrcLineContent, SrcLineNo), \r
-                                         self.FileLocalMacros, \r
+            #\r
+            SrcLineContent = InfExpandMacro(SrcLineContent,\r
+                                         (FileName, SrcLineContent, SrcLineNo),\r
+                                         self.FileLocalMacros,\r
                                          SectionMacros)\r
 \r
             TokenList = GetSplitValueList(SrcLineContent, DT.TAB_VALUE_SPLIT, 4)\r
             ValueList[0:len(TokenList)] = TokenList\r
-          \r
+\r
             #\r
             # Store section content string after MACRO replaced.\r
             #\r
-            SectionContent += SrcLineContent + DT.END_OF_LINE \r
-            \r
-            SourceList.append((ValueList, LineComment, \r
+            SectionContent += SrcLineContent + DT.END_OF_LINE\r
+\r
+            SourceList.append((ValueList, LineComment,\r
                                (SrcLineContent, SrcLineNo, FileName)))\r
             ValueList = []\r
             LineComment = None\r
             TailComments = ''\r
             HeaderComments = []\r
             continue\r
-        \r
+\r
         #\r
         # Current section archs\r
         #\r
         ArchList = []\r
         for Item in self.LastSectionHeaderContent:\r
             if Item[1] not in ArchList:\r
-                ArchList.append(Item[1])  \r
+                ArchList.append(Item[1])\r
                 InfSectionObject.SetSupArchList(Item[1])\r
-                \r
-        InfSectionObject.SetAllContent(SectionContent)             \r
+\r
+        InfSectionObject.SetAllContent(SectionContent)\r
         if not InfSectionObject.SetSources(SourceList, Arch = ArchList):\r
-            Logger.Error('InfParser', \r
+            Logger.Error('InfParser',\r
                          FORMAT_INVALID,\r
                          ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ("[Sources]"),\r
-                         File=FileName, \r
-                         Line=Item[3])            
\ No newline at end of file
+                         File=FileName,\r
+                         Line=Item[3])\r