~ubuntu-branches/ubuntu/oneiric/moin/oneiric-security

« back to all changes in this revision

Viewing changes to MoinMoin/support/pygments/formatters/_mapping.py

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-03-30 12:55:34 UTC
  • mfrom: (0.1.17 sid)
  • Revision ID: james.westby@ubuntu.com-20100330125534-4c2ufc1rok24447l
Tags: 1.9.2-2ubuntu1
* Merge from Debian testing (LP: #521834). Based on work by Stefan Ebner.
  Remaining changes:
 - Remove python-xml from Suggests field, the package isn't anymore in
   sys.path.
 - Demote fckeditor from Recommends to Suggests; the code was previously
   embedded in moin, but it was also disabled, so there's no reason for us
   to pull this in by default currently. Note: This isn't necessary anymore
   but needs a MIR for fckeditor, so postpone dropping this change until
   lucid+1
* debian/rules:
  - Replace hardcoded python2.5 with python* and hardcore python2.6 for ln
* debian/control.in: drop versioned depends on cdbs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
"""
 
3
    pygments.formatters._mapping
 
4
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
5
 
 
6
    Formatter mapping defintions. This file is generated by itself. Everytime
 
7
    you change something on a builtin formatter defintion, run this script from
 
8
    the formatters folder to update it.
 
9
 
 
10
    Do not alter the FORMATTERS dictionary by hand.
 
11
 
 
12
    :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS.
 
13
    :license: BSD, see LICENSE for details.
 
14
"""
 
15
 
 
16
from pygments.util import docstring_headline
 
17
 
 
18
# start
 
19
from pygments.formatters.bbcode import BBCodeFormatter
 
20
from pygments.formatters.html import HtmlFormatter
 
21
from pygments.formatters.img import BmpImageFormatter
 
22
from pygments.formatters.img import GifImageFormatter
 
23
from pygments.formatters.img import ImageFormatter
 
24
from pygments.formatters.img import JpgImageFormatter
 
25
from pygments.formatters.latex import LatexFormatter
 
26
from pygments.formatters.other import NullFormatter
 
27
from pygments.formatters.other import RawTokenFormatter
 
28
from pygments.formatters.rtf import RtfFormatter
 
29
from pygments.formatters.svg import SvgFormatter
 
30
from pygments.formatters.terminal import TerminalFormatter
 
31
from pygments.formatters.terminal256 import Terminal256Formatter
 
32
 
 
33
FORMATTERS = {
 
34
    BBCodeFormatter: ('BBCode', ('bbcode', 'bb'), (), 'Format tokens with BBcodes. These formatting codes are used by many bulletin boards, so you can highlight your sourcecode with pygments before posting it there.'),
 
35
    BmpImageFormatter: ('img_bmp', ('bmp', 'bitmap'), ('*.bmp',), 'Create a bitmap image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
 
36
    GifImageFormatter: ('img_gif', ('gif',), ('*.gif',), 'Create a GIF image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
 
37
    HtmlFormatter: ('HTML', ('html',), ('*.html', '*.htm'), "Format tokens as HTML 4 ``<span>`` tags within a ``<pre>`` tag, wrapped in a ``<div>`` tag. The ``<div>``'s CSS class can be set by the `cssclass` option."),
 
38
    ImageFormatter: ('img', ('img', 'IMG', 'png'), ('*.png',), 'Create a PNG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
 
39
    JpgImageFormatter: ('img_jpg', ('jpg', 'jpeg'), ('*.jpg',), 'Create a JPEG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
 
40
    LatexFormatter: ('LaTeX', ('latex', 'tex'), ('*.tex',), 'Format tokens as LaTeX code. This needs the `fancyvrb` and `color` standard packages.'),
 
41
    NullFormatter: ('Text only', ('text', 'null'), ('*.txt',), 'Output the text unchanged without any formatting.'),
 
42
    RawTokenFormatter: ('Raw tokens', ('raw', 'tokens'), ('*.raw',), 'Format tokens as a raw representation for storing token streams.'),
 
43
    RtfFormatter: ('RTF', ('rtf',), ('*.rtf',), 'Format tokens as RTF markup. This formatter automatically outputs full RTF documents with color information and other useful stuff. Perfect for Copy and Paste into Microsoft\xc2\xae Word\xc2\xae documents.'),
 
44
    SvgFormatter: ('SVG', ('svg',), ('*.svg',), 'Format tokens as an SVG graphics file.  This formatter is still experimental. Each line of code is a ``<text>`` element with explicit ``x`` and ``y`` coordinates containing ``<tspan>`` elements with the individual token styles.'),
 
45
    Terminal256Formatter: ('Terminal256', ('terminal256', 'console256', '256'), (), 'Format tokens with ANSI color sequences, for output in a 256-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly.'),
 
46
    TerminalFormatter: ('Terminal', ('terminal', 'console'), (), 'Format tokens with ANSI color sequences, for output in a text console. Color sequences are terminated at newlines, so that paging the output works correctly.')
 
47
}
 
48
 
 
49
if __name__ == '__main__':
 
50
    import sys
 
51
    import os
 
52
 
 
53
    # lookup formatters
 
54
    found_formatters = []
 
55
    imports = []
 
56
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
 
57
    for filename in os.listdir('.'):
 
58
        if filename.endswith('.py') and not filename.startswith('_'):
 
59
            module_name = 'pygments.formatters.%s' % filename[:-3]
 
60
            print module_name
 
61
            module = __import__(module_name, None, None, [''])
 
62
            for formatter_name in module.__all__:
 
63
                imports.append((module_name, formatter_name))
 
64
                formatter = getattr(module, formatter_name)
 
65
                found_formatters.append(
 
66
                    '%s: %r' % (formatter_name,
 
67
                                (formatter.name,
 
68
                                 tuple(formatter.aliases),
 
69
                                 tuple(formatter.filenames),
 
70
                                 docstring_headline(formatter))))
 
71
    # sort them, that should make the diff files for svn smaller
 
72
    found_formatters.sort()
 
73
    imports.sort()
 
74
 
 
75
    # extract useful sourcecode from this file
 
76
    f = open(__file__)
 
77
    try:
 
78
        content = f.read()
 
79
    finally:
 
80
        f.close()
 
81
    header = content[:content.find('# start')]
 
82
    footer = content[content.find("if __name__ == '__main__':"):]
 
83
 
 
84
    # write new file
 
85
    f = open(__file__, 'w')
 
86
    f.write(header)
 
87
    f.write('# start\n')
 
88
    f.write('\n'.join(['from %s import %s' % imp for imp in imports]))
 
89
    f.write('\n\n')
 
90
    f.write('FORMATTERS = {\n    %s\n}\n\n' % ',\n    '.join(found_formatters))
 
91
    f.write(footer)
 
92
    f.close()