mirror of
https://github.com/codespell-project/codespell.git
synced 2025-08-06 18:24:41 +08:00
codespell itself
This commit is contained in:
@ -6,7 +6,7 @@ import re
|
|||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
USAGE = "%prog [OPTIONS] dict_filename file1 <file2 ... fileN>"
|
USAGE = "%prog [OPTIONS] dict_filename file1 <file2 ... fileN>"
|
||||||
mispellings = {}
|
misspellings = {}
|
||||||
options = None
|
options = None
|
||||||
|
|
||||||
#OPTIONS:
|
#OPTIONS:
|
||||||
@ -61,7 +61,7 @@ def build_dict(filename):
|
|||||||
|
|
||||||
for line in f:
|
for line in f:
|
||||||
[key, data] = line.split('->')
|
[key, data] = line.split('->')
|
||||||
mispellings[key] = Mispell(data, data.find(',') + 1)
|
misspellings[key] = Mispell(data, data.find(',') + 1)
|
||||||
|
|
||||||
if f != sys.stdin:
|
if f != sys.stdin:
|
||||||
f.close()
|
f.close()
|
||||||
@ -71,12 +71,12 @@ def parse_file(filename, colors):
|
|||||||
i = 1
|
i = 1
|
||||||
for line in f:
|
for line in f:
|
||||||
for word in re.findall('\w+', line):
|
for word in re.findall('\w+', line):
|
||||||
if word in mispellings:
|
if word in misspellings:
|
||||||
cfilename = "%s%s" % (colors.FILE, filename)
|
cfilename = "%s%s" % (colors.FILE, filename)
|
||||||
cline = "%d%s" % (i, colors.DISABLE)
|
cline = "%d%s" % (i, colors.DISABLE)
|
||||||
cwrongword = "%s%s%s" % (colors.WWORD, word, colors.DISABLE)
|
cwrongword = "%s%s%s" % (colors.WWORD, word, colors.DISABLE)
|
||||||
crightword = "%s%s%s" % (colors.FWORD, \
|
crightword = "%s%s%s" % (colors.FWORD, \
|
||||||
mispellings[word].data, \
|
misspellings[word].data, \
|
||||||
colors.DISABLE)
|
colors.DISABLE)
|
||||||
|
|
||||||
print ("%(FILENAME)s:%(LINE)s: %(WRONGWORD)s " \
|
print ("%(FILENAME)s:%(LINE)s: %(WRONGWORD)s " \
|
||||||
|
Reference in New Issue
Block a user