diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-29 10:15:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-29 10:15:57 +0000 |
commit | bb4fc4f4007988874f910d4de5492f9629301641 (patch) | |
tree | 3da40481bb661bd72bdb7dda99732326c3543438 /contrib | |
parent | a9fccfb90479597e554f05ed71bf7bdcc7837ca5 (diff) | |
download | gnunet-bb4fc4f4007988874f910d4de5492f9629301641.tar.gz gnunet-bb4fc4f4007988874f910d4de5492f9629301641.zip |
script to remove whitespace at the end of a line
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/removetrailingwhitespace | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/contrib/removetrailingwhitespace b/contrib/removetrailingwhitespace new file mode 100755 index 000000000..9e620cbb2 --- /dev/null +++ b/contrib/removetrailingwhitespace | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/usr/bin/python | ||
2 | |||
3 | import sys | ||
4 | import re | ||
5 | |||
6 | for fileName in sys.argv[1:]: | ||
7 | f = open(fileName, 'r+') | ||
8 | fileString = f.read() | ||
9 | |||
10 | fileString = re.sub(r'[ ]+\n', r'\n', fileString) | ||
11 | fileString = re.sub(r'\r', r'', fileString) | ||
12 | f.seek(0) | ||
13 | f.write(fileString) | ||
14 | f.truncate(len(fileString)) | ||