MCPcopy
hub / github.com/mitmproxy/mitmproxy / toggler

Method toggler

mitmproxy/optmanager.py:262–276  ·  view source on GitHub ↗

Generate a toggler for a boolean attribute. This returns a callable that takes no arguments.

(self, attr)

Source from the content-addressed store, hash-verified

260 return setter
261
262 def toggler(self, attr):
263 """
264 Generate a toggler for a boolean attribute. This returns a callable
265 that takes no arguments.
266 """
267 if attr not in self._options:
268 raise KeyError("No such option: %s" % attr)
269 o = self._options[attr]
270 if o.typespec is not bool:
271 raise ValueError("Toggler can only be used with boolean options")
272
273 def toggle():
274 setattr(self, attr, not getattr(self, attr))
275
276 return toggle
277
278 def default(self, option: str) -> Any:
279 return self._options[option].default

Callers 2

test_togglerFunction · 0.80
keypressMethod · 0.80

Calls

no outgoing calls

Tested by 1

test_togglerFunction · 0.64