MCPcopy Index your code
hub / github.com/ipython/ipython / dispatch_custom_completer

Method dispatch_custom_completer

IPython/core/completer.py:3220–3270  ·  view source on GitHub ↗

.. deprecated:: 8.6 You can use :meth:`custom_completer_matcher` instead.

(self, text)

Source from the content-addressed store, hash-verified

3218 return result
3219
3220 def dispatch_custom_completer(self, text):
3221 """
3222 .. deprecated:: 8.6
3223 You can use :meth:`custom_completer_matcher` instead.
3224 """
3225 if not self.custom_completers:
3226 return
3227
3228 line = self.line_buffer
3229 if not line.strip():
3230 return None
3231
3232 # Create a little structure to pass all the relevant information about
3233 # the current completion to any custom completer.
3234 event = SimpleNamespace()
3235 event.line = line
3236 event.symbol = text
3237 cmd = line.split(None,1)[0]
3238 event.command = cmd
3239 event.text_until_cursor = self.text_until_cursor
3240
3241 # for foo etc, try also to find completer for %foo
3242 if not cmd.startswith(self.magic_escape):
3243 try_magic = self.custom_completers.s_matches(
3244 self.magic_escape + cmd)
3245 else:
3246 try_magic = []
3247
3248 for c in itertools.chain(self.custom_completers.s_matches(cmd),
3249 try_magic,
3250 self.custom_completers.flat_matches(self.text_until_cursor)):
3251 try:
3252 res = c(event)
3253 if res:
3254 # first, try case sensitive match
3255 withcase = [r for r in res if r.startswith(text)]
3256 if withcase:
3257 return withcase
3258 # if none, then case insensitive ones are ok too
3259 text_low = text.lower()
3260 return [r for r in res if r.lower().startswith(text_low)]
3261 except TryNext:
3262 pass
3263 except KeyboardInterrupt:
3264 """
3265 If custom completer take too long,
3266 let keyboard interrupt abort and return nothing.
3267 """
3268 break
3269
3270 return None
3271
3272 def completions(self, text: str, offset: int)->Iterator[Completion]:
3273 """

Callers 1

Calls 2

s_matchesMethod · 0.80
flat_matchesMethod · 0.80

Tested by

no test coverage detected