aeat.application.wizard._prompter module¶
Prompter abstraction for the wizard runtime.
The Prompter protocol decouples “where does an answer come
from” from “what does the wizard ask for”. The runtime calls
prompter.ask(question, default=...) for every visible question
and receives a canonical-token string in return. Two implementations
ship: ScriptedPrompter for deterministic tests and structured
flag-driven CLI invocations, and QuestionaryPrompter for live
operator interaction. Both speak the same canonical-token contract.
- exception WizardUnsupportedConsoleError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
AeatErrorRaised when the host terminal cannot host an interactive wizard.
Surfaces when
prompt_toolkitrejects the active TTY (typicallyprompt_toolkit.output.win32.NoConsoleScreenBufferErrorunder git-bash on Windows). The runtime catches this at theQuestionaryPrompterboundary and surfaces a translated operator-facing message rather than a Python traceback.- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- exception WizardEditUnsupportedConsoleError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
WizardUnsupportedConsoleErrorNo-console refusal raised specifically from the
profile editflow.The base error’s recovery suggestion names
profile create, which reads as a destructive replacement when an operator hit the no-console state viaprofile edit. This subclass carries its own registered error code so the trailing recovery suggestion names the non-interactiveprofile editpatch form instead.- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- class Prompter(*args, **kwargs)[source]¶
Bases:
ProtocolCapability protocol for collecting one answer from one question.
- ask(question, *, default)[source]¶
Render
questionand return the operator’s canonical-token answer.- Return type:
- Parameters:
question (WizardQuestion)
default (str | None)
- class ScriptedPrompter(answers)[source]¶
Bases:
objectTest-only prompter that pops canonical-token answers from a FIFO queue.
Tests construct a
ScriptedPrompterwith a deque of canonical tokens whose order matches the runtime’s expected question sequence. Eachaskcall pops the leftmost token; an empty deque raisesWizardScriptUnderflowError. Callingclose()after the runtime finishes raisesWizardScriptOverflowErrorif any scripted token went unconsumed, surfacing test-fixture drift loudly without exposing token values in diagnostics.- ask(question, *, default)[source]¶
Pop and return the next scripted canonical-token answer.
- Parameters:
question (
WizardQuestion) – TheWizardQuestionbeing asked (used only in the underflow error message).default (
str|None) – Ignored; the scripted queue always supplies an explicit answer.
- Raises:
WizardScriptUnderflowError – When the answer queue is empty.
- Return type:
- close()[source]¶
Assert every scripted answer was consumed.
- Raises:
WizardScriptOverflowError – When the deque holds unconsumed canonical tokens at flow end. The exception context reports counts only because scripted tokens can contain secrets.
- Return type:
- class QuestionaryPrompter(*, input=None, output=None)[source]¶
Bases:
objectProduction prompter that dispatches each widget onto a questionary primitive.
The mapping is one-to-one:
TEXT→questionary.text,SECRET→questionary.password,CONFIRM→questionary.confirm,SELECT→questionary.select,CHECKBOX→questionary.checkbox,PATH→questionary.path,INTEGER→questionary.textwith a numeric validator. The class accepts an optionalinput/outputpair so tests can drive it throughprompt_toolkit.input.create_pipe_input().- Parameters:
input (Input | None)
output (Output | None)
- prepare(flow)[source]¶
Verify prompt support and explain the setup flow before progress starts.
- Return type:
- Parameters:
flow (WizardFlow)
- emit_progress(text)[source]¶
Emit a progress line (section header or question prefix).
Called by the runtime between question prompts so operators see their position in the flow. Routes through the structured logger so the message is handled by the configured logging pipeline and any registered secret-scrubbing filters.
- ask(question, *, default)[source]¶
Render
questioninteractively and return the canonical-token answer.Dispatches to the appropriate
questionaryprimitive based onquestion.widgetand returns the operator’s response as a canonical-token string ("true"/"false"for CONFIRM, comma-separated tokens for CHECKBOX, raw text otherwise).- Parameters:
question (
WizardQuestion) – TheWizardQuestionto render.default (
str|None) – Pre-filled answer string shown to the operator.
- Raises:
WizardUnsupportedConsoleError – When the host terminal cannot host an interactive prompt (Windows no-console, non-TTY).
- Return type: