diff options
Diffstat (limited to 'utils/check_sources.py')
-rwxr-xr-x | utils/check_sources.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/utils/check_sources.py b/utils/check_sources.py index 7bbd0a79..6b984ad6 100755 --- a/utils/check_sources.py +++ b/utils/check_sources.py @@ -10,6 +10,7 @@ :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ +from __future__ import print_function import sys, os, re import cStringIO @@ -54,7 +55,7 @@ if sys.version_info < (3, 0): def check_syntax(fn, lines): try: compile(b('').join(lines), fn, "exec") - except SyntaxError, err: + except SyntaxError as err: yield 0, "not compilable: %s" % err @@ -77,9 +78,9 @@ def check_style_and_encoding(fn, lines): yield lno+1, 'using == None/True/False' try: line.decode(encoding) - except UnicodeDecodeError, err: + except UnicodeDecodeError as err: yield lno+1, "not decodable: %s\n Line: %r" % (err, line) - except LookupError, err: + except LookupError as err: yield 0, "unknown encoding: %s" % encoding encoding = 'latin1' @@ -183,7 +184,7 @@ def main(argv): elif len(args) == 1: path = args[0] else: - print args + print(args) parser.error('No more then one path supported') verbose = options.verbose @@ -214,7 +215,7 @@ def main(argv): continue if verbose: - print "Checking %s..." % fn + print("Checking %s..." % fn) try: f = open(fn, 'rb') @@ -222,8 +223,8 @@ def main(argv): lines = list(f) finally: f.close() - except (IOError, OSError), err: - print "%s: cannot open: %s" % (fn, err) + except (IOError, OSError) as err: + print("%s: cannot open: %s" % (fn, err)) num += 1 continue @@ -231,15 +232,15 @@ def main(argv): if not in_check_pkg and checker.only_pkg: continue for lno, msg in checker(fn, lines): - print >>out, "%s:%d: %s" % (fn, lno, msg) + print("%s:%d: %s" % (fn, lno, msg), file=out) num += 1 if verbose: - print + print() if num == 0: - print "No errors found." + print("No errors found.") else: - print out.getvalue().rstrip('\n') - print "%d error%s found." % (num, num > 1 and "s" or "") + print(out.getvalue().rstrip('\n')) + print("%d error%s found." % (num, num > 1 and "s" or "")) return int(num > 0) |