ยปCore Development>Code coverage>Tools/scripts/lfcr.py

Python code coverage for Tools/scripts/lfcr.py

#countcontent
1n/a#! /usr/bin/env python3
2n/a
3n/a"Replace LF with CRLF in argument files. Print names of changed files."
4n/a
5n/aimport sys, re, os
6n/a
7n/adef main():
8n/a for filename in sys.argv[1:]:
9n/a if os.path.isdir(filename):
10n/a print(filename, "Directory!")
11n/a continue
12n/a with open(filename, "rb") as f:
13n/a data = f.read()
14n/a if b'\0' in data:
15n/a print(filename, "Binary!")
16n/a continue
17n/a newdata = re.sub(b"\r?\n", b"\r\n", data)
18n/a if newdata != data:
19n/a print(filename)
20n/a with open(filename, "wb") as f:
21n/a f.write(newdata)
22n/a
23n/aif __name__ == '__main__':
24n/a main()