##// END OF EJS Templates
Small fix for %run which wouldn't complete arguments to scripts if they...
fperez -
Show More
@@ -170,14 +170,26 b' def runlistpy(self, event):'
170 comps = shlex.split(event.line)
170 comps = shlex.split(event.line)
171 relpath = (len(comps) > 1 and comps[-1] or '')
171 relpath = (len(comps) > 1 and comps[-1] or '')
172
172
173 #print "rp",relpath # dbg
173 #print "\nev=",event # dbg
174 #print "rp=",relpath # dbg
175 #print 'comps=',comps # dbg
176
174 lglob = glob.glob
177 lglob = glob.glob
175 isdir = os.path.isdir
178 isdir = os.path.isdir
176 if relpath.startswith('~'):
179 if relpath.startswith('~'):
177 relpath = os.path.expanduser(relpath)
180 relpath = os.path.expanduser(relpath)
178 dirs = [f.replace('\\','/') + "/" for f in lglob(relpath+'*')
181 dirs = [f.replace('\\','/') + "/" for f in lglob(relpath+'*')
179 if isdir(f)]
182 if isdir(f)]
180 pys = [f.replace('\\','/') for f in lglob(relpath+'*.py') + lglob(relpath+'*.ipy')]
183
184 # Find if the user has already typed the first filename, after which we
185 # should complete on all files, since after the first one other files may
186 # be arguments to the input script.
187 #filter(
188 if filter(lambda f: f.endswith('.py') or f.endswith('.ipy'),comps):
189 pys = [f.replace('\\','/') for f in lglob('*')]
190 else:
191 pys = [f.replace('\\','/')
192 for f in lglob(relpath+'*.py') + lglob(relpath+'*.ipy')]
181 return dirs + pys
193 return dirs + pys
182
194
183 ip.set_hook('complete_command', runlistpy, str_key = '%run')
195 ip.set_hook('complete_command', runlistpy, str_key = '%run')
@@ -1,5 +1,11 b''
1 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
1 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
2
2
3 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
4 bug where only .ipy or .py would be completed. Once the first
5 argument to %run has been given, all completions are valid because
6 they are the arguments to the script, which may well be non-python
7 filenames.
8
3 * IPython/irunner.py (InteractiveRunner.run_source): major updates
9 * IPython/irunner.py (InteractiveRunner.run_source): major updates
4 to irunner to allow it to correctly support real doctesting of
10 to irunner to allow it to correctly support real doctesting of
5 out-of-process ipython code.
11 out-of-process ipython code.
General Comments 0
You need to be logged in to leave comments. Login now