MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / complete

Method complete

tools/python-3.11.9-amd64/Lib/cmd.py:251–279  ·  view source on GitHub ↗

Return the next possible completion for 'text'. If a command has not been entered, then complete against command list. Otherwise try to call complete_ to get list of completions.

(self, text, state)

Source from the content-addressed store, hash-verified

249 return [a[3:] for a in self.get_names() if a.startswith(dotext)]
250
251 def complete(self, text, state):
252 """Return the next possible completion for 'text'.
253
254 If a command has not been entered, then complete against command list.
255 Otherwise try to call complete_<command> to get list of completions.
256 """
257 if state == 0:
258 import readline
259 origline = readline.get_line_buffer()
260 line = origline.lstrip()
261 stripped = len(origline) - len(line)
262 begidx = readline.get_begidx() - stripped
263 endidx = readline.get_endidx() - stripped
264 if begidx>0:
265 cmd, args, foo = self.parseline(line)
266 if cmd == '':
267 compfunc = self.completedefault
268 else:
269 try:
270 compfunc = getattr(self, 'complete_' + cmd)
271 except AttributeError:
272 compfunc = self.completedefault
273 else:
274 compfunc = self.completenames
275 self.completion_matches = compfunc(text, line, begidx, endidx)
276 try:
277 return self.completion_matches[state]
278 except IndexError:
279 return None
280
281 def get_names(self):
282 # This method used to pull in base class attributes

Callers

nothing calls this directly

Calls 2

parselineMethod · 0.95
lstripMethod · 0.80

Tested by

no test coverage detected