diff options
Diffstat (limited to 'contrib/scripts/removetrailingwhitespace.py.in')
-rwxr-xr-x | contrib/scripts/removetrailingwhitespace.py.in | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/contrib/scripts/removetrailingwhitespace.py.in b/contrib/scripts/removetrailingwhitespace.py.in new file mode 100755 index 000000000..5824fb591 --- /dev/null +++ b/contrib/scripts/removetrailingwhitespace.py.in | |||
@@ -0,0 +1,15 @@ | |||
1 | #!@PYTHON@ | ||
2 | |||
3 | import sys | ||
4 | import re | ||
5 | |||
6 | |||
7 | for fileName in sys.argv[1:]: | ||
8 | f = open(fileName, 'r+') | ||
9 | fileString = f.read() | ||
10 | |||
11 | fileString = re.sub(r'[ ]+\n', r'\n', fileString) | ||
12 | fileString = re.sub(r'\r', r'', fileString) | ||
13 | f.seek(0) | ||
14 | f.write(fileString) | ||
15 | f.truncate(len(fileString)) | ||