home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
-
- def apply_filters(stream, filters, lexer = None):
-
- def _apply(filter_, stream):
- for token in filter_.filter(lexer, stream):
- yield token
-
-
- for filter_ in filters:
- stream = _apply(filter_, stream)
-
- return stream
-
-
- def simplefilter(f):
- return type(f.__name__, (FunctionFilter,), {
- 'function': f,
- '__module__': getattr(f, '__module__'),
- '__doc__': f.__doc__ })
-
-
- class Filter(object):
-
- def __init__(self, **options):
- self.options = options
-
-
- def filter(self, lexer, stream):
- raise NotImplementedError()
-
-
-
- class FunctionFilter(Filter):
- function = None
-
- def __init__(self, **options):
- if not hasattr(self, 'function'):
- raise TypeError('%r used without bound function' % self.__class__.__name__)
- hasattr(self, 'function')
- Filter.__init__(self, **options)
-
-
- def filter(self, lexer, stream):
- for ttype, value in self.function(lexer, stream, self.options):
- yield (ttype, value)
-
-
-
-