Skip to content

Commit

Permalink
Merge pull request #119 from cclauss/patch-1
Browse files Browse the repository at this point in the history
Streamline file operations in convert()
  • Loading branch information
Vonng committed Aug 9, 2021
2 parents f744e6d + 228db78 commit ef60741
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions bin/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ def convert(infile: str, outfile: str, cfg: str):
"""
converter = opencc.OpenCC(cfg)
with open(infile, "r") as inf, open(outfile, "w+") as outf:
data = inf.readlines()
data = list(map(converter.convert, data))
outf.writelines(data)
outf.write("\n".join(converter.convert(line) for line in inf))
print(f"Convert to {outfile}")


Expand Down

0 comments on commit ef60741

Please sign in to comment.