git-svn-id: http://webrtc.googlecode.com/svn/trunk@8 4adac7df-926f-26a2-2b94-8c16560cd09d

This commit is contained in:
niklase@google.com
2011-05-30 11:42:35 +00:00
parent 5c61233a88
commit 47bdc463db
10 changed files with 1312 additions and 0 deletions

29
tools/refactoring/trim.py Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env python
import sys
import fileinput
# Defaults
TABSIZE = 4
usage = """
Replaces all TAB characters with %(TABSIZE)d space characters.
In addition, all trailing space characters are removed.
usage: trim file ...
file ... : files are changed in place without taking any backup.
""" % vars()
def main():
if len(sys.argv) == 1:
sys.stderr.write(usage)
sys.exit(2)
# Iterate over the lines of all files listed in sys.argv[1:]
for line in fileinput.input(sys.argv[1:], inplace=True):
line = line.replace('\t',' '*TABSIZE); # replace TABs
line = line.rstrip(None) # remove trailing whitespaces
print line # modify the file
if __name__ == '__main__':
main()