]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/InfSectionParser.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / InfSectionParser.py
index d98508973841ed61ec9562151dd3cc3d2d5983d7..a55ddac341b65a6468e8d99f1befedeb8fb710c1 100644 (file)
@@ -2,13 +2,7 @@
 # Parser a Inf file and Get specify section data.\r
 #\r
 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this 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
 ## Import Modules\r
@@ -34,7 +28,8 @@ class InfSectionParser():
         SectionData = []\r
 \r
         try:\r
-            FileLinesList = open(self._FilePath, "r", 0).readlines()\r
+            with open(self._FilePath, "r") as File:\r
+                FileLinesList = File.readlines()\r
         except BaseException:\r
             EdkLogger.error("build", AUTOGEN_ERROR, 'File %s is opened failed.' % self._FilePath)\r
 \r
@@ -80,13 +75,13 @@ class InfSectionParser():
                             UserExtensionTianoCore.append({SubSection: SectionDataDict[key]})\r
         return UserExtensionTianoCore\r
 \r
-    # Get depex expresion\r
+    # Get depex expression\r
     #\r
     # @return: a list include some dictionary that key is section and value is a list contain all data.\r
     def GetDepexExpresionList(self):\r
-        DepexExpresionList = []\r
+        DepexExpressionList = []\r
         if not self._FileSectionDataList:\r
-            return DepexExpresionList\r
+            return DepexExpressionList\r
         for SectionDataDict in self._FileSectionDataList:\r
             for key in SectionDataDict:\r
                 if key.lower() == "[depex]" or key.lower().startswith("[depex."):\r
@@ -105,8 +100,8 @@ class InfSectionParser():
                             SubKey = (SectionList[1], SectionList[2])\r
                         else:\r
                             EdkLogger.error("build", AUTOGEN_ERROR, 'Section %s is invalid.' % key)\r
-                        DepexExpresionList.append({SubKey: SectionDataDict[key]})\r
-        return DepexExpresionList\r
+                        DepexExpressionList.append({SubKey: SectionDataDict[key]})\r
+        return DepexExpressionList\r
 \r
 \r
 \r