MCPcopy
hub / github.com/mitmproxy/mitmproxy / add

Method add

mitmproxy/tools/console/keymap.py:89–107  ·  view source on GitHub ↗

Add a key to the key map.

(self, key: str, command: str, contexts: Sequence[str], help="")

Source from the content-addressed store, hash-verified

87 self.binding_for_help.cache_clear()
88
89 def add(self, key: str, command: str, contexts: Sequence[str], help="") -> None:
90 """
91 Add a key to the key map.
92 """
93 self._check_contexts(contexts)
94
95 for b in self.bindings:
96 if b.key == key and b.command.strip() == command.strip():
97 b.contexts = sorted(list(set(b.contexts + contexts)))
98 if help:
99 b.help = help
100 self.bind(b)
101 break
102 else:
103 self.remove(key, contexts)
104 b = Binding(key=key, command=command, contexts=contexts, help=help)
105 self.bindings.append(b)
106 self.bind(b)
107 self._on_change()
108
109 def remove(self, key: str, contexts: Sequence[str]) -> None:
110 """

Callers 10

test_bindFunction · 0.95
test_joinFunction · 0.95
test_removeFunction · 0.95
test_load_pathFunction · 0.95
__init__Method · 0.45
key_bindMethod · 0.45
__init__Method · 0.45
load_pathMethod · 0.45
mapFunction · 0.45
__init__Method · 0.45

Calls 7

_check_contextsMethod · 0.95
bindMethod · 0.95
removeMethod · 0.95
_on_changeMethod · 0.95
setFunction · 0.85
BindingClass · 0.85
appendMethod · 0.45

Tested by 4

test_bindFunction · 0.76
test_joinFunction · 0.76
test_removeFunction · 0.76
test_load_pathFunction · 0.76