From 400be92006f97f7d18dfccd358d728a0d719839d Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 4 Oct 2014 22:00:09 +0200 Subject: debug_lexer: fix byte/str confusion for Py3 and print usage if no args given. --- scripts/debug_lexer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') 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)) -- cgit v1.2.1