blob: 58181854016bc7115057d639e8f2a8e3e486ac0f [file] [log] [blame]
Guido van Rossum09eea821998-09-14 15:46:41 +00001#! /usr/bin/env python
2
3"Replace CRLF with LF in argument files. Print names of changed files."
4
Guido van Rossum967e5092000-02-14 21:42:14 +00005import sys, re, os
Guido van Rossum09eea821998-09-14 15:46:41 +00006for file in sys.argv[1:]:
7 if os.path.isdir(file):
8 print file, "Directory!"
9 continue
10 data = open(file, "rb").read()
11 if '\0' in data:
12 print file, "Binary!"
13 continue
Guido van Rossum967e5092000-02-14 21:42:14 +000014 newdata = re.sub("\r\n", "\n", data)
Guido van Rossum09eea821998-09-14 15:46:41 +000015 if newdata != data:
16 print file
17 f = open(file, "wb")
18 f.write(newdata)
19 f.close()