From 6d4f4cc01d2f63d9aa7e9bee068b9a9a261a5824 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 10 Nov 2014 18:32:24 -0200 Subject: using with to write encrypted storage --- service/pixelated/support/encrypted_file_storage.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'service/pixelated/support/encrypted_file_storage.py') diff --git a/service/pixelated/support/encrypted_file_storage.py b/service/pixelated/support/encrypted_file_storage.py index cdf52ecf..c6410404 100644 --- a/service/pixelated/support/encrypted_file_storage.py +++ b/service/pixelated/support/encrypted_file_storage.py @@ -23,8 +23,8 @@ class EncryptedFileStorage(FileStorage): file_struct.seek(0) content = file_struct.file.read() encrypted_content = self.f.encrypt(content) - _file = open(self._fpath(name), 'w+b') - _file.write(encrypted_content) + with open(self._fpath(name), 'w+b') as _f: + _f.write(encrypted_content) return self._open_file(name, onclose=onclose) @@ -33,8 +33,8 @@ class EncryptedFileStorage(FileStorage): file_struct.seek(0) content = file_struct.file.read() encrypted_content = self.f.encrypt(content) - _file = open(self._fpath(name), 'w+b') - _file.write(encrypted_content) + with open(self._fpath(name), 'w+b') as _f: + _f.write(encrypted_content) f = StructFile(io.BytesIO(), name=name, onclose=onclose) f.is_real = False -- cgit v1.2.3