MCPcopy Index your code
hub / github.com/RustPython/RustPython / global_matches

Method global_matches

Lib/rlcompleter.py:113–138  ·  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 that match.

(self, text)

Source from the content-addressed store, hash-verified

111 return word
112
113 def global_matches(self, text):
114 """Compute matches when text is a simple name.
115
116 Return a list of all keywords, built-in functions and names currently
117 defined in self.namespace that match.
118
119 """
120 matches = []
121 seen = {"__builtins__"}
122 n = len(text)
123 for word in keyword.kwlist + keyword.softkwlist:
124 if word[:n] == text:
125 seen.add(word)
126 if word in {'finally', 'try'}:
127 word = word + ':'
128 elif word not in {'False', 'None', 'True',
129 'break', 'continue', 'pass',
130 'else', '_'}:
131 word = word + ' '
132 matches.append(word)
133 for nspace in [self.namespace, builtins.__dict__]:
134 for word, val in nspace.items():
135 if word[:n] == text and word not in seen:
136 seen.add(word)
137 matches.append(self._callable_postfix(val, word))
138 return matches
139
140 def attr_matches(self, text):
141 """Compute matches when text contains a dot.

Callers 2

completeMethod · 0.95
test_global_matchesMethod · 0.80

Calls 5

_callable_postfixMethod · 0.95
lenFunction · 0.85
addMethod · 0.45
appendMethod · 0.45
itemsMethod · 0.45

Tested by 1

test_global_matchesMethod · 0.64