<s> """<STR_LIT>""" <EOL> from pygments . formatter import Formatter <EOL> from pygments . util import get_choice_opt <EOL> from pygments . token import Token <EOL> from pygments . console import colorize <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class NullFormatter ( Formatter ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> aliases = [ '<STR_LIT:text>' , '<STR_LIT:null>' ] <EOL> filenames = [ '<STR_LIT>' ] <EOL> def format ( self , tokensource , outfile ) : <EOL> enc = self . encoding <EOL> for ttype , value in tokensource : <EOL> if enc : <EOL> outfile . write ( value . encode ( enc ) ) <EOL> else : <EOL> outfile . write ( value ) <EOL> class RawTokenFormatter ( Formatter ) : <EOL> r"""<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> aliases = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> filenames = [ '<STR_LIT>' ] <EOL> unicodeoutput = False <EOL> def __init__ ( self , ** options ) : <EOL> Formatter . __init__ ( self , ** options ) <EOL> self . compress = get_choice_opt ( options , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT:none>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . error_color = options . get ( '<STR_LIT>' , None ) <EOL> if self . error_color is True : <EOL> self . error_color = '<STR_LIT>' <EOL> if self . error_color is not None : <EOL> try : <EOL> colorize ( self . error_color , '<STR_LIT>' ) <EOL> except KeyError : <EOL> raise ValueError ( "<STR_LIT>" % <EOL> self . error_color ) <EOL> def format ( self , tokensource , outfile ) : <EOL> if self . compress == '<STR_LIT>' : <EOL> import gzip <EOL> outfile = gzip . GzipFile ( '<STR_LIT>' , '<STR_LIT:wb>' , <NUM_LIT:9> , outfile ) <EOL> write = outfile . write <EOL> flush = outfile . flush <EOL> elif self . compress == '<STR_LIT>' : <EOL> import bz2 <EOL> compressor = bz2 . BZ2Compressor ( <NUM_LIT:9> ) <EOL> def write ( text ) : <EOL> outfile . write ( compressor . compress ( text ) ) <EOL> def flush ( ) : <EOL> outfile . write ( compressor . flush ( ) ) <EOL> outfile . flush ( ) <EOL> else : <EOL> write = outfile . write <EOL> flush = outfile . flush <EOL> lasttype = None <EOL> lastval = u'<STR_LIT>' <EOL> if self . error_color : <EOL> for ttype , value in tokensource : <EOL> line = "<STR_LIT>" % ( ttype , value ) <EOL> if ttype is Token . Error : <EOL> write ( colorize ( self . error_color , line ) ) <EOL> else : <EOL> write ( line ) <EOL> else : <EOL> for ttype , value in tokensource : <EOL> write ( "<STR_LIT>" % ( ttype , value ) ) <EOL> flush ( ) </s>
