Limnoria/scripts/removeSpaces.py
James Vega c803e5e9d8 Added vim:set ... : strings to source in order to keep file formatting
consistent between developers. Jeremy should be adding the equivalent
settings for emacs soon.
2003-03-24 08:41:19 +00:00

36 lines
905 B
Python
Executable File

#!/usr/bin/env python
import os
import os.path
class MutableX:
def __init__(self):
self.x = None
def visit(bytesRemoved, dirname, names):
filenames = [os.path.join(dirname, s) for s in names if s.endswith('.py')]
for filename in filenames:
tmpname = filename + '.tmp'
tmpfd = file(tmpname, 'w')
fd = file(filename, 'r')
for line in fd:
stripped = line.rstrip()
bytesRemoved.x += len(line) - len(stripped)
tmpfd.write(stripped)
tmpfd.write('\n')
fd.close()
tmpfd.close()
os.rename(tmpname, filename)
if __name__ == '__main__':
import sys
if len(sys.argv) < 2:
dir = '.'
else:
dir = sys.argv[1]
x = MutableX()
x.x = 0
os.path.walk(dir, visit, x)
print '%s bytes removed.' % x.x
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: