summaryrefslogtreecommitdiff
path: root/lib/python2.7/Tools/scripts/lfcr.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python2.7/Tools/scripts/lfcr.py')
-rw-r--r--lib/python2.7/Tools/scripts/lfcr.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/python2.7/Tools/scripts/lfcr.py b/lib/python2.7/Tools/scripts/lfcr.py
new file mode 100644
index 0000000..1f19da6
--- /dev/null
+++ b/lib/python2.7/Tools/scripts/lfcr.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python2
+
+"Replace LF with CRLF in argument files. Print names of changed files."
+
+import sys, re, os
+
+def main():
+ for filename in sys.argv[1:]:
+ if os.path.isdir(filename):
+ print filename, "Directory!"
+ continue
+ data = open(filename, "rb").read()
+ if '\0' in data:
+ print filename, "Binary!"
+ continue
+ newdata = re.sub("\r?\n", "\r\n", data)
+ if newdata != data:
+ print filename
+ f = open(filename, "wb")
+ f.write(newdata)
+ f.close()
+
+if __name__ == '__main__':
+ main()