MCPcopy Create free account
hub / github.com/aws/aws-cli / WizardTraverser

Class WizardTraverser

awscli/customizations/wizard/app.py:93–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91
92
93class WizardTraverser:
94 DONE = core.DONE_SECTION_NAME
95 OUTPUT = core.OUTPUT_SECTION_NAME
96
97 def __init__(self, definition, values, executor):
98 self._definition = definition
99 self._values = values
100 self._executor = executor
101 self._prompt_definitions = self._collect_prompt_definitions()
102 self._prompt_to_sections = self._map_prompts_to_sections()
103 self._current_prompt = self._get_starting_prompt()
104 self._previous_prompts = []
105 self._visited_sections = [self.get_current_section()]
106
107 def get_current_prompt(self):
108 return self._current_prompt
109
110 def get_current_section(self):
111 if self.has_no_remaining_prompts():
112 return self.DONE
113 return self._prompt_to_sections[self._current_prompt]
114
115 def get_current_prompt_choices(self):
116 choices = self._get_choices(self._current_prompt)
117 if choices:
118 return [choice['display'] for choice in choices]
119 return None
120
121 def current_prompt_has_details(self):
122 return 'details' in self._prompt_definitions.get(
123 self._current_prompt, {}
124 )
125
126 def submit_prompt_answer(self, answer):
127 definition = self._prompt_definitions[self._current_prompt]
128 if 'choices' in definition:
129 answer = self._convert_display_value_to_actual_value(
130 self._get_choices(self._current_prompt), answer
131 )
132 if 'datatype' in definition:
133 answer = core.DataTypeConverter.convert(
134 definition['datatype'], answer
135 )
136
137 self._values[self._current_prompt] = answer
138
139 def next_prompt(self):
140 if self._current_prompt == self.DONE:
141 return self._current_prompt
142 new_prompt = self._get_next_prompt()
143 self._previous_prompts.append(self._current_prompt)
144 section_of_new_prompt = self._prompt_to_sections.get(new_prompt)
145 if section_of_new_prompt != self.get_current_section():
146 self._visited_sections.append(self._prompt_to_sections[new_prompt])
147 self._current_prompt = new_prompt
148 return new_prompt
149
150 def previous_prompt(self):

Callers 2

create_traverserMethod · 0.90
create_wizard_appFunction · 0.90

Calls

no outgoing calls

Tested by 1

create_traverserMethod · 0.72