3 pygments.cmdline |
3 pygments.cmdline |
4 ~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Command line interface. |
6 Command line interface. |
7 |
7 |
8 :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 import sys |
11 import sys |
12 import getopt |
12 import getopt |
13 from textwrap import dedent |
13 from textwrap import dedent |
217 if opts.pop('-h', None) is not None: |
217 if opts.pop('-h', None) is not None: |
218 print(usage) |
218 print(usage) |
219 return 0 |
219 return 0 |
220 |
220 |
221 if opts.pop('-V', None) is not None: |
221 if opts.pop('-V', None) is not None: |
222 print('Pygments version %s, (c) 2006-2008 by Georg Brandl.' % __version__) |
222 print('Pygments version %s, (c) 2006-2011 by Georg Brandl.' % __version__) |
223 return 0 |
223 return 0 |
224 |
224 |
225 # handle ``pygmentize -L`` |
225 # handle ``pygmentize -L`` |
226 L_opt = opts.pop('-L', None) |
226 L_opt = opts.pop('-L', None) |
227 if L_opt is not None: |
227 if L_opt is not None: |
406 # use terminal encoding; Python 3's terminals already do that |
406 # use terminal encoding; Python 3's terminals already do that |
407 lexer.encoding = getattr(sys.stdin, 'encoding', |
407 lexer.encoding = getattr(sys.stdin, 'encoding', |
408 None) or 'ascii' |
408 None) or 'ascii' |
409 fmter.encoding = getattr(sys.stdout, 'encoding', |
409 fmter.encoding = getattr(sys.stdout, 'encoding', |
410 None) or 'ascii' |
410 None) or 'ascii' |
|
411 elif not outfn and sys.version_info > (3,): |
|
412 # output to terminal with encoding -> use .buffer |
|
413 outfile = sys.stdout.buffer |
411 |
414 |
412 # ... and do it! |
415 # ... and do it! |
413 try: |
416 try: |
414 # process filters |
417 # process filters |
415 for fname, fopts in F_opts: |
418 for fname, fopts in F_opts: |