summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/AutoGen/InfSectionParser.py
diff options
context:
space:
mode:
authorkx <kx@radix.pro>2024-06-04 06:43:08 +0300
committerkx <kx@radix.pro>2024-06-04 06:43:08 +0300
commit7e2ccccace24636f29ddc210b94606abd4c7e42b (patch)
tree545d43ea12671048956cafeb12303e84d601e571 /BaseTools/Source/Python/AutoGen/InfSectionParser.py
parent27b044605cd5f6b33a3d231576003850b3fe305b (diff)
downloadedk2-trunk.tar.xz
Renormalized end-of-lines from master@27b044605cd5f6b33a3d231576003850b3fe305btrunk
Diffstat (limited to 'BaseTools/Source/Python/AutoGen/InfSectionParser.py')
-rw-r--r--BaseTools/Source/Python/AutoGen/InfSectionParser.py238
1 files changed, 119 insertions, 119 deletions
diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/Source/Python/AutoGen/InfSectionParser.py
index a55ddac341..38e3861cd7 100644
--- a/BaseTools/Source/Python/AutoGen/InfSectionParser.py
+++ b/BaseTools/Source/Python/AutoGen/InfSectionParser.py
@@ -1,119 +1,119 @@
-## @file
-# Parser a Inf file and Get specify section data.
-#
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-
-## Import Modules
-#
-
-import Common.EdkLogger as EdkLogger
-from Common.BuildToolError import *
-from Common.DataType import *
-
-
-class InfSectionParser():
- def __init__(self, FilePath):
- self._FilePath = FilePath
- self._FileSectionDataList = []
- self._ParserInf()
-
- def _ParserInf(self):
- FileLinesList = []
- UserExtFind = False
- FindEnd = True
- FileLastLine = False
- SectionLine = ''
- SectionData = []
-
- try:
- with open(self._FilePath, "r") as File:
- FileLinesList = File.readlines()
- except BaseException:
- EdkLogger.error("build", AUTOGEN_ERROR, 'File %s is opened failed.' % self._FilePath)
-
- for Index in range(0, len(FileLinesList)):
- line = str(FileLinesList[Index]).strip()
- if Index + 1 == len(FileLinesList):
- FileLastLine = True
- NextLine = ''
- else:
- NextLine = str(FileLinesList[Index + 1]).strip()
- if UserExtFind and FindEnd == False:
- if line:
- SectionData.append(line)
- if line.startswith(TAB_SECTION_START) and line.endswith(TAB_SECTION_END):
- SectionLine = line
- UserExtFind = True
- FindEnd = False
-
- if (NextLine != '' and NextLine[0] == TAB_SECTION_START and \
- NextLine[-1] == TAB_SECTION_END) or FileLastLine:
- UserExtFind = False
- FindEnd = True
- self._FileSectionDataList.append({SectionLine: SectionData[:]})
- del SectionData[:]
- SectionLine = ''
-
- # Get user extension TianoCore data
- #
- # @return: a list include some dictionary that key is section and value is a list contain all data.
- def GetUserExtensionTianoCore(self):
- UserExtensionTianoCore = []
- if not self._FileSectionDataList:
- return UserExtensionTianoCore
- for SectionDataDict in self._FileSectionDataList:
- for key in SectionDataDict:
- if key.lower().startswith("[userextensions") and key.lower().find('.tianocore.') > -1:
- SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
- SubSectionList = [SectionLine]
- if str(SectionLine).find(TAB_COMMA_SPLIT) > -1:
- SubSectionList = str(SectionLine).split(TAB_COMMA_SPLIT)
- for SubSection in SubSectionList:
- if SubSection.lower().find('.tianocore.') > -1:
- UserExtensionTianoCore.append({SubSection: SectionDataDict[key]})
- return UserExtensionTianoCore
-
- # Get depex expression
- #
- # @return: a list include some dictionary that key is section and value is a list contain all data.
- def GetDepexExpresionList(self):
- DepexExpressionList = []
- if not self._FileSectionDataList:
- return DepexExpressionList
- for SectionDataDict in self._FileSectionDataList:
- for key in SectionDataDict:
- if key.lower() == "[depex]" or key.lower().startswith("[depex."):
- SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
- SubSectionList = [SectionLine]
- if str(SectionLine).find(TAB_COMMA_SPLIT) > -1:
- SubSectionList = str(SectionLine).split(TAB_COMMA_SPLIT)
- for SubSection in SubSectionList:
- SectionList = SubSection.split(TAB_SPLIT)
- SubKey = ()
- if len(SectionList) == 1:
- SubKey = (TAB_ARCH_COMMON, TAB_ARCH_COMMON)
- elif len(SectionList) == 2:
- SubKey = (SectionList[1], TAB_ARCH_COMMON)
- elif len(SectionList) == 3:
- SubKey = (SectionList[1], SectionList[2])
- else:
- EdkLogger.error("build", AUTOGEN_ERROR, 'Section %s is invalid.' % key)
- DepexExpressionList.append({SubKey: SectionDataDict[key]})
- return DepexExpressionList
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+## @file
+# Parser a Inf file and Get specify section data.
+#
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+## Import Modules
+#
+
+import Common.EdkLogger as EdkLogger
+from Common.BuildToolError import *
+from Common.DataType import *
+
+
+class InfSectionParser():
+ def __init__(self, FilePath):
+ self._FilePath = FilePath
+ self._FileSectionDataList = []
+ self._ParserInf()
+
+ def _ParserInf(self):
+ FileLinesList = []
+ UserExtFind = False
+ FindEnd = True
+ FileLastLine = False
+ SectionLine = ''
+ SectionData = []
+
+ try:
+ with open(self._FilePath, "r") as File:
+ FileLinesList = File.readlines()
+ except BaseException:
+ EdkLogger.error("build", AUTOGEN_ERROR, 'File %s is opened failed.' % self._FilePath)
+
+ for Index in range(0, len(FileLinesList)):
+ line = str(FileLinesList[Index]).strip()
+ if Index + 1 == len(FileLinesList):
+ FileLastLine = True
+ NextLine = ''
+ else:
+ NextLine = str(FileLinesList[Index + 1]).strip()
+ if UserExtFind and FindEnd == False:
+ if line:
+ SectionData.append(line)
+ if line.startswith(TAB_SECTION_START) and line.endswith(TAB_SECTION_END):
+ SectionLine = line
+ UserExtFind = True
+ FindEnd = False
+
+ if (NextLine != '' and NextLine[0] == TAB_SECTION_START and \
+ NextLine[-1] == TAB_SECTION_END) or FileLastLine:
+ UserExtFind = False
+ FindEnd = True
+ self._FileSectionDataList.append({SectionLine: SectionData[:]})
+ del SectionData[:]
+ SectionLine = ''
+
+ # Get user extension TianoCore data
+ #
+ # @return: a list include some dictionary that key is section and value is a list contain all data.
+ def GetUserExtensionTianoCore(self):
+ UserExtensionTianoCore = []
+ if not self._FileSectionDataList:
+ return UserExtensionTianoCore
+ for SectionDataDict in self._FileSectionDataList:
+ for key in SectionDataDict:
+ if key.lower().startswith("[userextensions") and key.lower().find('.tianocore.') > -1:
+ SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
+ SubSectionList = [SectionLine]
+ if str(SectionLine).find(TAB_COMMA_SPLIT) > -1:
+ SubSectionList = str(SectionLine).split(TAB_COMMA_SPLIT)
+ for SubSection in SubSectionList:
+ if SubSection.lower().find('.tianocore.') > -1:
+ UserExtensionTianoCore.append({SubSection: SectionDataDict[key]})
+ return UserExtensionTianoCore
+
+ # Get depex expression
+ #
+ # @return: a list include some dictionary that key is section and value is a list contain all data.
+ def GetDepexExpresionList(self):
+ DepexExpressionList = []
+ if not self._FileSectionDataList:
+ return DepexExpressionList
+ for SectionDataDict in self._FileSectionDataList:
+ for key in SectionDataDict:
+ if key.lower() == "[depex]" or key.lower().startswith("[depex."):
+ SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
+ SubSectionList = [SectionLine]
+ if str(SectionLine).find(TAB_COMMA_SPLIT) > -1:
+ SubSectionList = str(SectionLine).split(TAB_COMMA_SPLIT)
+ for SubSection in SubSectionList:
+ SectionList = SubSection.split(TAB_SPLIT)
+ SubKey = ()
+ if len(SectionList) == 1:
+ SubKey = (TAB_ARCH_COMMON, TAB_ARCH_COMMON)
+ elif len(SectionList) == 2:
+ SubKey = (SectionList[1], TAB_ARCH_COMMON)
+ elif len(SectionList) == 3:
+ SubKey = (SectionList[1], SectionList[2])
+ else:
+ EdkLogger.error("build", AUTOGEN_ERROR, 'Section %s is invalid.' % key)
+ DepexExpressionList.append({SubKey: SectionDataDict[key]})
+ return DepexExpressionList
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+