From 58b4ce4e54f60aec92e088020ae9c7cc5f547231 2006-12-07 18:59:45 From: vivainio Date: 2006-12-07 18:59:45 Subject: [PATCH] yet again resort to complex file name completer more often --- diff --git a/IPython/Extensions/ipy_stock_completers.py b/IPython/Extensions/ipy_stock_completers.py index 6949b9e..f7931a8 100755 --- a/IPython/Extensions/ipy_stock_completers.py +++ b/IPython/Extensions/ipy_stock_completers.py @@ -184,7 +184,7 @@ ip.set_hook('complete_command', runlistpy, str_key = '%run') def cd_completer(self, event): relpath = event.symbol - # print event # dbg + #print event # dbg if '-b' in event.line: # return only bookmark completions bkms = self.db.get('bookmarks',{}) @@ -198,20 +198,20 @@ def cd_completer(self, event): return ents return [] - if sys.platform != 'win32': - protect = lambda n: n - else: - def protect(n): - return n.replace('\\' ,'/').replace(' ', '\\ ') - if relpath.startswith('~'): relpath = os.path.expanduser(relpath).replace('\\','/') - found = [protect(f)+'/' for f in glob.glob(relpath+'*') if os.path.isdir(f)] - # print "f",found # dbg + found = [] + for d in [f + '/' for f in glob.glob(relpath+'*') if os.path.isdir(f)]: + if ' ' in d: + # we don't want to deal with any of that, complex code + # for this is elsewhere + raise IPython.ipapi.TryNext + found.append( d ) + if not found: if os.path.isdir(relpath): return [relpath] - raise IPython.ipapi.TryNext + raise IPython.ipapi.TryNext return found ip.set_hook('complete_command', cd_completer, str_key = '%cd')