diff options
author | Guido van Rossum <guido@python.org> | 1998-09-14 15:46:41 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-09-14 15:46:41 (GMT) |
commit | 09eea820050afd4e61dce30d3248efd089bf8400 (patch) | |
tree | 18ffc272256ecf76fa8fffffda537a9ebb1c8e8b /Tools/scripts | |
parent | 499a6e5fd470f9791f791379153d34b27aa71eb4 (diff) | |
download | cpython-09eea820050afd4e61dce30d3248efd089bf8400.zip cpython-09eea820050afd4e61dce30d3248efd089bf8400.tar.gz cpython-09eea820050afd4e61dce30d3248efd089bf8400.tar.bz2 |
Utility to replace CRLF with LF in argument files.
Diffstat (limited to 'Tools/scripts')
-rwxr-xr-x | Tools/scripts/crlf.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Tools/scripts/crlf.py b/Tools/scripts/crlf.py new file mode 100755 index 0000000..3f843fe --- /dev/null +++ b/Tools/scripts/crlf.py @@ -0,0 +1,19 @@ +#! /usr/bin/env python + +"Replace CRLF with LF in argument files. Print names of changed files." + +import sys, regsub, os +for file in sys.argv[1:]: + if os.path.isdir(file): + print file, "Directory!" + continue + data = open(file, "rb").read() + if '\0' in data: + print file, "Binary!" + continue + newdata = regsub.gsub("\r\n", "\n", data) + if newdata != data: + print file + f = open(file, "wb") + f.write(newdata) + f.close() |