@@ -578,7 +578,7 @@ class SpellingTask:
578578 "O" : glob .O
579579 }
580580
581- def __init__ (self , checker , config , binary = '' , verbose = 0 , jobs = 0 , debug = False ):
581+ def __init__ (self , checker , config , binary = '' , verbose = 0 , jobs = 0 , debug = False , skip_dict_compile = False ):
582582 """Initialize."""
583583
584584 if checker == "hunspell" : # pragma: no cover
@@ -594,6 +594,7 @@ def __init__(self, checker, config, binary='', verbose=0, jobs=0, debug=False):
594594 self .binary = checker if not binary else binary
595595 self .debug = debug
596596 self .jobs = jobs
597+ self .skip_dict_compile = skip_dict_compile
597598
598599 def log (self , text , level ):
599600 """Log level."""
@@ -622,7 +623,13 @@ def walk_src(self, targets, flags, limit):
622623 def get_checker (self ):
623624 """Get a spell checker object."""
624625
625- checker = self .spellchecker (self .config , self .binary , self .verbose , self .default_encoding , self .debug )
626+ checker = self .spellchecker (
627+ self .config ,
628+ self .binary ,
629+ self .verbose ,
630+ self .default_encoding ,
631+ self .debug
632+ )
626633 checker ._build_pipeline (self .task )
627634 return checker
628635
@@ -654,7 +661,15 @@ def run_task(self, task, source_patterns=None):
654661 self .task = task
655662 self .default_encoding = self .task .get ('default_encoding' , '' )
656663 self .options = self .spellchecker .get_options (self .task )
657- self .personal_dict = self .spellchecker .setup_dictionary (self .task , self .binary , self .verbose )
664+ if not self .skip_dict_compile :
665+ self .personal_dict = self .spellchecker .setup_dictionary (self .task , self .binary , self .verbose )
666+ else :
667+ dictionary_options = self .task .get ('dictionary' , {})
668+ output = os .path .abspath (dictionary_options .get ('output' , os .path .abspath (self .spellchecker .DICTIONARY )))
669+ if os .path .exists (output ):
670+ self .personal_dict = output
671+ else :
672+ self .personal_dict = self .spellchecker .setup_dictionary (self .task , self .binary , self .verbose )
658673 self .found_match = False
659674 glob_flags = self ._to_flags (self .task .get ('glob_flags' , "N|B|G" ))
660675 glob_limit = self .task .get ('glob_pattern_limit' , 1000 )
@@ -696,7 +711,8 @@ def spellcheck(
696711 sources = None ,
697712 verbose = 0 ,
698713 debug = False ,
699- jobs = 0
714+ jobs = 0 ,
715+ skip_dict_compile = False
700716):
701717 """Spell check."""
702718
@@ -737,7 +753,7 @@ def spellcheck(
737753
738754 log ('Using {} to spellcheck {}' .format (checker , task .get ('name' , '' )), 1 , verbose )
739755
740- spelltask = SpellingTask (checker , config , binary , verbose , jobs , debug )
756+ spelltask = SpellingTask (checker , config , binary , verbose , jobs , debug , skip_dict_compile )
741757
742758 for result in spelltask .run_task (task , source_patterns = sources ):
743759 log ('Context: %s' % result .context , 2 , verbose )
0 commit comments