home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __version__ = '1.3.1'
- __docformat__ = 'restructuredtext'
- __all__ = [
- 'lex',
- 'format',
- 'highlight']
- import sys
- from pygments.util import StringIO, BytesIO
-
- def lex(code, lexer):
-
- try:
- return lexer.get_tokens(code)
- except TypeError:
- err = None
- if isinstance(err.args[0], str) and 'unbound method get_tokens' in err.args[0]:
- raise TypeError('lex() argument must be a lexer instance, not a class')
- 'unbound method get_tokens' in err.args[0]
- raise
-
-
-
- def format(tokens, formatter, outfile = None):
-
- try:
- if not outfile:
- if not formatter.encoding or BytesIO():
- pass
- realoutfile = StringIO()
- formatter.format(tokens, realoutfile)
- return realoutfile.getvalue()
- formatter.format(tokens, outfile)
- except TypeError:
- err = None
- if isinstance(err.args[0], str) and 'unbound method format' in err.args[0]:
- raise TypeError('format() argument must be a formatter instance, not a class')
- 'unbound method format' in err.args[0]
- raise
-
-
-
- def highlight(code, lexer, formatter, outfile = None):
- return format(lex(code, lexer), formatter, outfile)
-
- if __name__ == '__main__':
- from pygments.cmdline import main
- sys.exit(main(sys.argv))
-
-