1998-09-14 12:46:15 -03:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
"Replace LF with CRLF in argument files. Print names of changed files."
|
|
|
|
|
2000-02-14 17:42:14 -04:00
|
|
|
import sys, re, os
|
2003-05-13 14:09:01 -03:00
|
|
|
for filename in sys.argv[1:]:
|
|
|
|
if os.path.isdir(filename):
|
|
|
|
print filename, "Directory!"
|
1998-09-14 12:56:40 -03:00
|
|
|
continue
|
2003-05-13 14:09:01 -03:00
|
|
|
data = open(filename, "rb").read()
|
1998-09-14 12:46:15 -03:00
|
|
|
if '\0' in data:
|
2003-05-13 14:09:01 -03:00
|
|
|
print filename, "Binary!"
|
1998-09-14 12:56:40 -03:00
|
|
|
continue
|
2000-02-14 17:42:14 -04:00
|
|
|
newdata = re.sub("\r?\n", "\r\n", data)
|
1998-09-14 12:46:15 -03:00
|
|
|
if newdata != data:
|
2003-05-13 14:09:01 -03:00
|
|
|
print filename
|
|
|
|
f = open(filename, "wb")
|
1998-09-14 12:56:40 -03:00
|
|
|
f.write(newdata)
|
|
|
|
f.close()
|