aboutsummaryrefslogtreecommitdiff
path: root/tests/unix2dos.py
blob: 4e6c9cf452f76cfa1c785e56af40a603cb8854e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python3
import sys

buf = ""
with open(sys.argv[1], 'r+b') as f:
    buf = f.read()

if buf.find(b'\r\n'):
    print(f"{sys.argv[1]} is already a CRLF file")
    sys.exit(1)

buf = buf.replace(b'\n', b'\r\n')

with open(sys.argv[1], 'w+b') as f:
    f.write(buf)