diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2014-11-10 18:32:24 -0200 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2014-11-10 18:32:24 -0200 |
commit | 6d4f4cc01d2f63d9aa7e9bee068b9a9a261a5824 (patch) | |
tree | 539dd00bd81a2759f218fc26d2fc0aadb42b6d5a /service | |
parent | 84689864542cb9c6c356b5204f94dd7a0ea7a777 (diff) |
using with to write encrypted storage
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/support/encrypted_file_storage.py | 8 |
1 files changed, 4 insertions, 4 deletions
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 |