1998-09-14 17:46:41 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
"Replace CRLF with LF in argument files. Print names of changed files."
|
|
|
|
|
2002-11-13 22:04:31 +01:00
|
|
|
import sys, os
|
2003-05-13 16:51:39 +02:00
|
|
|
for filename in sys.argv[1:]:
|
|
|
|
if os.path.isdir(filename):
|
|
|
|
print filename, "Directory!"
|
1998-09-14 17:46:41 +02:00
|
|
|
continue
|
2003-05-13 16:51:39 +02:00
|
|
|
data = open(filename, "rb").read()
|
1998-09-14 17:46:41 +02:00
|
|
|
if '\0' in data:
|
2003-05-13 16:51:39 +02:00
|
|
|
print filename, "Binary!"
|
1998-09-14 17:46:41 +02:00
|
|
|
continue
|
2002-11-13 22:04:31 +01:00
|
|
|
newdata = data.replace("\r\n", "\n")
|
1998-09-14 17:46:41 +02:00
|
|
|
if newdata != data:
|
2003-05-13 16:51:39 +02:00
|
|
|
print filename
|
|
|
|
f = open(filename, "wb")
|
1998-09-14 17:46:41 +02:00
|
|
|
f.write(newdata)
|
|
|
|
f.close()
|