Skip to content

Commit

Permalink
Remove reason from suggested fixes
Browse files Browse the repository at this point in the history
If there's a reason why a change is not a 1:1, do not print it in the
list of suggestions.
  • Loading branch information
Lucas De Marchi committed Jan 29, 2011
1 parent 049da20 commit b11405e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
17 changes: 14 additions & 3 deletions codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
# file1 .. fileN Files to check spelling

class Mispell:
def __init__(self, data, fix):
def __init__(self, data, fix, reason):
self.data = data
self.fix = fix

self.reason = reason

class TermColors:
def __init__(self):
Expand Down Expand Up @@ -66,7 +66,18 @@ def build_dict(filename):
with open(filename, 'r') as f:
for line in f:
[key, data] = line.split('->')
misspellings[key] = Mispell(data, data.find(',') + 1)
fix = data.find(',')

if fix != (len(data) - 1) and fix > 0:
reason = data.split(',')[-1]
else:
reason = ''

if fix > 0:
fix = True
data = "%s\n" % data[:data.rfind(',')]

misspellings[key] = Mispell(data, fix, reason)

def parse_file(filename, colors):
if filename == '-':
Expand Down
10 changes: 8 additions & 2 deletions example/code.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@

int f(int type)
{
return type;
}

int main(void)
{
int fd;
int fd, clas;
/* tis code does nothing */

f(1, 2, 3);

fd = opem("/tmp/a", O_RDONLY);
return 0;

// buring your cpu
return f(clas);
}
2 changes: 2 additions & 0 deletions example/dict.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
tis->this
opem->open
buring->burying, burning, burin, during,
clas->class, disabled due to name clash in c++

0 comments on commit b11405e

Please sign in to comment.