summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/crlf.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/scripts/crlf.py')
-rwxr-xr-xTools/scripts/crlf.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/Tools/scripts/crlf.py b/Tools/scripts/crlf.py
index a975cb2..f231d29 100755
--- a/Tools/scripts/crlf.py
+++ b/Tools/scripts/crlf.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"Replace CRLF with LF in argument files. Print names of changed files."
import sys, os
@@ -6,18 +6,18 @@ import sys, os
def main():
for filename in sys.argv[1:]:
if os.path.isdir(filename):
- print filename, "Directory!"
+ print(filename, "Directory!")
continue
- data = open(filename, "rb").read()
- if '\0' in data:
- print filename, "Binary!"
+ with open(filename, "rb") as f:
+ data = f.read()
+ if b'\0' in data:
+ print(filename, "Binary!")
continue
- newdata = data.replace("\r\n", "\n")
+ newdata = data.replace(b"\r\n", b"\n")
if newdata != data:
- print filename
- f = open(filename, "wb")
- f.write(newdata)
- f.close()
+ print(filename)
+ with open(filename, "wb") as f:
+ f.write(newdata)
if __name__ == '__main__':
main()