0
0
mirror of https://github.com/python/cpython.git synced 2024-12-01 03:01:36 +01:00
cpython/Mac/scripts/crlf.py

26 lines
463 B
Python
Raw Normal View History

1994-05-06 16:16:55 +02:00
#! /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()