Roi Dayan via dev <[email protected]> writes:
> Load dictionary_code.txt in addition to the default dictionary.
> Add a new command line argument --dictionaries to be able
> to specify codespell dictionaries.
>
> Signed-off-by: Roi Dayan <[email protected]>
> Acked-by: Salem Sol <[email protected]>
> ---
Thanks for the update, it's close. I got a bit confused when trying to
test with this - it seems the order of arguments is dependent:
-S -D dictionary.txt -D dictionary_rare.txt
will not load the new dictionaries, and we have to add -S at the end.
BUT, I think the following incremental could work to resolve that.
WDYT? Otherwise, we'll need to document that spellchecking needs to be
after the dictionaries are specified.
diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index dd68e307a5..6a456931a7 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -40,11 +40,9 @@ missing_authors = []
codespell_dictionaries = ['dictionary.txt', 'dictionary_code.txt']
__codespell_dict_reset_once = True
+codespell_files = []
-def open_spell_check_dict():
- import enchant
-
- codespell_files = []
+def load_codespell_files():
try:
import codespell_lib
codespell_dir = os.path.dirname(codespell_lib.__file__)
@@ -55,6 +53,22 @@ def open_spell_check_dict():
except:
pass
+
+def load_codespell_words():
+ global spell_check_dict, codespell_files
+
+ for fn in codespell_files:
+ with open(fn) as f:
+ for line in f.readlines():
+ words = line.strip().split('>')[1].strip(', ').split(',')
+ for word in words:
+ if spell_check_dict:
+ spell_check_dict.add_to_session(word.strip())
+
+
+def open_spell_check_dict():
+ import enchant
+
try:
extra_keywords = ['ovs', 'vswitch', 'vswitchd', 'ovs-vswitchd',
'netdev', 'selinux', 'ovs-ctl', 'dpctl', 'ofctl',
@@ -125,13 +139,6 @@ def open_spell_check_dict():
spell_check_dict = enchant.Dict("en_US")
- for fn in codespell_files:
- with open(fn) as f:
- for line in f.readlines():
- words = line.strip().split('>')[1].strip(', ').split(',')
- for word in words:
- spell_check_dict.add_to_session(word.strip())
-
for kw in extra_keywords:
spell_check_dict.add_to_session(kw)
@@ -1274,6 +1281,9 @@ if __name__ == '__main__':
print("Unknown option '%s'" % o)
sys.exit(EXIT_FAILURE)
+ load_codespell_files()
+ load_codespell_words()
+
if sys.stdout.isatty():
colors = True
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev