Hi, I use the following script to check newly added trailing whitespaces just before I upload a patch. It uses the same code in the patchbot trailing whitespaces plugin. :-) Just put it into an executable file, say, "check_spaces"
#!/usr/bin/env python import sys import re import os def trailing_whitespace(patches, ignore_empty = True): bad_lines = 0 trailing = re.compile("\\+.*\\s+$") for patch_path in patches: patch = os.path.basename(patch_path) print patch for ix, line in enumerate(open(patch_path)): line = line.strip("\n") m = trailing.match(line) if m: print " %s:%s %s$" % (patch, ix+1, line) if line.strip() == '+' and ignore_empty: pass else: bad_lines += 1 msg = "Trailing whitespace inserted on %s %slines." % (bad_lines, "non-empty " if ignore_empty else "") if bad_lines > 0: print msg else: print "All clear." if __name__ == "__main__": if len(sys.argv) > 1: patch = sys.argv[1] trailing_whitespace(patches=sys.argv[1:]) else: pass -- -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org