A basic file writer
188300
def write_to_file(filename, content, mode, chmod=600)
      mode = (mode == :append) ? 'a' : 'w'
      f = File.open(filename,mode)
      f.puts content
      f.close
      return unless Rudy.sysinfo.os == :unix
      raise "Provided chmod is not a Fixnum (#{chmod})" unless chmod.is_a?(Fixnum)
      File.chmod(chmod, filename)
    end
1043987
private static int createWriteDFSPaths()
  {

  	if (createDFSPaths() != 0) {
  		return -1;
  	}
  	
	  try {
		  // write to all the files!
	  	for (Map.Entry<String, OutputStream> file : files_.entrySet()) {
	  		OutputStream os = file.getValue();

	  		long startTime = System.nanoTime();
	  		os.write(data_.getBytes());
        timingWrite_.add(new Double((System.nanoTime() - startTime)/(1E9)));
	  		os.close();
	  	}
	  	
	  } catch (IOException e) {
	  	e.printStackTrace();
	  	return -1;
	  }
  	  	
  	return 0;
  }
98208
def write_data(data, out_file):
    """"""
    with open(out_file, 'w') as handle_out:
        handle_out.write(json.dumps([data], skipkeys=True, indent=2))
919018
def write(path, data, binary=False):
    
    mode = "w"
    if binary:
        mode = "wb"
    with open(path, mode) as f:
        f.write(data)
    f.close()
248770
def write_file(self, blob, dest):
        '''
        
        '''
        with salt.utils.files.fopen(dest, 'wb+') as fp_:
            blob.stream_data(fp_)
517351
function FileWriter (path, opts) {
  if (!(this instanceof FileWriter)) return new FileWriter(path, opts);
  Writer.call(this, opts);
  this.path = path;
  this.file = fs.createWriteStream(path, opts);
  this.pipe(this.file);
  this.on('header', this._onHeader);
}
90181
def write(self):
        
        writer = csv.writer(self.file)

        for f, b in zip(self.gb.result["forward"], self.gb.result["backward"]):
            f = f._asdict()
            b = b._asdict()
            if not self.check_same(f, b):
                raise AssertionError()

            args_info = ", ".join(["{}: {}".format(k, v)
                                   for k, v in f["args_info"]])

            out = [f["parameter_scope"], f["function_name"], f["inputs_shape"], args_info,
                   f["mean_time"], b["mean_time"], f["n_run"], b["n_run"]]

            writer.writerow(out)

        writer.writerow([])
        writer.writerow(["forward all", self.gb.result["forward_all"]])
        writer.writerow(
            ["forward_all_n_run", self.gb.result["n_run_forward_all"]])

        writer.writerow([])
        writer.writerow(["backward all", self.gb.result["backward_all"]])
        writer.writerow(
            ["backward_all_n_run", self.gb.result["n_run_backward_all"]])

        if set(self.gb.result.keys()) >= {"training", "n_run_training"}:
            writer.writerow([])
            writer.writerow(
                ["training(forward + backward + update)", self.gb.result["training"]])
            writer.writerow(
                ["training_n_run", self.gb.result["n_run_training"]])
251267
function writeBuffer() {
      fs.write(fd, buff, 0, buff.length, 0, function (error) {
        fs.close(fd);

        callback(error);
      });
    }
1019624
function fsWrite(fd, buffer, position, callback) {
  var offset = 0,
      length = buffer.length;

  function writeChunk() {
    fs.write(fd, buffer, offset, length - offset, position, function (err, bytesWritten) {
      if (err) { callback(err); return; }
      offset += bytesWritten;
      if (offset < length) {
        writeChunk();
        return;
      }
      callback();
    });
  }
  writeChunk();
}
1137668
def _writen(fd, data):
    """"""
    while data:
        n = os.write(fd, data)
        data = data[n:]
866167
def write(self, arg, **kwargs):
        """"""
        if hasattr(arg, 'seek'):
            self._tofile(arg, **kwargs)
        else:
            with open(arg, 'wb') as fid:
                self._tofile(fid, **kwargs)
757308
function write(filepath, contents) {
  return mkdirp(path.dirname(filepath)).then(() => {
    return writeFile(filepath, contents);
  });
}
944528
def write_file(path, data, mode='w'):  # type: (str, str, str) -> None
    
    with open(path, mode) as f:
        f.write(data)
1140711
def write_command(cls, writer, name, buffers=()):
        
        assert len(name) < 256

        body_len = len(name) + 1 + sum(len(buffer) for buffer in buffers)

        if body_len < 256:
            writer.write(struct.pack('!BBB', 0x04, body_len, len(name)))
        else:
            writer.write(struct.pack('!BQB', 0x06, body_len, len(name)))

        writer.write(name)

        for buffer in buffers:
            writer.write(buffer)
423060
@Override
    public final void write(final byte[] b) throws IOException {
        file.write(b);
        counter = counter + b.length;
    }
1187777
def _build_file_writer(cls, session: AppSession):
        '''
        '''
        args = session.args

        if args.delete_after:
            return session.factory.new('FileWriter')  # is a NullWriter

        elif args.output_document:
            session.factory.class_map['FileWriter'] = SingleDocumentWriter
            return session.factory.new('FileWriter', args.output_document,
                                       headers_included=args.save_headers)

        use_dir = (len(args.urls) != 1 or args.page_requisites
                   or args.recursive)

        if args.use_directories == 'force':
            use_dir = True
        elif args.use_directories == 'no':
            use_dir = False

        os_type = 'windows' if 'windows' in args.restrict_file_names \
            else 'unix'
        ascii_only = 'ascii' in args.restrict_file_names
        no_control = 'nocontrol' not in args.restrict_file_names

        if 'lower' in args.restrict_file_names:
            case = 'lower'
        elif 'upper' in args.restrict_file_names:
            case = 'upper'
        else:
            case = None

        path_namer = session.factory.new(
            'PathNamer',
            args.directory_prefix,
            index=args.default_page,
            use_dir=use_dir,
            cut=args.cut_dirs,
            protocol=args.protocol_directories,
            hostname=args.host_directories,
            os_type=os_type,
            ascii_only=ascii_only,
            no_control=no_control,
            case=case,
            max_filename_length=args.max_filename_length,
        )

        if args.recursive or args.page_requisites or args.continue_download:
            if args.clobber_method == 'disable':
                file_class = OverwriteFileWriter
            else:
                file_class = IgnoreFileWriter
        elif args.timestamping:
            file_class = TimestampingFileWriter
        else:
            file_class = AntiClobberFileWriter

        session.factory.class_map['FileWriter'] = file_class

        return session.factory.new(
            'FileWriter',
            path_namer,
            file_continuing=args.continue_download,
            headers_included=args.save_headers,
            local_timestamping=args.use_server_timestamps,
            adjust_extension=args.adjust_extension,
            content_disposition=args.content_disposition,
            trust_server_names=args.trust_server_names,
        )
589704
def write(self, data):
        """"""

        if len(data) > self.data_size:
            raise ValueError

        self.__fileobj.seek(self.data_offset)
        self.__fileobj.write(data)