simulate_perfect: Do not overwrite original file

This commit is contained in:
2021-01-13 11:04:33 -06:00
parent b01d97cc2b
commit beee252fa2
6 changed files with 46 additions and 26 deletions

View File

@@ -29,12 +29,15 @@ class InstanceIterator:
self.current += 1
if isinstance(result, str):
logger.debug("Read: %s" % result)
if result.endswith(".gz"):
with gzip.GzipFile(result, "rb") as file:
result = pickle.load(file)
else:
with open(result, "rb") as file:
result = pickle.load(file)
try:
if result.endswith(".gz"):
with gzip.GzipFile(result, "rb") as file:
result = pickle.load(file)
else:
with open(result, "rb") as file:
result = pickle.load(file)
except pickle.UnpicklingError:
raise Exception(f"Invalid instance file: {result}")
return result