use 'with' syntax for open file

This commit is contained in:
Michel Oosterhof
2015-12-23 20:28:15 +00:00
parent d15bdb574b
commit bb7f81128e

View File

@@ -444,9 +444,8 @@ class HTTPProgressDownloader(client.HTTPDownloader):
self.curl.fs.getfile(self.fakeoutfile),
self.curl.safeoutfile)
else:
file = open(self.curl.safeoutfile,'r')
self.curl.writeln(file.read())
file.close()
with open(self.curl.safeoutfile, 'r') as f:
self.curl.writeln(f.read())
self.curl.fileName = self.fileName
return client.HTTPDownloader.pageEnd(self)