~ubuntu-branches/ubuntu/raring/wxwidgets2.8/raring

« back to all changes in this revision

Viewing changes to wxPython/wx/tools/Editra/src/extern/pygments/lexers/special.py

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2012-01-07 13:59:25 UTC
  • mfrom: (1.1.9) (5.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20120107135925-2601miy9ullcon9j
Tags: 2.8.12.1-6ubuntu1
* Resync from Debian, changes that were kept:
  - debian/rules: re-enable mediactrl. This allows libwx_gtk2u_media-2.8 to be
    built, as this is required by some applications (LP: #632984)
  - debian/control: Build-dep on libxt-dev for mediactrl.
  - Patches
    + fix-bashism-in-example
* Add conflict on python-wxgtk2.8 (<< 2.8.12.1-6ubuntu1~) to python-wxversion
  to guarantee upgrade ordering when moving from pycentral to dh_python2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
    Special lexers.
7
7
 
8
 
    :copyright: 2006-2007 by Georg Brandl.
9
 
    :license: BSD, see LICENSE for more details.
 
8
    :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS.
 
9
    :license: BSD, see LICENSE for details.
10
10
"""
11
11
 
12
12
import re
14
14
 
15
15
from pygments.lexer import Lexer
16
16
from pygments.token import Token, Error, Text
17
 
from pygments.util import get_choice_opt
 
17
from pygments.util import get_choice_opt, b
18
18
 
19
19
 
20
20
__all__ = ['TextLexer', 'RawTokenLexer']
35
35
 
36
36
_ttype_cache = {}
37
37
 
38
 
line_re = re.compile('.*?\n')
 
38
line_re = re.compile(b('.*?\n'))
39
39
 
40
40
class RawTokenLexer(Lexer):
41
41
    """
60
60
        Lexer.__init__(self, **options)
61
61
 
62
62
    def get_tokens(self, text):
 
63
        if isinstance(text, unicode):
 
64
            # raw token stream never has any non-ASCII characters
 
65
            text = text.encode('ascii')
63
66
        if self.compress == 'gz':
64
67
            import gzip
65
68
            gzipfile = gzip.GzipFile('', 'rb', 9, cStringIO.StringIO(text))
70
73
 
71
74
        # do not call Lexer.get_tokens() because we do not want Unicode
72
75
        # decoding to occur, and stripping is not optional.
73
 
        text = text.strip('\n') + '\n'
 
76
        text = text.strip(b('\n')) + b('\n')
74
77
        for i, t, v in self.get_tokens_unprocessed(text):
75
78
            yield t, v
76
79
 
78
81
        length = 0
79
82
        for match in line_re.finditer(text):
80
83
            try:
81
 
                ttypestr, val = match.group().split('\t', 1)
 
84
                ttypestr, val = match.group().split(b('\t'), 1)
82
85
            except ValueError:
83
86
                val = match.group().decode(self.encoding)
84
87
                ttype = Error