]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Parser/InfSectionParser.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Parser / InfSectionParser.py
index 8ba4c3fc0819265a5d11b4abc395322a5ef3051d..474d37379d2b1c2476a1beef7da9ee5b0276289d 100644 (file)
@@ -1,15 +1,9 @@
 ## @file\r
-# This file contained the parser for sections in INF file \r
+# This file contained the parser for sections in INF file\r
 #\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
@@ -95,7 +89,7 @@ def GetSpecialStr2(ItemList, FileName, LineNo, SectionString):
             if ItemList[3] != '':\r
                 Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_SOURCE_SECTION_SECTIONNAME_INVALID \\r
                              % (SectionString), File=FileName, Line=LineNo, ExtraData=SectionString)\r
-        \r
+\r
         if not ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper():\r
             Str2 = ItemList[2] + ' | ' + ItemList[3]\r
         else:\r
@@ -108,7 +102,7 @@ def GetSpecialStr2(ItemList, FileName, LineNo, SectionString):
     return Str2\r
 \r
 ## ProcessUseExtHeader\r
-# \r
+#\r
 #\r
 def ProcessUseExtHeader(ItemList):\r
     NewItemList = []\r
@@ -138,12 +132,12 @@ def ProcessUseExtHeader(ItemList):
                 NewItemList.append(Item)\r
             else:\r
                 AppendContent = AppendContent + "." + Item\r
-    \r
+\r
     if len(NewItemList) > 4:\r
         return False, []\r
-    \r
+\r
     return True, NewItemList\r
-  \r
+\r
 ## GetArch\r
 #\r
 # GetArch\r
@@ -227,7 +221,7 @@ class InfSectionParser(InfDefinSectionParser,
         self.InfBuildOptionSection = InfBuildOptionsObject()\r
         self.InfLibraryClassSection = InfLibraryClassObject()\r
         self.InfPackageSection = InfPackageObject()\r
-        self.InfPcdSection = InfPcdObject(self.MetaFiles.keys()[0])\r
+        self.InfPcdSection = InfPcdObject(list(self.MetaFiles.keys())[0])\r
         self.InfSourcesSection = InfSourcesObject()\r
         self.InfUserExtensionSection = InfUserExtensionObject()\r
         self.InfProtocolSection = InfProtocolObject()\r
@@ -244,7 +238,7 @@ class InfSectionParser(InfDefinSectionParser,
 \r
         #\r
         # A List for store define section content.\r
-        #    \r
+        #\r
         self._PcdNameList = []\r
         self._SectionName = ''\r
         self._SectionType = 0\r
@@ -253,7 +247,7 @@ class InfSectionParser(InfDefinSectionParser,
 \r
     #\r
     # File Header content parser\r
-    #    \r
+    #\r
     def InfHeaderParser(self, Content, InfHeaderObject2, FileName, IsBinaryHeader = False):\r
         if IsBinaryHeader:\r
             (Abstract, Description, Copyright, License) = ParseHeaderCommentSection(Content, FileName, True)\r
@@ -272,7 +266,7 @@ class InfSectionParser(InfDefinSectionParser,
 \r
         #\r
         # Insert Abstract, Description, CopyRight, License into header object\r
-        #                                \r
+        #\r
         InfHeaderObject2.SetAbstract(Abstract)\r
         InfHeaderObject2.SetDescription(Description)\r
         InfHeaderObject2.SetCopyright(Copyright)\r
@@ -287,7 +281,7 @@ class InfSectionParser(InfDefinSectionParser,
     #\r
     #       [section_name.arch<.platform|module_type>]\r
     #\r
-    # @param String    A string contained the content need to be parsed. \r
+    # @param String    A string contained the content need to be parsed.\r
     #\r
     def SectionHeaderParser(self, SectionString, FileName, LineNo):\r
         _Scope = []\r
@@ -313,7 +307,7 @@ class InfSectionParser(InfDefinSectionParser,
             #\r
             # different section should not mix in one section\r
             # Allow different PCD type sections mixed together\r
-            # \r
+            #\r
             if _SectionName.upper() not in _PcdNameList:\r
                 if _SectionName != '' and _SectionName.upper() != ItemList[0].upper():\r
                     Logger.Error('Parser',\r
@@ -350,7 +344,7 @@ class InfSectionParser(InfDefinSectionParser,
 \r
             #\r
             # For [Defines] section, do special check.\r
-            # \r
+            #\r
             if ItemList[0].upper() == DT.TAB_COMMON_DEFINES.upper():\r
                 if len(ItemList) != 1:\r
                     Logger.Error('Parser',\r
@@ -360,26 +354,26 @@ class InfSectionParser(InfDefinSectionParser,
 \r
             #\r
             # For [UserExtension] section, do special check.\r
-            # \r
+            #\r
             if ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper():\r
-            \r
+\r
                 RetValue = ProcessUseExtHeader(ItemList)\r
-                \r
+\r
                 if not RetValue[0]:\r
                     Logger.Error('Parser',\r
                                  FORMAT_INVALID,\r
                                  ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (SectionString),\r
                                  File=FileName, Line=LineNo, ExtraData=SectionString)\r
                 else:\r
-                    ItemList = RetValue[1]              \r
-                \r
+                    ItemList = RetValue[1]\r
+\r
                 if len(ItemList) == 3:\r
                     ItemList.append('COMMON')\r
-                \r
+\r
                 Str1 = ItemList[1]\r
 \r
             #\r
-            # For Library classes, need to check module type.       \r
+            # For Library classes, need to check module type.\r
             #\r
             if ItemList[0].upper() == DT.TAB_LIBRARY_CLASSES.upper() and len(ItemList) == 3:\r
                 if ItemList[2] != '':\r
@@ -424,10 +418,10 @@ class InfSectionParser(InfDefinSectionParser,
 \r
     ## GenSpecialSectionList\r
     #\r
-    #  @param SpecialSectionList: a list of list, of which item's format \r
+    #  @param SpecialSectionList: a list of list, of which item's format\r
     #                             (Comment, LineNum)\r
     #  @param ContainerFile:      Input value for filename of Inf file\r
-    # \r
+    #\r
     def InfSpecialCommentParser (self, SpecialSectionList, InfSectionObject, ContainerFile, SectionType):\r
         ReFindSpecialCommentRe = re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL)\r
         ReFindHobArchRe = re.compile(r"""[Hh][Oo][Bb]\.([^,]*)""", re.DOTALL)\r
@@ -455,7 +449,7 @@ class InfSectionParser(InfDefinSectionParser,
                     Arch = Match.groups(1)[0].upper()\r
                     ArchList.append(Arch)\r
             CommentSoFar = ''\r
-            for Index in xrange(1, len(List)):\r
+            for Index in range(1, len(List)):\r
                 Result = ParseComment(List[Index], DT.ALL_USAGE_TOKENS, TokenDict, [], False)\r
                 Usage = Result[0]\r
                 Type = Result[1]\r