def magic_run_completer(self, event):
comps = arg_split(event.line, strict=False)<EOL>relpath = (len(comps) > <NUM_LIT:1> and comps[-<NUM_LIT:1>] or '<STR_LIT>').strip("<STR_LIT>")<EOL>lglob = glob.glob<EOL>isdir = os.path.isdir<EOL>relpath, tilde_expand, tilde_val = expand_user(relpath)<EOL>dirs = [f.replace('<STR_LIT:\\>','<STR_LIT:/>') + "<STR_LIT:/>" for f in lglob(relpath+'<STR_LIT:*>') if isdir(f)]<EOL>if filter(magic_run_re.match, comps):<EOL><INDENT>pys =  [f.replace('<STR_LIT:\\>','<STR_LIT:/>') for f in lglob('<STR_LIT:*>')]<EOL><DEDENT>else:<EOL><INDENT>pys =  [f.replace('<STR_LIT:\\>','<STR_LIT:/>')<EOL>for f in lglob(relpath+'<STR_LIT>') + lglob(relpath+'<STR_LIT>') +<EOL>lglob(relpath + '<STR_LIT>')]<EOL><DEDENT>return [compress_user(p, tilde_expand, tilde_val) for p in dirs+pys]<EOL>
Complete files that end in .py or .ipy for the %run command.