## @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
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
return Str2\r
\r
## ProcessUseExtHeader\r
-# \r
+#\r
#\r
def ProcessUseExtHeader(ItemList):\r
NewItemList = []\r
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
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
\r
#\r
# A List for store define section content.\r
- # \r
+ #\r
self._PcdNameList = []\r
self._SectionName = ''\r
self._SectionType = 0\r
\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
\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
#\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
#\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
\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
\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
\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
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