update password module to use standardized interactive interface

This commit is contained in:
randomuser 2023-07-23 21:07:38 -05:00
parent e107e28947
commit 772cfc900c
2 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,6 @@
from modules.wires import WiresModule
from modules.button import ButtonModule
from modules.comp_wires import ComplicatedWiresModule
from modules.password import PasswordModule
modules = {

View File

@ -1,3 +1,6 @@
from prompt_toolkit import prompt
from prompt_toolkit.completion import WordCompleter
class FoundCondition(Exception):
pass
@ -60,7 +63,7 @@ class PasswordModule:
default module execution location
(hint, default module execution location is where __name__ ==
"__main__"
"__main__")
"""
responses = []
@ -71,5 +74,16 @@ class PasswordModule:
obj = cls(responses)
return obj.solve()
@classmethod
def interactive(cls, state, cmdline):
responses = []
for i in range(5):
print("Enter {}th column of letters:".format(str(i + 1)))
response = [*prompt('password> ')]
responses.append(response)
password = cls(responses)
print(password.solve())
if __name__ == "__main__":
print(PasswordModule.human_helper())