Whitespace normalization.
[python/dscho.git] / Tools / scripts / crlf.py
blob4fb8be36d9a3b8a159a505263410bb4c6d1d7a3c
1 #! /usr/bin/env python
3 "Replace CRLF with LF in argument files. Print names of changed files."
5 import sys, os
6 for filename in sys.argv[1:]:
7 if os.path.isdir(filename):
8 print filename, "Directory!"
9 continue
10 data = open(filename, "rb").read()
11 if '\0' in data:
12 print filename, "Binary!"
13 continue
14 newdata = data.replace("\r\n", "\n")
15 if newdata != data:
16 print filename
17 f = open(filename, "wb")
18 f.write(newdata)
19 f.close()