Write text to a file.
515638
def write_file(filename, text):
    """"""
    logging.debug(_('Writing file: %s'), filename)
    try:
        with open(filename, 'w') as writable:
            writable.write(text)
    except (PermissionError, NotADirectoryError):
        logging.error(_('Error writing file: %s'), filename)
        return False
    return True
1189577
def write_text(filename, tracklisting):
    """"""
    print("Saving text file.")
    try:
        write_listing_to_textfile(filename + '.txt', tracklisting)
    except IOError:
        # if all else fails, just print listing
        print("Cannot write text file to path: {}".format(filename))
        print("Printing tracklisting here instead.")
        # ignoring errors is a hack to cope with Windows not dealing well
        # with UTF-8
        print(tracklisting.encode(sys.stdout.encoding, errors='ignore'))
1187198
def write_file(self, new_text, filename, old_text, encoding=None):
        
        try:
            f = _open_with_encoding(filename, "w", encoding=encoding)
        except os.error as err:
            self.log_error("Can't create %s: %s", filename, err)
            return
        try:
            f.write(_to_system_newlines(new_text))
        except os.error as err:
            self.log_error("Can't write %s: %s", filename, err)
        finally:
            f.close()
        self.log_debug("Wrote changes to %s", filename)
        self.wrote = True
1216408
def write_input_to_file(self, fname='ace_input.txt'):
        """"""
        self._write_columns(fname, self.x, self.y)
1075777
def _write_file(folder, filename, data):
    '''
    
    '''
    path = os.path.join(folder, filename)
    if not os.path.exists(folder):
        msg = '{0} cannot be written. {1} does not exist'.format(filename, folder)
        log.error(msg)
        raise AttributeError(six.text_type(msg))
    with salt.utils.files.fopen(path, 'w') as fp_:
        fp_.write(salt.utils.stringutils.to_str(data))

    return 0
563443
def write(self, content):
        """"""
        with io.open(self.target, 'w', encoding='utf-8') as fp:
            fp.write(content)
            if not content.endswith(u'\n'):
                fp.write(u'\n')
989045
def _write(self, to_write):
        
        self._file.write(to_write.encode(self._encoding or
                                         self._default_encoding))
191155
def write(self, data):
        """"""
        data = data.encode('utf-8')
        data_p = ctypes.create_string_buffer(data)
        num_bytes = PLARGE_INTEGER(LARGE_INTEGER(0))
        bytes_to_write = len(data)
        success = WriteFile(self.conin_pipe, data_p,
                            bytes_to_write, num_bytes, None)
        return success, num_bytes[0]
588369
def simple_write(filename, group, times, features,
                 properties=None, item='item', mode='a'):
    """"""
    write(filename, group, [item], [times], [features], mode=mode,
          properties=[properties] if properties is not None else None)
1272243
def write_file(name, text, opts):
    """"""
    fname = path.join(opts.destdir, '%s.%s' % (name, opts.suffix))
    if opts.dryrun:
        print 'Would create file %s.' % fname
        return
    if not opts.force and path.isfile(fname):
        print 'File %s already exists, skipping.' % fname
    else:
        print 'Creating file %s.' % fname
        f = open(fname, 'w')
        try:
            f.write(text)
        finally:
            f.close()
318166
def save_file(self, filename, text):
        """"""
        if not filename.endswith('.py'):
            filename += '.py'
        path = os.path.join(self.currentpath, filename)
        with open(path, 'w', encoding="utf-8") as file_:
            file_.write(text)
437298
def write_file(writer, filename):
  """"""
  for line in txt_line_iterator(filename):
    writer.write(line)
    writer.write("\n")
637603
public static void writeText(String text, File output) {
        PrintWriter pw = null;
        try {
            pw = new PrintWriter(new FileWriter(output));
            pw.write(text);
        } catch (Exception e) {
            throw new MockitoException("Problems writing text to file: " + output, e);
        } finally {
            close(pw);
        }
    }
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)
1049068
def dump(self, **kwargs):
    """"""

    f = io.StringIO()
    w = Writer(f, self.keys, **kwargs)
    w.write(self)
    text = f.getvalue().lstrip()
    f.close()

    return text
591748
def append_to_file(file_name, line_data):
    """"""
    with open(file_name, mode='a', encoding='utf-8') as f1:
        f1.write(line_data)
        f1.write("\n")
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