''' Convert LF line endings to CRLF. ''' import sys from voussoirkit import pipeable from voussoirkit import winglob CR = b'\x0D' LF = b'\x0A' CRLF = CR + LF def crlf(filename): with open(filename, 'rb') as handle: content = handle.read() content = content.replace(CRLF, LF) content = content.replace(LF, CRLF) with open(filename, 'wb') as handle: handle.write(content) def main(args): for line in pipeable.go(args, strip=True, skip_blank=True): for filename in winglob.glob(line): pipeable.stdout(filename) crlf(filename) if __name__ == '__main__': raise SystemExit(main(sys.argv[1:]))