diff options
author | Georg Brandl <georg@python.org> | 2014-10-04 22:00:09 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-10-04 22:00:09 +0200 |
commit | 400be92006f97f7d18dfccd358d728a0d719839d (patch) | |
tree | 1b2d8f314722b97cad6bc474abc69c8dad46dc9c /scripts | |
parent | 9533104db3819e45084c7dcaaa7b2be2b7a9b7c0 (diff) | |
download | pygments-400be92006f97f7d18dfccd358d728a0d719839d.tar.gz |
debug_lexer: fix byte/str confusion for Py3 and print usage if no args given.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/debug_lexer.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/debug_lexer.py b/scripts/debug_lexer.py index df160931..6164e09a 100755 --- a/scripts/debug_lexer.py +++ b/scripts/debug_lexer.py @@ -116,7 +116,7 @@ def main(fn, lexer=None, options={}): debug_lexer = True lx = lxcls(**options) lno = 1 - text = open(fn, 'U').read().decode('utf-8') + text = open(fn, 'rb').read().decode('utf-8') text = text.strip('\n') + '\n' tokens = [] states = [] @@ -166,8 +166,10 @@ def print_help(): print('''\ Pygments development helper to quickly debug lexers. + scripts/debug_lexer.py [options] file ... + Give one or more filenames to lex them and display possible error tokens -and/or profiling info. Options are: +and/or profiling info. Files are assumed to be encoded in UTF-8. Selecting lexer and options: @@ -216,6 +218,8 @@ if __name__ == '__main__': print_help() sys.exit(0) ret = 0 + if not args: + print_help() for f in args: ret += main(f, lexer, options) sys.exit(bool(ret)) |