[21/24] New test for inference rule (!real -> !integer & !positive & !zero & .....
[sympy.git] / bin / strip_whitespace
blobda6dc020e3a34577dc636754ddef18278c586798
1 #!/usr/bin/env python
3 def strip_file(filename, write, report):
4 lines = enumerate(open(filename).readlines())
5 if write:
6 f = open(filename, "w")
7 for index, line in lines:
8 if report and line.endswith(" \n"):
9 print "%s, line %s" % (filename, index + 1)
10 if write:
11 f.write(line.rstrip() + "\n")
13 def main():
14 from optparse import OptionParser
15 p = OptionParser("usage: %prog [options] filename")
16 p.add_option("-d", "--dry", action="store_true", dest="dry",
17 help="Do not modify files.")
18 p.add_option("-v", "--verbose", action="store_true", dest="verbose",
19 help="Report all changes.")
20 options, args = p.parse_args()
21 if options.dry:
22 options.verbose = True
23 if len(args) == 1:
24 strip_file(args[0], not options.dry, options.verbose)
25 else:
26 p.print_help()
28 if __name__ == "__main__":
29 main()