diff options
author | Jaime van Kessel <nallath@gmail.com> | 2016-09-08 15:23:35 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2016-09-08 15:23:35 +0300 |
commit | 96a1aafb80e7cb463b22d9185281df096837730d (patch) | |
tree | f05187f3a5ce014a376dfa26fccf190d4dc53d85 /plugins/CuraProfileReader | |
parent | 45a841a52bd53909decadb6c916e0194fe9eb2e8 (diff) |
Zipfile is now closed when it's done loading
CURA-2252
Diffstat (limited to 'plugins/CuraProfileReader')
-rw-r--r-- | plugins/CuraProfileReader/CuraProfileReader.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/plugins/CuraProfileReader/CuraProfileReader.py b/plugins/CuraProfileReader/CuraProfileReader.py index c8d39b7a78..2bccb8e3cb 100644 --- a/plugins/CuraProfileReader/CuraProfileReader.py +++ b/plugins/CuraProfileReader/CuraProfileReader.py @@ -27,15 +27,15 @@ class CuraProfileReader(ProfileReader): # returned. def read(self, file_name): try: - archive = zipfile.ZipFile(file_name, "r") - results = [] - for profile_id in archive.namelist(): - with archive.open(profile_id) as f: - serialized = f.read() - profile = self._loadProfile(serialized.decode("utf-8"), profile_id) - if profile is not None: - results.append(profile) - return results + with zipfile.ZipFile(file_name, "r") as archive: + results = [] + for profile_id in archive.namelist(): + with archive.open(profile_id) as f: + serialized = f.read() + profile = self._loadProfile(serialized.decode("utf-8"), profile_id) + if profile is not None: + results.append(profile) + return results except zipfile.BadZipFile: # It must be an older profile from Cura 2.1. |