Use constructor method calltip only if available
[geany-mirror.git] / scripts / rstrip-whitespace.py
blob523d95099c2c90610b7bd3021e3a523dafa114d5
1 #!/usr/bin/env python
3 import sys
5 filenames = sys.argv[1:]
7 def backup_file (fn):
8 open ("%s~" % fn, "w").write (open (fn, "r").read ())
10 for fn in filenames:
11 #backup_file (fn)
12 contents = open (fn, "r").read ()
13 lines = contents.split ('\n')
14 with open (fn, "w") as fobj:
15 for line in lines:
16 line = line.rstrip ()
17 fobj.write ("%s\n" % line)
18 contents = open (fn, "r").read ()
19 contents.rstrip ()
20 while contents[-1] in " \t\r\n":
21 contents = contents[:-1]
22 open (fn, "w").write ("%s\n" % contents)