summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-10-04 22:00:09 +0200
committerGeorg Brandl <georg@python.org>2014-10-04 22:00:09 +0200
commit400be92006f97f7d18dfccd358d728a0d719839d (patch)
tree1b2d8f314722b97cad6bc474abc69c8dad46dc9c /scripts
parent9533104db3819e45084c7dcaaa7b2be2b7a9b7c0 (diff)
downloadpygments-400be92006f97f7d18dfccd358d728a0d719839d.tar.gz
debug_lexer: fix byte/str confusion for Py3 and print usage if no args given.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/debug_lexer.py8
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))