##// END OF EJS Templates
yet again resort to complex file name completer more often
vivainio -
Show More
@@ -184,7 +184,7 b" ip.set_hook('complete_command', runlistpy, str_key = '%run')"
184
184
185 def cd_completer(self, event):
185 def cd_completer(self, event):
186 relpath = event.symbol
186 relpath = event.symbol
187 # print event # dbg
187 #print event # dbg
188 if '-b' in event.line:
188 if '-b' in event.line:
189 # return only bookmark completions
189 # return only bookmark completions
190 bkms = self.db.get('bookmarks',{})
190 bkms = self.db.get('bookmarks',{})
@@ -198,20 +198,20 b' def cd_completer(self, event):'
198 return ents
198 return ents
199 return []
199 return []
200
200
201 if sys.platform != 'win32':
202 protect = lambda n: n
203 else:
204 def protect(n):
205 return n.replace('\\' ,'/').replace(' ', '\\ ')
206
207 if relpath.startswith('~'):
201 if relpath.startswith('~'):
208 relpath = os.path.expanduser(relpath).replace('\\','/')
202 relpath = os.path.expanduser(relpath).replace('\\','/')
209 found = [protect(f)+'/' for f in glob.glob(relpath+'*') if os.path.isdir(f)]
203 found = []
210 # print "f",found # dbg
204 for d in [f + '/' for f in glob.glob(relpath+'*') if os.path.isdir(f)]:
205 if ' ' in d:
206 # we don't want to deal with any of that, complex code
207 # for this is elsewhere
208 raise IPython.ipapi.TryNext
209 found.append( d )
210
211 if not found:
211 if not found:
212 if os.path.isdir(relpath):
212 if os.path.isdir(relpath):
213 return [relpath]
213 return [relpath]
214 raise IPython.ipapi.TryNext
214 raise IPython.ipapi.TryNext
215 return found
215 return found
216
216
217 ip.set_hook('complete_command', cd_completer, str_key = '%cd')
217 ip.set_hook('complete_command', cd_completer, str_key = '%cd')
General Comments 0
You need to be logged in to leave comments. Login now