Write a new copy of the aliases file.  Lines is a list of lines
    as returned by __parse_aliases.
178569
def __write_aliases_file(lines):
    '''
    
    '''
    afn = __get_aliases_filename()
    adir = os.path.dirname(afn)

    out = tempfile.NamedTemporaryFile(dir=adir, delete=False)

    if not __opts__.get('integration.test', False):
        if os.path.isfile(afn):
            afn_st = os.stat(afn)
            os.chmod(out.name, stat.S_IMODE(afn_st.st_mode))
            os.chown(out.name, afn_st.st_uid, afn_st.st_gid)
        else:
            os.chmod(out.name, 0o644)
            os.chown(out.name, 0, 0)

    for (line_alias, line_target, line_comment) in lines:
        if isinstance(line_target, list):
            line_target = ', '.join(line_target)
        if not line_comment:
            line_comment = ''
        if line_alias and line_target:
            write_line = '{0}: {1}{2}\n'.format(
                line_alias, line_target, line_comment
            )
        else:
            write_line = '{0}\n'.format(line_comment)
        if six.PY3:
            write_line = write_line.encode(__salt_system_encoding__)
        out.write(write_line)

    out.close()
    os.rename(out.name, afn)

    # Search $PATH for the newalises command
    newaliases = salt.utils.path.which('newaliases')
    if newaliases is not None:
        __salt__['cmd.run'](newaliases)

    return True
1218692
def write_dict_to_new_file(file_name, localization_key_to_comment):
    
    output_file_descriptor = open_strings_file(file_name, "w")
    for entry_key, entry_comment in sorted(localization_key_to_comment.iteritems(), key=operator.itemgetter(1)):
        write_entry_to_file(output_file_descriptor, entry_comment, entry_key)
        output_file_descriptor.write(u'\n')
    output_file_descriptor.close()
916497
def append_line(filename, **line):
    
    global lock

    data = json.dumps(line, separators=(',', ':')) + '\n'
    with lock:
        with file(filename, 'a') as fp:
            fp.seek(0, SEEK_END)
            fp.write(data)
80560
def copy_all_lines_from_to(inputFile, outputFile):
    """"""
    currentLine = inputFile.readline()
    while currentLine:
        outputFile.write(currentLine)
        currentLine = inputFile.readline()
802890
def lines(self):
        
        # Cache, because this one is reused very often.
        if self._cache.lines is None:
            self._cache.lines = _ImmutableLineList(self.text.split('\n'))

        return self._cache.lines
105888
async def writelines(self, lines, eof = False, buffering = True):
        
        for l in lines:
            await self.write(l, False, buffering)
        if eof:
            await self.write(b'', eof, buffering)
252876
def _write(self, destination: TextIO) -> None:
        
        for line in self.dest_lines:
            destination.write(line + NL)
973347
public static void writeFile( List<String> lines, String filePath ) throws IOException {
        writeFile(lines, new File(filePath));
    }
153751
def gen_lines_from_textfiles(
        files: Iterable[TextIO]) -> Generator[str, None, None]:
    
    for file in files:
        for line in file:
            yield line
995167
def _write_incron_lines(user, lines):
    '''
    
    '''
    if user == 'system':
        ret = {}
        ret['retcode'] = _write_file(_INCRON_SYSTEM_TAB, 'salt', ''.join(lines))
        return ret
    else:
        path = salt.utils.files.mkstemp()
        with salt.utils.files.fopen(path, 'wb') as fp_:
            fp_.writelines(salt.utils.data.encode(lines))
        if __grains__['os_family'] == 'Solaris' and user != "root":
            __salt__['cmd.run']('chown {0} {1}'.format(user, path), python_shell=False)
        ret = __salt__['cmd.run_all'](_get_incron_cmdstr(path), runas=user, python_shell=False)
        os.remove(path)
        return ret
799629
public static void writeFileList(Iterable<File> files, CharSink sink) throws IOException {
    writeUnixLines(FluentIterable.from(files)
        .transform(toAbsolutePathFunction()), sink);
  }
1153953
def spitOutLines(lines, file, expand=False):
    """
    file = _normalizeToFile(file, mode="w", expand=expand)
    try:     file.writelines(lines)
    finally: file.close()
693922
def execute_lines(self, lines):
        
        for line in lines.splitlines():
            stripped_line = line.strip()
            if stripped_line.startswith('#'):
                continue
            self.write(line+os.linesep, flush=True)
            self.execute_command(line+"\n")
            self.flush()
594264
public void write(FileColumn[] columns, List<String[]> lines) throws IOException
    {
        Object contents = getContents(columns, lines);
        if(stream != null && contents instanceof byte[])
        {
            byte[] bytes = (byte[])contents;
            stream.write(bytes);
        }
    }

    /**
     * Close the output file objects.
     */
    public void close()
    {
        try
        {
            // Close the workbook
            if(workbook != null)
                workbook.close();
        }
        catch(Exception e)
        {
        }

        try
        {
            // Flush and close the byte stream
            if(baos != null)
            {
                baos.flush();
                baos.close();
            }
        }
1046266
def writelines(self, lines, fmt):
        
        if isinstance(fmt, basestring):
            fmt = [fmt] * len(lines)
        for f, line in zip(fmt, lines):
            self.writeline(f, line, self.endian)
461636
public static void writeInstances( File targetFile, Collection<Instance> rootInstances ) throws IOException {

		FileDefinition def = new FromInstances().buildFileDefinition( rootInstances, targetFile, false, true );
		ParsingModelIo.saveRelationsFile( def, false, "\n" );
	}
500256
def modified_lines_from_udiff(udiff):
    """"""
    chunks = re.split('\n@@ [^\n]+\n', udiff)[1:]

    line_numbers = re.findall('@@\s[+-]\d+,\d+ \+(\d+)', udiff)
    line_numbers = list(map(int, line_numbers))

    for c, start in zip(chunks, line_numbers):
        ilines = enumerate((line for line in c.splitlines()
                            if not line.startswith('-')),
                           start=start)
        added_lines = [i for i, line in ilines if line.startswith('+')]
        if added_lines:
            yield (added_lines[0], added_lines[-1])