Overwrite a file in place with a short message to save disk.

    This keeps files as a sanity check on processes working, but saves
    disk by replacing them with a short message.
773590
def save_diskspace(fname, reason, config):
    
    if config["algorithm"].get("save_diskspace", False):
        with open(fname, "w") as out_handle:
            out_handle.write("File removed to save disk space: %s" % reason)
269383
def overwrite(self, bs, pos=None):
        
        bs = Bits(bs)
        if not bs.len:
            return
        if pos is None:
            try:
                pos = self._pos
            except AttributeError:
                raise TypeError("overwrite require a bit position for this type.")
        if pos < 0:
            pos += self.len
        if pos < 0 or pos + bs.len > self.len:
            raise ValueError("Overwrite exceeds boundary of bitstring.")
        self._overwrite(bs, pos)
        try:
            self._pos = pos + bs.len
        except AttributeError:
            pass
832770
def save(cls,instance,filename):
        """"""
        filename = cls.correct_file_extension(filename)
        try:
            with open(filename,'wb') as f:
                pickle.dump(instance,f,protocol=pickle.HIGHEST_PROTOCOL)
        except MemoryError as e:
            print ('{} occurred, will downsampled the saved file by 20.'
                   .format(type(e).__name__))
            copy_instance = instance.copy()
            copy_instance.H = copy_instance.H[::20,:,:]
            copy_instance.Y = copy_instance.Y[::20,:]
            with open(filename,'wb') as f:
                pickle.dump(copy_instance,f,protocol=pickle.HIGHEST_PROTOCOL)
673493
def append_message(self,
                       message):
        
        # Delete the first message of the list
        if len(self.messages) > 0:
            del self.messages[0]

        # Append the new message at the end
        self.messages.append(message)
        self.changes_made = True

        # Redraw
        self.redraw()
448572
def save(self, filename):
        ''''''
        try:
            f = open(filename, mode='w')
        except Exception:
            return False
        for k in self.list():
            f.write("%s=%s\n" % (k, self.get(k)))
        f.close()
        return True
1044127
def save(self, *args):
        
        with open(self.file_root + '.pkl', "wb") as f:
            pickle.dump(args, f, protocol=pickle.HIGHEST_PROTOCOL)
981441
def save_file(self):
        """"""

        l = []
        walk = self.walker
        for edit in walk.lines:
            # collect the text already stored in edit widgets
            if edit.original_text.expandtabs() == edit.edit_text:
                l.append(edit.original_text)
            else:
                l.append(re_tab(edit.edit_text))

        # then the rest
        while walk.file is not None:
            l.append(walk.read_next_line())

        # write back to disk
        outfile = open(self.save_name, "w")

        l_iter = iter(l)

        line = next(l_iter)
        prefix = ""

        while True:
            try:
                outfile.write(prefix + line)
                prefix = "\n"
                line = next(l_iter)
            except StopIteration:
                if line != "\n":
                    outfile.write("\n")
                break
435576
function storeFileToDisk(i_oFile, i_sOutput) {
    var l_sDirname = path.dirname(i_oFile.filename),
        l_sFilename;

    console.log("File name: ", i_oFile.filename, " size: ", i_oFile.header.unpackedSize);
    console.log("Saving content of file ");

    l_sDirname = path.join(i_sOutput, path.dirname(i_oFile.filename));
    l_sFilename = path.join(l_sDirname, path.basename(i_oFile.filename));
    return new Promise(function(i_oResolve) {
        mkdirp(l_sDirname, function (err) {
            if (err) console.error(err);
            _writeFile(l_sFilename, i_oFile, i_oResolve);
        });
    });
}
162838
def write(self, value):
        

        if self.capacity > 0 and self.strategy == 0:
            len_value = len(value)
            if len_value >= self.capacity:
                needs_new_strategy = True
            else:
                self.seek(0, 2)  # find end of file
                needs_new_strategy = \
                    (self.tell() + len_value) >= self.capacity
            if needs_new_strategy:
                self.makeTempFile()

        if not isinstance(value, six.binary_type):
            value = value.encode('utf-8')

        self._delegate.write(value)
