MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / OptionsList

Class OptionsList

mitmproxy/tools/console/options.py:153–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151
152
153class OptionsList(urwid.ListBox):
154 def __init__(self, master, help_widget: OptionHelp):
155 self.master = master
156 self.walker = OptionListWalker(master, help_widget)
157 super().__init__(self.walker)
158
159 def save_config(self, path):
160 try:
161 optmanager.save(self.master.options, path)
162 except exceptions.OptionsError as e:
163 signals.status_message.send(message=str(e))
164
165 def keypress(self, size, key):
166 if self.walker.editing:
167 if key == "enter":
168 foc, idx = self.get_focus()
169 v = self.walker.get_edit_text()
170 try:
171 self.master.options.set(f"{foc.opt.name}={v}")
172 except exceptions.OptionsError as v:
173 signals.status_message.send(message=str(v))
174 self.walker.stop_editing()
175 return None
176 elif key == "esc":
177 self.walker.stop_editing()
178 return None
179 else:
180 if key == "m_start":
181 self.set_focus(0)
182 self.walker._modified()
183 elif key == "m_end":
184 self.set_focus(len(self.walker.opts) - 1)
185 self.walker._modified()
186 elif key == "m_select":
187 foc, idx = self.get_focus()
188 if foc.opt.typespec is bool:
189 self.master.options.toggler(foc.opt.name)()
190 # Bust the focus widget cache
191 self.set_focus(self.walker.index)
192 elif can_edit_inplace(foc.opt):
193 self.walker.start_editing()
194 self.walker._modified()
195 elif foc.opt.choices:
196 self.master.overlay(
197 overlay.Chooser(
198 self.master,
199 foc.opt.name,
200 foc.opt.choices,
201 foc.opt.current(),
202 self.master.options.setter(foc.opt.name),
203 )
204 )
205 elif foc.opt.typespec in (Sequence[str], typing.Sequence[str]):
206 self.master.overlay(
207 overlay.OptionsOverlay(
208 self.master,
209 foc.opt.name,
210 foc.opt.current(),

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…