|
|
|
@ -70,6 +70,7 @@ class MainLoop(cmd2.Cmd): |
|
|
|
self.hidden = set() |
|
|
|
self.init_letters(input("Enter letters: ")) |
|
|
|
self._candidates = None |
|
|
|
self._in_dictionary = None |
|
|
|
super().__init__() |
|
|
|
|
|
|
|
def init_letters(self, letters): |
|
|
|
@ -79,6 +80,7 @@ class MainLoop(cmd2.Cmd): |
|
|
|
self.letters = [l for l in letters if l in LOWERCASE] |
|
|
|
self.prompt = MainLoop.prompt.format(", ".join(self.letters)) |
|
|
|
self._candidates = None |
|
|
|
self._in_dictionary = None |
|
|
|
|
|
|
|
@property |
|
|
|
def candidates(self): |
|
|
|
@ -86,6 +88,12 @@ class MainLoop(cmd2.Cmd): |
|
|
|
self._candidates = candidates(self.letters) |
|
|
|
return self._candidates |
|
|
|
|
|
|
|
@property |
|
|
|
def in_dictionary(self): |
|
|
|
if self._in_dictionary is None: |
|
|
|
self._in_dictionary = DICTS[self.dict].filter(self.candidates) |
|
|
|
return self._in_dictionary |
|
|
|
|
|
|
|
def filter(self, regex): |
|
|
|
matching_pattern = filter(regex.match, self.candidates) |
|
|
|
return DICTS[self.dict].filter(matching_pattern) |
|
|
|
|