diff --git a/vigil b/vigil index 77b55a0..72fbf2f 100755 --- a/vigil +++ b/vigil @@ -1,5 +1,8 @@ #!/usr/bin/env python +from __future__ import print_function +from builtins import filter +from builtins import range import re import sys import traceback @@ -33,7 +36,7 @@ def punish(line, offense): # Clear the lines, but don't delete them. That way later failures will # have the right line number. - for i in xrange(start, end + 1): + for i in range(start, end): source_lines[i] = '' def vigil_implore(ok, expr): @@ -53,27 +56,27 @@ def vigil_done(): return # Strip out the dirty impure lines. - cleansed = filter(len, source_lines) + cleansed = list(filter(len, source_lines)) with open(source_path, 'w') as f: f.writelines(cleansed) - print "" - print "" - print "------------------------------------------------------------------" - print "" - print "The ever vigilant watchers of your code have found malfeasance in:" - print "" + print("") + print("") + print("------------------------------------------------------------------") + print("") + print("The ever vigilant watchers of your code have found malfeasance in:") + print("") for fn, offense, _ in offenders: - print fn - print "Crime:", offense - print "" + print(fn) + print("Crime:", offense) + print("") - print "Each has been dealt an appropriate punishment." + print("Each has been dealt an appropriate punishment.") def vigil_uncaught(): raise_line = traceback.extract_tb(sys.exc_info()[2])[-1][1] - print "uncaught error from line ", raise_line + print("uncaught error from line ", raise_line) punish(raise_line, "Raised '%s' which was not caught." % sys.exc_info()[1]) try: