Write a multiline string to a temp file and return the filename.

            data: a multiline string to be written to a file.

           * Note: the result will be the filename as a FilePath object
            (which is a string subclass).
480260
def _tempfile_as_multiline_string(self, data):
        
        filename = FilePath(self.getTmpFilename(self.TmpDir))
        data_file = open(filename,'w')
        data_file.write(data)
        data_file.close()
        return filename
682227
def write_to_temp_file(data, temp_base_name)
      Tempfile.new(temp_base_name, AttachmentMagic.tempfile_path).tap do |tmp|
        tmp.binmode
        tmp.write data
        tmp.close
      end
    end
1318999
def _input_as_multiline_string(self, data):
        
        if data:
            self.Parameters['-infile']\
                .on(super(Clustalw,self)._input_as_multiline_string(data))
        return ''
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'))
289601
def _write_temp(content, suffix):
    ''''''
    with NamedTemporaryFile(mode='w', suffix=suffix, delete=False) as out:
        out.write(content)
        return out.name
722395
def write_file(self, filename, **kwargs):
        
        with zopen(filename, "wt") as f:
            f.write(self.get_string(**kwargs))
688678
def get_temp_filename (content):
    """"""
    # store content in temporary file
    fd, filename = fileutil.get_temp_file(mode='wb', suffix='.doc',
        prefix='lc_')
    try:
        fd.write(content)
    finally:
        fd.close()
    return filename
1345053
def write(self, data):
        '''  '''
        if data == '\n':  # print does this
            return self.stream.write(data)
        else:
            bytes_ = 0
            for line in data.splitlines(True):
                nl = ''
                if line.endswith('\n'):  # mv nl to end:
                    line = line[:-1]
                    nl = '\n'
                bytes_ += self.stream.write(
                                f'{self.start}{line}{self.default}{nl}'
                          ) or 0  # in case None returned (on Windows)
            return bytes_
936747
def writelines(lines, filename, encoding='utf-8', mode='wb'):
    
    return write(os.linesep.join(lines), filename, encoding, mode)
163081
def _write_parameter_file(params):
    
    
    # Get path
    path = os.path.join(get_tempdir(), 'params.txt')
    
    # Define helper function
    def valToStr(val):
        if val in [True, False]:
            return '"%s"' % str(val).lower()
        elif isinstance(val, int):
            return str(val)
        elif isinstance(val, float):
            tmp = str(val)
            if not '.' in tmp:
                tmp += '.0'
            return tmp
        elif isinstance(val, str):
            return '"%s"' % val
    
    # Compile text
    text = ''
    for key in params:
        val = params[key]
        # Make a string of the values
        if isinstance(val, (list, tuple)):
            vals = [valToStr(v) for v in val]
            val_ = ' '.join(vals)
        else:
            val_ = valToStr(val)
        # Create line and add
        line = '(%s %s)' % (key, val_)
        text += line + '\n'
    
    # Write text
    f = open(path, 'wb')
    try:
        f.write(text.encode('utf-8'))
    finally:
        f.close()
    
    # Done
    return path
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")
1008467
def filesfile_string(self):
        """"""
        lines = []
        app = lines.append
        pj = os.path.join

        app(self.input_file.path)                 # Path to the input file
        app(self.output_file.path)                # Path to the output file
        app(pj(self.workdir, self.prefix.idata))  # Prefix for input data
        app(pj(self.workdir, self.prefix.odata))  # Prefix for output data
        app(pj(self.workdir, self.prefix.tdata))  # Prefix for temporary data

        # Paths to the pseudopotential files.
        # Note that here the pseudos **must** be sorted according to znucl.
        # Here we reorder the pseudos if the order is wrong.
        ord_pseudos = []

        znucl = [specie.number for specie in
                 self.input.structure.types_of_specie]

        for z in znucl:
            for p in self.pseudos:
                if p.Z == z:
                    ord_pseudos.append(p)
                    break
            else:
                raise ValueError("Cannot find pseudo with znucl %s in pseudos:\n%s" % (z, self.pseudos))

        for pseudo in ord_pseudos:
            app(pseudo.path)

        return "\n".join(lines)
321012
def write_file(data, outfilename):
    """"""
    if not data:
        return False
    try:
        with open(outfilename, 'w') as outfile:
            for line in data:
                if line:
                    outfile.write(line)
        return True
    except (OSError, IOError) as err:
        sys.stderr.write('An error occurred while writing {0}:\n{1}'
                         .format(outfilename, str(err)))
        return False
696871
def _write_file_network(data, filename, create=False):
    '''
    
    '''
    if not os.path.exists(filename) and not create:
        msg = '{0} cannot be written. {0} does not exist\
                and create is set to False'
        msg = msg.format(filename)
        log.error(msg)
        raise AttributeError(msg)
    with salt.utils.files.flopen(filename, 'w') as fout:
        fout.write(salt.utils.stringutils.to_str(data))
1220663
def write(self, string):
        """"""
        self.make_dir()
        with open(self.path, "w") as f:
            if not string.endswith("\n"):
                return f.write(string + "\n")
            else:
                return f.write(string)
519107
def write_data(self, data):
        
        with open(self.path, "w") as writer:
            writer.write(data)
996006
def _format_data(data):
        # type: (Union[str, IO]) -> Union[Tuple[None, str], Tuple[Optional[str], IO, str]]
        
        if hasattr(data, 'read'):
            data = cast(IO, data)
            data_name = None
            try:
                if data.name[0] != '<' and data.name[-1] != '>':
                    data_name = os.path.basename(data.name)
            except (AttributeError, TypeError):
                pass
            return (data_name, data, "application/octet-stream")
        return (None, cast(str, data))