(self, filename: PATH_TYPES, **kw: Any)
Rewrite a file atomically.

        Clients are allowed to delete the tmpfile to signal that they don't
        want to have it updated.
Rewrite a file atomically.
Rewrite a file atomically .
def update_safe(self, filename: PATH_TYPES, **kw: Any) -> Generator[IO, None, None]:
        """Rewrite a file atomically.

        Clients are allowed to delete the tmpfile to signal that they don't
        want to have it updated.
        """
        with tempfile.NamedTemporaryFile(
            delete=False,
            prefix=f"{os.path.basename(filename)}.",
            **kw,
        ) as tf:
            # TODO: Workout if this is actually used / needed
            tf.has_changed = False  # type: ignore
            yield tf
            if not os.path.exists(tf.name):
                return
            local_filename_tmp = pathlib.Path(tf.name)
        self.copy_local_file(str(local_filename_tmp), str(filename))
        local_filename_tmp.unlink()
def update_safe ( self , filename : PATH_TYPES , * * kw : Any ) -> Generator [ IO , None , None ] : with tempfile . NamedTemporaryFile ( delete = False , prefix = f"{os.path.basename(filename)}." , * * kw , ) as tf : # TODO: Workout if this is actually used / needed tf . has_changed = False # type: ignore yield tf if not os . path . exists ( tf . name ) : return local_filename_tmp = pathlib . Path ( tf . name ) self . copy_local_file ( str ( local_filename_tmp ) , str ( filename ) ) local_filename_tmp . unlink ( )