diff options
author | Georg Brandl <georg@python.org> | 2014-10-07 15:10:22 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-10-07 15:10:22 +0200 |
commit | bee0e0cbaa12bba306d8f5c52c6e749f1eb6ea26 (patch) | |
tree | 81ec18efd2586485bff0fe6ca047e0477affb1f6 /scripts | |
parent | f32c46a5b907553962d68cd7ce637729cd7dd45b (diff) | |
download | pygments-bee0e0cbaa12bba306d8f5c52c6e749f1eb6ea26.tar.gz |
debug_lexer: remove debug print; allow reading from stdin with filename "-"
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/debug_lexer.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/scripts/debug_lexer.py b/scripts/debug_lexer.py index 4d92ebb3..81b9288d 100755 --- a/scripts/debug_lexer.py +++ b/scripts/debug_lexer.py @@ -115,13 +115,16 @@ def main(fn, lexer=None, options={}): debug_lexer = True else: # HACK: ExtendedRegexLexer subclasses will only partially work here. - print(lxcls.__bases__) lxcls.__bases__ = (DebuggingRegexLexer,) debug_lexer = True lx = lxcls(**options) lno = 1 - text = open(fn, 'rb').read().decode('utf-8') + if fn == '-': + text = sys.stdin.read() + else: + with open(fn, 'rb') as fp: + text = fp.read().decode('utf-8') text = text.strip('\n') + '\n' tokens = [] states = [] |