From 296443137f4288cb030e92859ccfbe3204bc1088 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Tue, 17 Mar 2020 14:55:41 +0530 Subject: initial commit --- lib/python2.7/Tools/scripts/lfcr.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/python2.7/Tools/scripts/lfcr.py (limited to 'lib/python2.7/Tools/scripts/lfcr.py') 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() -- cgit