Write data String/Buffer into filename
548497
function write(filename, mtime, data) {
  var tempname = filename + '+';

  try {
    mkdirp(path.dirname(filename));
    fs.writeFileSync(tempname, toBuffer(data));
    fs.renameSync(tempname, filename);
    fs.utimesSync(filename, mtime, mtime);
  } catch (err) {
    // Try to remove tmp file on error.
    // Don't check if exists, just suppress errors
    try { fs.unlinkSync(tempname); } catch (__) {}

    throw err;
  }
}
833978
function write(buffer) {

    // first, trim trailing whitespace for fast searching
    buffer = buffer.replace(/[ \t]+$/gm, '')

    // compact lines if emptyLines != -1
    if (_elines >= 0)
      buffer = trimBuffer(buffer)

    if (!buffer) return

    // finished the surrounding lines, now the inners
    if (!_elines) {
      // remove empty lines and change eols in one unique operation
      buffer = buffer.replace(/\n{2,}/g, _to)
    }
    else {
      // keep max n empty lines (n+1 sucesive eols), -1 keep all
      if (_elines > 0)
        buffer = buffer.replace(_re, '$1')

      // change line terminator if not unix
      if (_to !== '\n') buffer = buffer.replace(/\n/g, _to)
    }

    // apply indentation, regex `^.` with `/m` matches non-empty lines
    if (_indent)
      buffer = buffer.replace(/^./mg, _indent + '$&')

    _lastch = buffer.slice(-1)
    // istanbul ignore else
    if (output)
      output.emit('data', buffer)
  }
1317561
function writeFileSync (fileName, data, options) {
    verifyFileName (fileName);
    
    var info = getFileInfo (fileName);
    if ((info.exists === true) && (info.isFile === false)) {
        var message1 = format (cc.MSG_IS_NOT_A_FILE, fileName);
        throw new SafeFileError (cc.IS_NOT_A_FILE, message1);
    }

    // if content undefined or null, set data to empty string
    if ((data === undefined) || (data === null)) {
        data = "";
    }

    // write file content, throwing exception on error occurring
    try {
        fs.writeFileSync (fileName, data, options);
    } catch (e) {
        var message2 = format (cc.MSG_WRITE_ERROR, e.message);
        throw new SafeFileError (cc.WRITE_ERROR, message2);
    }
}
573718
def write_file(self, filename="paths.dat"):
        
        with zopen(filename, "wt") as f:
            f.write(str(self) + "\n")
1147290
def file_to_str(fname):
    
    data = None
    # rU = read with Universal line terminator
    with open(fname, 'rU') as fd:
        data = fd.read()
    return data
997857
def _write_file(iface, data, folder, pattern):
    '''
    
    '''
    filename = os.path.join(folder, pattern.format(iface))
    if not os.path.exists(folder):
        msg = '{0} cannot be written. {1} does not exist'
        msg = msg.format(filename, folder)
        log.error(msg)
        raise AttributeError(msg)
    with salt.utils.files.flopen(filename, 'w') as fout:
        fout.write(salt.utils.stringutils.to_str(data))
    return filename
1210706
def write(self, filename):
        """"""
        if file_exists(filename):
            return filename
        out_files = [filename, filename + ".rownames", filename + ".colnames"]
        with file_transaction(out_files) as tx_out_files:
            with open(tx_out_files[0], "wb") as out_handle:
                scipy.io.mmwrite(out_handle, scipy.sparse.csr_matrix(self.matrix))
            pd.Series(self.rownames).to_csv(tx_out_files[1], index=False)
            pd.Series(self.colnames).to_csv(tx_out_files[2], index=False)
        return filename
571676
def storedata(filename=None):
    """"""
    if filename is None:
        filename = 'credolib_state.pickle'
    ns = get_ipython().user_ns
    with open(filename, 'wb') as f:
        d = {}
        for var in ['_headers', '_loaders', '_data1d', '_data2d', '_data1dunited',
                    'allsamplenames', '_headers_sample', 'badfsns', '_rowavg',
                    'saveto_dir',
                    'badfsns_datcmp', 'auximages_dir', 'subtractedsamplenames', 'outputpath', 'saveto_dir_rel',
                    'auximages_dir_rel', 'crd_prefix']:
            try:
                d[var] = ns[var]
            except KeyError:
                warnings.warn('Skipping storage of unavailable variable "%s"' % var)
        pickle.dump(d, f)
134569
def filesfile_string(self):
        """"""
        lines = []
        app = lines.append

        #optic.in     ! Name of input file
        #optic.out    ! Unused
        #optic        ! Root name for all files that will be produced
        app(self.input_file.path)                           # Path to the input file
        app(os.path.join(self.workdir, "unused"))           # Path to the output file
        app(os.path.join(self.workdir, self.prefix.odata))  # Prefix for output data

        return "\n".join(lines)
845372
def write(self, filename = ""):
        
        file_data = str(self)
        if filename:
            try:
                self.__write(filename, file_data)
            except IOError:
                raise IOError("File could not be opened for write operations.")
        else:
            return file_data
933118
def write_file(path, data):
    """"""
    with open(path, 'w') as f:
        log.debug('setting %s contents:\n%s', path, data)
        f.write(data)
    return f
1019693
def write(self, file_or_filename):
        
        if isinstance(file_or_filename, basestring):
            file = None
            try:
                file = open(file_or_filename, "wb")
            except Exception, detail:
                logger.error("Error opening %s." % detail)
            finally:
                if file is not None:
                    self._write_data(file)
                    file.close()
        else:
            file = file_or_filename
            self._write_data(file)

        return file
817845
def write_to_buffer(self, buf):
        """"""
        doc = self.to_dict()

        if config.rxt_as_yaml:
            content = dump_yaml(doc)
        else:
            content = json.dumps(doc, indent=4, separators=(",", ": "))

        buf.write(content)
1045785
public static void writeToFile(String str, String fileName, Charset charset) throws Exception {
    OutputStreamWriter writer = null;
    if (null == charset) {
      writer = new OutputStreamWriter(new FileOutputStream(fileName));
    } else {
      writer = new OutputStreamWriter(new FileOutputStream(fileName), charset.name());
    }
    writer.write(str);
    writer.close();
  }
318833
def bytes_to_file(input_data, output_file):
    """"""
    pathlib.Path(output_file.parent).mkdir(parents=True, exist_ok=True)

    with open(output_file, "wb") as file:
        file.write(input_data)
1328023
def write_text(self, name, s):
        """"""
        buf = io.BytesIO(compat.to_bytes(s))
        self.write_file(name, buf)
1284784
def file_data_to_str(data):
    
    if not data:
        return _('<i>File name not recorded</i>')
    res = data['name']
    try:
        mtime_as_str = time.strftime('%Y-%m-%d %H:%M:%S',
                                     time.localtime(data['mtime']))
        res += '<br><i>{}</i>: {}'.format(_('Last modified'), mtime_as_str)
        res += '<br><i>{}</i>: {} {}'.format(
                _('Size'), data['size'], _('bytes'))
    except KeyError:
        res += '<br>' + _('<i>File no longer exists</i>')
    return res