def __exit__(self, exc_type, exc_value, tback):
# Pass to tempfile, which also closes().
temp_path = self.temp.name
self.temp.__exit__(exc_type, exc_value, tback)
self.temp = None
if exc_type is not None:
# An exception occurred, clean up.
try:
_os.remove(temp_path)
except FileNotFoundError:
pass
else:
# No exception, commit changes
_os.replace(temp_path, self.filename)
return False # Don't cancel the exception.
# Import these, so people can reference 'srctools.Vec' instead of
# 'srctools.vec.Vec'.
# Should be done after other code, so everything's initialised.
# Not all classes are imported, just most-used ones.
评论列表
文章目录