Created
March 16, 2017 15:25
-
-
Save charsyam/ad68b16f59c8dd16f20bf6ed886584e6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import sys | |
def convert_misspel_to_sed(line): | |
parts = line.split(':') | |
filename = parts[0] | |
line_no = parts[1] | |
keyparts = parts[2].split("->") | |
misspel = keyparts[0].strip() | |
valids = [keyword[1:-1] for keyword in keyparts[1].strip().split(',')] | |
for valid in valids: | |
cmd = "sed -ie '{line}s/{misspel}/{valid}/' {filename}".format( | |
line=line_no, misspel=misspel, valid=valid, filename=filename | |
) | |
print(cmd) | |
with open(sys.argv[1]) as f: | |
lines = f.readlines() | |
for line in lines: | |
convert_misspel_to_sed(line.strip()) |
filename, line_no, keyparts = line.split(':')
👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
뭐하는 코드인지 잘 모르지만 멋집니다. 추가로... subprocess 모듈로 실행도 하시면 금상 첨화?