BaseTools: Explicitly close files after readlines

Rework some file open().readlines to open, readlines, close.
This prevents excessive file handles being open at the same time,
which may be a problem with alternative python environments.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Johnson <michael.johnson@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
mjohn4
2018-11-02 10:02:10 +08:00
committed by Feng, Bob C
parent dbe05cb1c0
commit b0189eac00
2 changed files with 14 additions and 5 deletions

View File

@ -34,7 +34,8 @@ class InfSectionParser():
SectionData = []
try:
FileLinesList = open(self._FilePath, "r").readlines()
with open(self._FilePath, "r") as File:
FileLinesList = File.readlines()
except BaseException:
EdkLogger.error("build", AUTOGEN_ERROR, 'File %s is opened failed.' % self._FilePath)