mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Utilize Python context managers for opening/closing files
In some of these cases, files were not being closed
This commit is contained in:
parent
7c45ff8e05
commit
2ab43bea5d
5 changed files with 18 additions and 21 deletions
|
@ -47,16 +47,14 @@ def main():
|
|||
parser = WebIDL.Parser(options.cachedir)
|
||||
for filename in fileList:
|
||||
fullPath = os.path.normpath(os.path.join(baseDir, filename))
|
||||
f = open(fullPath, 'rb')
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
with open(fullPath, 'rb') as f:
|
||||
lines = f.readlines()
|
||||
parser.parse(''.join(lines), fullPath)
|
||||
parserResults = parser.finish()
|
||||
|
||||
# Write the parser results out to a pickle.
|
||||
resultsFile = open('ParserResults.pkl', 'wb')
|
||||
cPickle.dump(parserResults, resultsFile, -1)
|
||||
resultsFile.close()
|
||||
with open('ParserResults.pkl', 'wb') as resultsFile:
|
||||
cPickle.dump(parserResults, resultsFile, -1)
|
||||
|
||||
# Load the configuration.
|
||||
config = Configuration(configFile, parserResults)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue