ThirdParty/Pygments/pygments/filter.py

changeset 4697
c2e9bf425554
parent 4172
4f20dba37ab6
child 5713
6762afd9f963
equal deleted inserted replaced
4696:bf4d19a7cade 4697:c2e9bf425554
3 pygments.filter 3 pygments.filter
4 ~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~
5 5
6 Module that implements the default filter. 6 Module that implements the default filter.
7 7
8 :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 12
13 def apply_filters(stream, filters, lexer=None): 13 def apply_filters(stream, filters, lexer=None):
27 def simplefilter(f): 27 def simplefilter(f):
28 """ 28 """
29 Decorator that converts a function into a filter:: 29 Decorator that converts a function into a filter::
30 30
31 @simplefilter 31 @simplefilter
32 def lowercase(lexer, stream, options): 32 def lowercase(self, lexer, stream, options):
33 for ttype, value in stream: 33 for ttype, value in stream:
34 yield ttype, value.lower() 34 yield ttype, value.lower()
35 """ 35 """
36 return type(f.__name__, (FunctionFilter,), { 36 return type(f.__name__, (FunctionFilter,), {
37 'function': f, 37 'function': f,
67 raise TypeError('%r used without bound function' % 67 raise TypeError('%r used without bound function' %
68 self.__class__.__name__) 68 self.__class__.__name__)
69 Filter.__init__(self, **options) 69 Filter.__init__(self, **options)
70 70
71 def filter(self, lexer, stream): 71 def filter(self, lexer, stream):
72 # pylint: disable-msg=E1102 72 # pylint: disable=not-callable
73 for ttype, value in self.function(lexer, stream, self.options): 73 for ttype, value in self.function(lexer, stream, self.options):
74 yield ttype, value 74 yield ttype, value

eric ide

mercurial