Given a GTFSR feed (FeedMessage instance), write it to the given
    file path (string or Path object).
    If ``to_json``, then save the file as JSON;
    otherwise save it as Protocol Buffer.
160201
def write_gtfsr(feed, path, *, to_json=False):
    
    path = Path(path)

    if to_json:
        with path.open('w') as tgt:
            tgt.write(json_format.MessageToJson(feed))
    else:
        with path.open('wb') as tgt:
            tgt.write(feed.SerializeToString())
777613
def save_blob_as_json(filename, blob, force_write, debug):
    
    try:
        if prompt_4_overwrite(filename, force_write):
            with open(filename, 'wt') as f:
                print('%s' % json.dumps(blob, indent=4 if debug else None, separators=(',', ': '), sort_keys=True, cls=CustomJSONEncoder), file=f)
    except Exception as e:
        printException(e)
        pass
58590
public void writeToFile(String path) {
        try {
            try (OutputStream os = new FileOutputStream(path)) {
                InputStreams.transferTo(body(), os);
            }
        } catch (IOException e) {
            throw new RequestsException(e);
        } finally {
            close();
        }
    }
892936
def WriteFileEntry(self, path):
    
    string = '{0:s}\n'.format(path)

    encoded_string = self._EncodeString(string)
    self._file_object.write(encoded_string)
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)
91293
def _save_json(self, filename):
        """"""
        with open(filename, 'w') as file_handle:
            json.dump(self._sensors, file_handle, cls=MySensorsJSONEncoder,
                      indent=4)
            file_handle.flush()
            os.fsync(file_handle.fileno())
1029465
def save_json(self, frames):
        
        if self.json_save_path is None: return
        path = os.path.join(self.json_save_path, '%s.json' % self.id)
        if not os.path.isdir(self.json_save_path):
            os.mkdir(self.json_save_path)
        with open(path, 'w') as f:
            json.dump(frames, f)
        self.json_data = frames
119539
def save_file_data(self, path):
        
        try:
            # just create file with empty text first; this command also creates the whole path to the file
            filesystem.write_file(os.path.join(path, storage.SCRIPT_FILE), "", create_full_path=True)
            storage_utils.write_dict_to_json(self.model.state.semantic_data, os.path.join(path, storage.SEMANTIC_DATA_FILE))
        except IOError as e:
            # Only happens if the file doesnt exist yet and would be written to the temp folder.
            # The method write_file doesn't create the path
            logger.error('The operating system raised an error: {}'.format(e))
549123
def WriteToPath(obj, filepath):
  
  with io.open(filepath, mode="w", encoding="utf-8") as filedesc:
    WriteToFile(obj, filedesc)
1076738
def _write_json(filepath, data, kwargs):
    """"""
    with io_stl.open(filepath, 'w', encoding='utf8') as outfile:
        if 'indent' not in kwargs:
            kwargs['indent'] = 4
        if 'sort_keys' not in kwargs:
            kwargs['sort_keys'] = True
        if 'separators' not in kwargs:
            kwargs['separators'] = (',', ': ')
        if 'ensure_ascii' not in kwargs:
            kwargs['ensure_ascii'] = False
        str_ = json.dumps(data, **kwargs)
        outfile.write(to_unicode(str_))
    return data
1024809
function writeFile(filepath, data, options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = {};
  }

  if (!Buffer.isBuffer(data)) {
    return callback(new TypeError('Data must be a Buffer'));
  }

  if (!options) {
    options = {};
  }

  // Default the same as node
  var mode = options.mode || constants.DEFAULT_FILE_MODE;
  var flags = options.flags || 'w';
  var position = APPEND_MODE_REGEXP.test(flags) ? null : 0;

  fs.open(filepath, flags, mode, onOpen);

  function onOpen(openErr, fd) {
    if (openErr) {
      return onComplete(openErr);
    }

    fs.write(fd, data, 0, data.length, position, onComplete);

    function onComplete(writeErr) {
      callback(writeErr, fd);
    }
  }
}
1257465
def serialize(path, data)
      # Make a path to the data file if one doesn't already exist
      mkpath_to path

      File.open(path, "w") do |f|
        f.puts data.to_json
      end
    end
142222
function rJson(path, callback) {

    if (typeof callback === "function") {
        Fs.readFile(path, "utf-8", function (err, data) {
            try {
                data = JSON.parse(data);
            } catch (e) {
                err = err || e;
            }
            callback(err, data);
        });
        return;
    }

    return JSON.parse(Fs.readFileSync(path));
}
389270
def _write_to_command_buffer(self, to_write):
        
        # TODO(mitch): Handle the edge case of writing too much data to the buffer.
        np.copyto(self._command_bool_ptr, True)
        to_write += '0'  # The gason JSON parser in holodeck expects a 0 at the end of the file.
        input_bytes = str.encode(to_write)
        for index, val in enumerate(input_bytes):
            self._command_buffer_ptr[index] = val
89159
function __save(filename, content, json){
  json = json === true

  if (json) {
    fs.writeFileSync(filename, JSON.stringify(content))
  } else {
    fs.writeFileSync(filename, content)
  }
}
917958
def dump(self, content, filepath, indent=4):
        
        with open(filepath, 'w') as fp:
            json.dump(content, fp, indent=indent)
1325709
function _gpfReadWScript (path) {
    return new Promise(function (resolve) {
        var file = _gpfMsFSO.OpenTextFile(path, _GPF_FS_WSCRIPT_READING, false);
        resolve(file.ReadAll());
        file.Close();
    });
}