Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
MoinMoin.support.pygments.formatters.other.RawTokenFormatter Class Reference
Inheritance diagram for MoinMoin.support.pygments.formatters.other.RawTokenFormatter:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.support.pygments.formatters.other.RawTokenFormatter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def format

Public Attributes

 encoding
 compress
 error_color

Static Public Attributes

string name = 'Raw tokens'
list aliases = ['raw', 'tokens']
list filenames = ['*.raw']
 unicodeoutput = False

Detailed Description

Definition at line 37 of file other.py.


Constructor & Destructor Documentation

Definition at line 62 of file other.py.

00062 
00063     def __init__(self, **options):
00064         Formatter.__init__(self, **options)
00065         if self.encoding:
00066             raise OptionError('the raw formatter does not support the '
00067                               'encoding option')
00068         self.encoding = 'ascii'  # let pygments.format() do the right thing
00069         self.compress = get_choice_opt(options, 'compress',
00070                                        ['', 'none', 'gz', 'bz2'], '')
00071         self.error_color = options.get('error_color', None)
00072         if self.error_color is True:
00073             self.error_color = 'red'
00074         if self.error_color is not None:
00075             try:
00076                 colorize(self.error_color, '')
00077             except KeyError:
00078                 raise ValueError("Invalid color %r specified" %
00079                                  self.error_color)


Member Function Documentation

def MoinMoin.support.pygments.formatters.other.RawTokenFormatter.format (   self,
  tokensource,
  outfile 
)

Definition at line 80 of file other.py.

00080 
00081     def format(self, tokensource, outfile):
00082         try:
00083             outfile.write(b(''))
00084         except TypeError:
00085             raise TypeError('The raw tokens formatter needs a binary '
00086                             'output file')
00087         if self.compress == 'gz':
00088             import gzip
00089             outfile = gzip.GzipFile('', 'wb', 9, outfile)
00090             def write(text):
00091                 outfile.write(text.encode())
00092             flush = outfile.flush
00093         elif self.compress == 'bz2':
00094             import bz2
00095             compressor = bz2.BZ2Compressor(9)
00096             def write(text):
00097                 outfile.write(compressor.compress(text.encode()))
00098             def flush():
00099                 outfile.write(compressor.flush())
00100                 outfile.flush()
00101         else:
00102             def write(text):
00103                 outfile.write(text.encode())
00104             flush = outfile.flush
00105 
00106         lasttype = None
00107         lastval = u''
00108         if self.error_color:
00109             for ttype, value in tokensource:
00110                 line = "%s\t%r\n" % (ttype, value)
00111                 if ttype is Token.Error:
00112                     write(colorize(self.error_color, line))
00113                 else:
00114                     write(line)
00115         else:
00116             for ttype, value in tokensource:
00117                 write("%s\t%r\n" % (ttype, value))
00118         flush()

Here is the call graph for this function:


Member Data Documentation

Definition at line 57 of file other.py.

Definition at line 68 of file other.py.

Definition at line 67 of file other.py.

Definition at line 70 of file other.py.

Definition at line 58 of file other.py.

Definition at line 56 of file other.py.

Definition at line 60 of file other.py.


The documentation for this class was generated from the following file: