MCPcopy Create free account
hub / github.com/ipython/ipython / global_matches

Method global_matches

IPython/core/completer.py:653–679  ·  view source on GitHub ↗

Compute matches when text is a simple name. Return a list of all keywords, built-in functions and names currently defined in self.namespace or self.global_namespace that match.

(self, text)

Source from the content-addressed store, hash-verified

651 return None
652
653 def global_matches(self, text):
654 """Compute matches when text is a simple name.
655
656 Return a list of all keywords, built-in functions and names currently
657 defined in self.namespace or self.global_namespace that match.
658
659 """
660 matches = []
661 match_append = matches.append
662 n = len(text)
663 for lst in [keyword.kwlist,
664 builtin_mod.__dict__.keys(),
665 self.namespace.keys(),
666 self.global_namespace.keys()]:
667 for word in lst:
668 if word[:n] == text and word != "__builtins__":
669 match_append(word)
670
671 snake_case_re = re.compile(r"[^_]+(_[^_]+)+?\Z")
672 for lst in [self.namespace.keys(),
673 self.global_namespace.keys()]:
674 shortened = {"_".join([sub[0] for sub in word.split('_')]) : word
675 for word in lst if snake_case_re.match(word)}
676 for word in shortened.keys():
677 if word[:n] == text and word != "__builtins__":
678 match_append(shortened[word])
679 return matches
680
681 def attr_matches(self, text):
682 """Compute matches when text contains a dot.

Callers 3

completeMethod · 0.95
magic_matchesMethod · 0.80
python_matchesMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected