2019-06-12 05:41:31 +00:00
|
|
|
'''
|
|
|
|
Convert LF line endings to CRLF.
|
|
|
|
'''
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from voussoirkit import pipeable
|
2020-01-16 06:47:26 +00:00
|
|
|
from voussoirkit import winglob
|
2019-06-12 05:41:31 +00:00
|
|
|
|
|
|
|
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):
|
2020-01-16 06:47:26 +00:00
|
|
|
for filename in winglob.glob(line):
|
2019-06-12 05:41:31 +00:00
|
|
|
pipeable.output(filename)
|
|
|
|
crlf(filename)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
raise SystemExit(main(sys.argv[1:]))
|