Exemple #1
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     from .. import platform
     self.fd.close()
     if exc_type is not None:
         truncate_and_unlink(self.tmppath)
         return
     os.replace(self.tmppath, self.path)
     platform.sync_dir(os.path.dirname(self.path))
Exemple #2
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     from .. import platform
     self.fd.close()
     if exc_type is not None:
         truncate_and_unlink(self.tmppath)
         return
     os.replace(self.tmppath, self.path)
     platform.sync_dir(os.path.dirname(self.path))
Exemple #3
0
 def __enter__(self):
     from .. import platform
     try:
         truncate_and_unlink(self.tmppath)
     except FileNotFoundError:
         pass
     self.fd = platform.SyncFile(self.tmppath, self.binary)
     return self.fd
Exemple #4
0
 def __enter__(self):
     from .. import platform
     try:
         truncate_and_unlink(self.tmppath)
     except FileNotFoundError:
         pass
     self.fd = platform.SyncFile(self.tmppath, self.binary)
     return self.fd