eric6/ThirdParty/Pygments/pygments/cmdline.py

changeset 7701
25f42e208e08
parent 7547
21b0534faebc
child 7983
54c5cfbb1e29
equal deleted inserted replaced
7700:a3cf077a8db3 7701:25f42e208e08
3 pygments.cmdline 3 pygments.cmdline
4 ~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~
5 5
6 Command line interface. 6 Command line interface.
7 7
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2020 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 import os 12 import os
13 import sys 13 import sys
230 if opts.pop('-h', None) is not None: 230 if opts.pop('-h', None) is not None:
231 print(usage) 231 print(usage)
232 return 0 232 return 0
233 233
234 if opts.pop('-V', None) is not None: 234 if opts.pop('-V', None) is not None:
235 print('Pygments version %s, (c) 2006-2019 by Georg Brandl.' % __version__) 235 print('Pygments version %s, (c) 2006-2020 by Georg Brandl.' % __version__)
236 return 0 236 return 0
237 237
238 # handle ``pygmentize -L`` 238 # handle ``pygmentize -L``
239 L_opt = opts.pop('-L', None) 239 L_opt = opts.pop('-L', None)
240 if L_opt is not None: 240 if L_opt is not None:
513 lexer = LatexEmbeddedLexer(left, right, lexer) 513 lexer = LatexEmbeddedLexer(left, right, lexer)
514 514
515 # ... and do it! 515 # ... and do it!
516 if '-s' not in opts: 516 if '-s' not in opts:
517 # process whole input as per normal... 517 # process whole input as per normal...
518 highlight(code, lexer, fmter, outfile) 518 try:
519 highlight(code, lexer, fmter, outfile)
520 finally:
521 if outfn:
522 outfile.close()
519 return 0 523 return 0
520 else: 524 else:
521 # line by line processing of stdin (eg: for 'tail -f')... 525 # line by line processing of stdin (eg: for 'tail -f')...
522 try: 526 try:
523 while 1: 527 while 1:
530 if hasattr(outfile, 'flush'): 534 if hasattr(outfile, 'flush'):
531 outfile.flush() 535 outfile.flush()
532 return 0 536 return 0
533 except KeyboardInterrupt: # pragma: no cover 537 except KeyboardInterrupt: # pragma: no cover
534 return 0 538 return 0
539 finally:
540 if outfn:
541 outfile.close()
535 542
536 543
537 def main(args=sys.argv): 544 def main(args=sys.argv):
538 """ 545 """
539 Main command line entry point. 546 Main command line entry point.

eric ide

mercurial