diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2019-06-04 21:50:09 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2019-06-04 22:35:26 +0300 |
commit | 673af6883fc5a22f6c3e730a81be3d6a0a32ad2f (patch) | |
tree | e58de1c4704231f63a1225b8671b9d1e4133f12c /calm/hint.py | |
parent | a702bd3f07e94193a551e4311e543fc79e2f5e64 (diff) |
Fix and warn about some common, long-standing typos
See also https://cygwin.com/ml/cygwin-apps/2015-10/msg00056.html
Diffstat (limited to 'calm/hint.py')
-rwxr-xr-x | calm/hint.py | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/calm/hint.py b/calm/hint.py index 6e1a948..c340b94 100755 --- a/calm/hint.py +++ b/calm/hint.py @@ -235,22 +235,28 @@ def hint_file_parse(fn, kind): if c.lower() not in categories: errors.append("unknown category '%s'" % (c)) - # verify that value for ldesc or sdesc is quoted - # (genini forces this) if key in ['sdesc', 'ldesc']: + # verify that value for ldesc or sdesc is quoted (genini + # forces this) if not (value.startswith('"') and value.endswith('"')): errors.append("%s value '%s' should be quoted" % (key, value)) + # warn about and fix common typos in ldesc/sdesc + value, msg = typofix(value) + if msg: + warnings.append("%s in %s" % (','.join(msg), key)) + # if sdesc ends with a '.', warn and fix it if key == 'sdesc': if re.search(r'\."$', value): warnings.append("sdesc ends with '.'") value = re.sub(r'\."$', '"', value) - # warn if sdesc contains ' ' + # if sdesc contains ' ', warn and fix it if key == 'sdesc': if ' ' in value: warnings.append("sdesc contains ' '") + value = value.replace(' ', ' ') # only 'ldesc' and 'message' are allowed a multi-line value if (type != 'multilineval') and (len(value.splitlines()) > 1): @@ -321,6 +327,33 @@ def hint_file_parse(fn, kind): # +# words that Cygwin package maintainers apparently can't spell correctly +# + +words = [ + (' accomodates ', ' accommodates '), + (' consistant ', ' consistent '), + (' examing ', ' examining '), + (' extremly ', ' extremely '), + (' interm ', ' interim '), + (' procesors ', ' processors '), + (' utilitzed ', ' utilized '), + (' utilties ', ' utilities '), +] + + +def typofix(v): + msg = [] + + for (wrong, right) in words: + if wrong in v: + v = v.replace(wrong, right) + msg.append('%s -> %s' % (wrong.strip(), right.strip())) + + return v, msg + + +# # # |