blob: f52867a34ea21616af093eee9870f66b9b948379 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#! /usr/local/bin/python
import sys
import os
import string
def main():
args = sys.argv[1:]
if not args:
print 'no files'
sys.exit(1)
for file in args:
print file, '...'
data = open(file, 'r').read()
lines = string.splitfields(data, '\r')
newdata = string.joinfields(lines, '\n')
if newdata != data:
print 'rewriting...'
os.rename(file, file + '~')
open(file, 'w').write(newdata)
print 'done.'
else:
print 'no change.'
main()
|