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

Method magic_config_matches

IPython/core/completer.py:2421–2458  ·  view source on GitHub ↗

Match class names and attributes for %config magic. .. deprecated:: 8.6 You can use :meth:`magic_config_matcher` instead.

(self, text: str)

Source from the content-addressed store, hash-verified

2419 return _convert_matcher_v1_result_to_v2_no_no(matches, type="param")
2420
2421 def magic_config_matches(self, text: str) -> list[str]:
2422 """Match class names and attributes for %config magic.
2423
2424 .. deprecated:: 8.6
2425 You can use :meth:`magic_config_matcher` instead.
2426 """
2427 texts = text.strip().split()
2428
2429 if len(texts) > 0 and (texts[0] == 'config' or texts[0] == '%config'):
2430 # get all configuration classes
2431 classes = sorted(set([ c for c in self.shell.configurables
2432 if c.__class__.class_traits(config=True)
2433 ]), key=lambda x: x.__class__.__name__)
2434 classnames = [ c.__class__.__name__ for c in classes ]
2435
2436 # return all classnames if config or %config is given
2437 if len(texts) == 1:
2438 return classnames
2439
2440 # match classname
2441 classname_texts = texts[1].split('.')
2442 classname = classname_texts[0]
2443 classname_matches = [ c for c in classnames
2444 if c.startswith(classname) ]
2445
2446 # return matched classes or the matched class with attributes
2447 if texts[1].find('.') < 0:
2448 return classname_matches
2449 elif len(classname_matches) == 1 and \
2450 classname_matches[0] == classname:
2451 cls = classes[classnames.index(classname)].__class__
2452 help = cls.class_get_help()
2453 # strip leading '--' from cl-args:
2454 help = re.sub(re.compile(r'^--', re.MULTILINE), '', help)
2455 return [ attr.split('=')[0]
2456 for attr in help.strip().splitlines()
2457 if attr.startswith(texts[1]) ]
2458 return []
2459
2460 @context_matcher()
2461 def magic_color_matcher(self, context: CompletionContext) -> SimpleMatcherResult:

Callers 1

magic_config_matcherMethod · 0.95

Calls 2

indexMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected