def METHOD_NAME(self, tokensource, outfile):
    if self.linenos:
        self._write_lineno(outfile)
    for ttype, value in tokensource:
        color = self._get_color(ttype)
        for line in value.splitlines(True):
            if color:
                outfile.write(ansiformat(color, line.rstrip('\n')))
            else:
                outfile.write(line.rstrip('\n'))
            if line.endswith('\n'):
                if self.linenos:
                    self._write_lineno(outfile)
                else:
                    outfile.write('\n')
    if self.linenos:
        outfile.write("\n")