1111815
def save(self):
        """"""
        file_name = fd.asksaveasfilename()
        if file_name is "" or file_name is None:
            return
        with open(file_name, "w") as f:
            f.write(self.text.get("1.0", tk.END))
749430
def save_file(path, text):
    
    dir = os.path.dirname(path)
    if not os.path.exists(dir):
        os.makedirs(dir)

    fd = open(path, 'w')
    try:
        fd.write(text)
    finally:
        fd.close()
776189
def save(self, path, compressed=True, exist_ok=False):
        
        path = os.path.expandvars(os.path.expanduser(path))
        if os.path.isfile(path) and not exist_ok:
            raise OSError(17, os.strerror(17), path)

        if os.path.isdir(path):
            path = os.path.join(path, "out.gdg")

        if compressed:
            bytes_written = cgaddag.gdg_save_compressed(self.gdg, path.encode("ascii"))
        else:
            bytes_written = cgaddag.gdg_save(self.gdg, path.encode("ascii"))

        if bytes_written == -1:
            errno = ctypes.c_int.in_dll(ctypes.pythonapi, "errno").value
            raise OSError(errno, os.strerror(errno), path)

        return bytes_written
1022049
def save(self, filename=None):
        
        if filename is None:
            filename = self.filename
        with open(filename, 'wb') as f:
            f.write(self.data)
767594
def save(self, path, **extra):
        
        with File(path, 'w') as f:
            for key, val in vars(self).items():
                assert val is not None, key  # sanity check
                try:
                    f[key] = maybe_encode(val)
                except ValueError as err:
                    if 'Object header message is too large' in str(err):
                        logging.error(str(err))
            for k, v in extra.items():
                f.attrs[k] = maybe_encode(v)
311114
function(src, dest){
      self.logger.warn('File at '+dest+' exists, overwrite?');
      
      rl.question('(yN) ', function(answer){
        switch(answer.toLowerCase()){
          case 'y':
            this.copy(src, dest); 
            this.triggerNext(); 
            break; 
          case 'n':
            this.triggerNext(); 
            break; 
          default:
            this.waitForResponse(src, dest); 
            break; 
        }
      }.bind(this)); 
    }
547440
def append_onto_file(self, file_name, msg):
        
        with open(file_name, "a") as heart_file:
            heart_file.write(msg)
            heart_file.close()
555280
def _overwrite(self, bs, pos):
        """"""
        assert 0 <= pos < self.len
        if bs is self:
            # Just overwriting with self, so do nothing.
            assert pos == 0
            return
        firstbytepos = (self._offset + pos) // 8
        lastbytepos = (self._offset + pos + bs.len - 1) // 8
        bytepos, bitoffset = divmod(self._offset + pos, 8)
        if firstbytepos == lastbytepos:
            mask = ((1 << bs.len) - 1) << (8 - bs.len - bitoffset)
            self._datastore.setbyte(bytepos, self._datastore.getbyte(bytepos) & (~mask))
            d = offsetcopy(bs._datastore, bitoffset)
            self._datastore.setbyte(bytepos, self._datastore.getbyte(bytepos) | (d.getbyte(0) & mask))
        else:
            # Do first byte
            mask = (1 << (8 - bitoffset)) - 1
            self._datastore.setbyte(bytepos, self._datastore.getbyte(bytepos) & (~mask))
            d = offsetcopy(bs._datastore, bitoffset)
            self._datastore.setbyte(bytepos, self._datastore.getbyte(bytepos) | (d.getbyte(0) & mask))
            # Now do all the full bytes
            self._datastore.setbyteslice(firstbytepos + 1, lastbytepos, d.getbyteslice(1, lastbytepos - firstbytepos))
            # and finally the last byte
            bitsleft = (self._offset + pos + bs.len) % 8
            if not bitsleft:
                bitsleft = 8
            mask = (1 << (8 - bitsleft)) - 1
            self._datastore.setbyte(lastbytepos, self._datastore.getbyte(lastbytepos) & mask)
            self._datastore.setbyte(lastbytepos,
                                    self._datastore.getbyte(lastbytepos) | (d.getbyte(d.bytelength - 1) & ~mask))
        assert self._assertsanity()