MCPcopy Index your code
hub / github.com/bpython/bpython / add

Method add

bpython/curtsiesfrontend/manual_readline.py:32–56  ·  view source on GitHub ↗
(self, key, func, overwrite=False)

Source from the content-addressed store, hash-verified

30 self.awaiting_config = {}
31
32 def add(self, key, func, overwrite=False):
33 if key in self:
34 if overwrite:
35 del self[key]
36 else:
37 raise ValueError(f"key {key!r} already has a mapping")
38 params = getargspec(func)
39 args = {k: v for k, v in self.default_kwargs.items() if k in params}
40 r = func(**args)
41 if len(r) == 2:
42 if hasattr(func, "kills"):
43 raise ValueError(
44 "function %r returns two values, but has a "
45 "kills attribute" % (func,)
46 )
47 self.simple_edits[key] = func
48 elif len(r) == 3:
49 if not hasattr(func, "kills"):
50 raise ValueError(
51 "function %r returns three values, but has "
52 "no kills attribute" % (func,)
53 )
54 self.cut_buffer_edits[key] = func
55 else:
56 raise ValueError(f"return type of function {func!r} not recognized")
57
58 def add_config_attr(self, config_attr, func):
59 if config_attr in self.awaiting_config:

Callers 11

find_modulesMethod · 0.45
find_all_modulesMethod · 0.45
matchesMethod · 0.45
matchesMethod · 0.45
test_seqMethod · 0.45
test_configMethod · 0.45
add_to_keybindsMethod · 0.45
__init__Method · 0.45
_add_moduleMethod · 0.45

Calls

no outgoing calls

Tested by 4

test_seqMethod · 0.36
test_configMethod · 0.36