Skip to content

Commit

Permalink
scripts: Add utolf.py helper script.
Browse files Browse the repository at this point in the history
Converts line endings to lf.
  • Loading branch information
bradleysepos committed Oct 25, 2023
1 parent 79bdc5e commit 477b393
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/utolf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#/usr/bin/env python3

import os
import sys

def main():
filenames = sys.argv[1:]
if filenames:
convert(filenames)
else:
print("Usage: <command> filename [filename ...]")

def convert(files):
for file in files:
print(file)
with open(file, 'r') as infile, \
open(file + '.tmp', 'w', newline='\n') as outfile:
outfile.writelines(infile.readlines())
os.replace(file + '.tmp', file)

if __name__ == "__main__":
main()

0 comments on commit 477b393

Please sign in to comment.