Created
March 8, 2018 19:09
-
-
Save astrograzl/57d60ff9dc281c43cb61724db16959a6 to your computer and use it in GitHub Desktop.
End of Line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python3 | |
# coding: utf-8 | |
"""Trim white space from end of line.""" | |
import sys | |
if len(sys.argv) < 2: | |
sys.exit("Usage: eol.py FILENAME[S]") | |
for filename in sys.argv[1:]: | |
try: | |
with open(filename, "r") as finp: | |
lines = finp.readlines() | |
except Exception as err: | |
print(err) | |
else: | |
with open(filename, "w") as fout: | |
for line in lines: | |
fout.write(line.rstrip()+"\n") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment