diff options
author | Corey Farwell <coreyf@rwell.org> | 2015-08-21 11:15:17 -0400 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2015-08-21 11:15:17 -0400 |
commit | 2ab43bea5d508f41790339507ed439d2709c0bfa (patch) | |
tree | 6b6b7843469d00fd7303ffa2b6251f6657c2edc4 /components/script/dom/bindings/codegen/GlobalGen.py | |
parent | 7c45ff8e05a6ebd21f9aa5c360e997a01d48b1fc (diff) | |
download | servo-2ab43bea5d508f41790339507ed439d2709c0bfa.tar.gz servo-2ab43bea5d508f41790339507ed439d2709c0bfa.zip |
Utilize Python context managers for opening/closing files
In some of these cases, files were not being closed
Diffstat (limited to 'components/script/dom/bindings/codegen/GlobalGen.py')
-rw-r--r-- | components/script/dom/bindings/codegen/GlobalGen.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/components/script/dom/bindings/codegen/GlobalGen.py b/components/script/dom/bindings/codegen/GlobalGen.py index 1bebc213e38..b3ed1e25b12 100644 --- a/components/script/dom/bindings/codegen/GlobalGen.py +++ b/components/script/dom/bindings/codegen/GlobalGen.py @@ -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) |