Skip to content

Commit ae87a80

Browse files
committed
Refined script
1 parent 508f255 commit ae87a80

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

codext/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def main():
4343
help="ignore|replace|strict")
4444
parser.add_argument("-i", "--input-file", dest="infile")
4545
parser.add_argument("-o", "--output-file", dest="outfile")
46+
parser.add_argument("-s", "--strip-newlines", action="store_true",
47+
dest="strip")
4648
args = parser.parse_args()
4749
# handle input file or stdin
4850
if args.infile:
@@ -53,6 +55,8 @@ def main():
5355
for line in __stdin_pipe():
5456
c += line
5557
# encode or decode
58+
if args.strip:
59+
c = re.sub("\r?\n", "", c)
5660
c = getattr(codecs, ["encode", "decode"][args.decode])\
5761
(c, args.encoding, args.errors)
5862
# hanbdle output file or stdout

0 commit comments

Comments
 (0)