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

Function magic_run_completer

IPython/core/completerlib.py:289–323  ·  view source on GitHub ↗

Complete files that end in .py or .ipy or .ipynb for the %run command.

(self, event)

Source from the content-addressed store, hash-verified

287# completers, that is currently reimplemented in each.
288
289def magic_run_completer(self, event):
290 """Complete files that end in .py or .ipy or .ipynb for the %run command.
291 """
292 comps = arg_split(event.line, strict=False)
293 # relpath should be the current token that we need to complete.
294 if (len(comps) > 1) and (not event.line.endswith(' ')):
295 relpath = comps[-1].strip("'\"")
296 else:
297 relpath = ''
298
299 #print("\nev=", event) # dbg
300 #print("rp=", relpath) # dbg
301 #print('comps=', comps) # dbg
302
303 lglob = glob.glob
304 isdir = os.path.isdir
305 relpath, tilde_expand, tilde_val = expand_user(relpath)
306
307 # Find if the user has already typed the first filename, after which we
308 # should complete on all files, since after the first one other files may
309 # be arguments to the input script.
310
311 if any(magic_run_re.match(c) for c in comps):
312 matches = [f.replace('\\','/') + ('/' if isdir(f) else '')
313 for f in lglob(relpath+'*')]
314 else:
315 dirs = [f.replace('\\','/') + "/" for f in lglob(relpath+'*') if isdir(f)]
316 pys = [f.replace('\\','/')
317 for f in lglob(relpath+'*.py') + lglob(relpath+'*.ipy') +
318 lglob(relpath+'*.ipynb') + lglob(relpath + '*.pyw')]
319
320 matches = dirs + pys
321
322 #print('run comp:', dirs+pys) # dbg
323 return [compress_user(p, tilde_expand, tilde_val) for p in matches]
324
325
326def cd_completer(self, event):

Callers 8

test_1Method · 0.90
test_2Method · 0.90
test_3Method · 0.90
test_1Method · 0.90
test_2Method · 0.90
test_3Method · 0.90

Calls 5

expand_userFunction · 0.85
matchMethod · 0.80
replaceMethod · 0.80
compress_userFunction · 0.70
arg_splitFunction · 0.50

Tested by 8

test_1Method · 0.72
test_2Method · 0.72
test_3Method · 0.72
test_1Method · 0.72
test_2Method · 0.72
test_3Method · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…