def __idle_save_text(self, status): self.__save_text_id = 0 _logger.debug("autosaving to %s", self.__filename) dn,bn = os.path.split(self.__filename) try: perms = os.stat(self.__filename).st_mode except: perms = None (tempfd, temppath) = tempfile.mkstemp('.tmp', self.__filename, dn) os.close(tempfd) f = open_text_file(temppath, 'w') text = self.input.get_property("text") utext = str(text) f.write(utext) f.flush() os.fsync(tempfd) f.close() if perms is not None: os.chmod(temppath, perms) atomic_rename(temppath, self.__filename) self.__show_msg(status + _("...done")) self.__modified = False self.__sync_modified_sensitivity() _logger.debug("autosave complete") return False
def __idle_save_text(self, status): self.__save_text_id = 0 _logger.debug("autosaving to %s", self.__filename) dn, bn = os.path.split(self.__filename) try: perms = os.stat(self.__filename).st_mode except: perms = None (tempfd, temppath) = tempfile.mkstemp('.tmp', self.__filename, dn) os.close(tempfd) f = open_text_file(temppath, 'w') text = self.input.get_property("text") utext = unicode(text) f.write(utext) f.flush() os.fsync(tempfd) f.close() if perms is not None: os.chmod(temppath, perms) atomic_rename(temppath, self.__filename) self.__show_msg(status + _("...done")) self.__modified = False self.__sync_modified_sensitivity() _logger.debug("autosave complete") return False
def add(self, path): if path in self.__bookmarks: return self.__bookmarks.append(path) (bdir, bname) = os.path.split(self.__bookmarks_path) (fd, temppath) = tempfile.mkstemp('.tmp', bname, bdir) f = os.fdopen(fd, 'w') for mark in self.__bookmarks: f.write(path_tourl(mark)) f.write('\n') f.close() atomic_rename(temppath, self.__bookmarks_path) # Might as well signal now dispatcher.send(sender=self)