def write_lines(self, lines, encoding=None, errors='<STR_LIT:strict>',<EOL>linesep=os.linesep, append=False):
if append:<EOL><INDENT>mode = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>mode = '<STR_LIT:wb>'<EOL><DEDENT>f = self.open(mode)<EOL>try:<EOL><INDENT>for line in lines:<EOL><INDENT>isUnicode = isinstance(line, str)<EOL>if linesep is not None:<EOL><INDENT>if isUnicode:<EOL><INDENT>if line[-<NUM_LIT:2>:] in ('<STR_LIT:\r\n>', '<STR_LIT>'):<EOL><INDENT>line = line[:-<NUM_LIT:2>]<EOL><DEDENT>elif line[-<NUM_LIT:1>:] in ('<STR_LIT:\r>', '<STR_LIT:\n>',<EOL>'<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>line = line[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if line[-<NUM_LIT:2>:] == '<STR_LIT:\r\n>':<EOL><INDENT>line = line[:-<NUM_LIT:2>]<EOL><DEDENT>elif line[-<NUM_LIT:1>:] in ('<STR_LIT:\r>', '<STR_LIT:\n>'):<EOL><INDENT>line = line[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>line += linesep<EOL><DEDENT>if isUnicode:<EOL><INDENT>if encoding is None:<EOL><INDENT>encoding = sys.getdefaultencoding()<EOL><DEDENT>line = line.encode(encoding, errors)<EOL><DEDENT>f.write(line)<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>f.close()<EOL><DEDENT>
r""" Write the given lines of text to this file.

        By default this overwrites any existing file at this path.

        This puts a platform-specific newline sequence on every line.
        See 'linesep' below.

        lines - A list of strings.

        encoding - A Unicode encoding to use.  This applies only if
            'lines' contains any Unicode strings.

        errors - How to handle errors in Unicode encoding.  This
            also applies only to Unicode strings.

        linesep - The desired line-ending.  This line-ending is
            applied to every line.  If a line already has any
            standard line ending ('\r', '\n', '\r\n', u'\x85',
            u'\r\x85', u'\u2028'), that will be stripped off and
            this will be used instead.  The default is os.linesep,
            which is platform-dependent ('\r\n' on Windows, '\n' on
            Unix, etc.)  Specify None to write the lines as-is,
            like file.writelines().

        Use the keyword argument append=True to append lines to the
        file.  The default is to overwrite the file.  Warning:
        When you use this with Unicode data, if the encoding of the
        existing data in the file is different from the encoding
        you specify with the encoding= parameter, the result is
        mixed-encoding data, which can really confuse someone trying
        to read the file later.