environment/lib/python2.7/site-packages/IPython/core/completerlib.py
def cd_completer(self, event):
    """Completer function for cd, which only returns directories."""
    ip = get_ipython()
    relpath = event.symbol

    #print(event) # dbg
    if event.line.endswith('-b') or ' -b ' in event.line:
        # return only bookmark completions
        bkms = self.db.get('bookmarks', None)
        if bkms:
            return bkms.keys()
        else:
            return []

    if event.symbol == '-':
        width_dh = str(len(str(len(ip.user_ns['_dh']) + 1)))
        # jump in directory history by number
        fmt = '-%0' + width_dh +'d [%s]'
        ents = [ fmt % (i,s) for i,s in enumerate(ip.user_ns['_dh'])]
        if len(ents) > 1:
            return ents
        return []

    if event.symbol.startswith('--'):
        return ["--" + os.path.basename(d) for d in ip.user_ns['_dh']]

    # Expand ~ in path and normalize directory separators.
    relpath, tilde_expand, tilde_val = expand_user(relpath)
    relpath = relpath.replace('\\','/')

    found = []
    for d in [f.replace('\\','/') + '/' 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 TryNext

        found.append(d)

    if not found:
        if os.path.isdir(relpath):
            return [compress_user(relpath, tilde_expand, tilde_val)]

        # if no completions so far, try bookmarks
        bks = self.db.get('bookmarks',{}).iterkeys()
        bkmatches = [s for s in bks if s.startswith(event.symbol)]
        if bkmatches:
            return bkmatches

        raise TryNext

    return [compress_user(p, tilde_expand, tilde_val) for p in found]
def cd_completer(self, event):
    ip = get_ipython()
    relpath = event.symbol

    #print(event) # dbg
    if event.line.endswith('-b') or ' -b ' in event.line:
        # return only bookmark completions
        bkms = self.db.get('bookmarks', None)
        if bkms:
            return bkms.keys()
        else:
            return []

    if event.symbol == '-':
        width_dh = str(len(str(len(ip.user_ns['_dh']) + 1)))
        # jump in directory history by number
        fmt = '-%0' + width_dh +'d [%s]'
        ents = [ fmt % (i,s) for i,s in enumerate(ip.user_ns['_dh'])]
        if len(ents) > 1:
            return ents
        return []

    if event.symbol.startswith('--'):
        return ["--" + os.path.basename(d) for d in ip.user_ns['_dh']]

    # Expand ~ in path and normalize directory separators.
    relpath, tilde_expand, tilde_val = expand_user(relpath)
    relpath = relpath.replace('\\','/')

    found = []
    for d in [f.replace('\\','/') + '/' 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 TryNext

        found.append(d)

    if not found:
        if os.path.isdir(relpath):
            return [compress_user(relpath, tilde_expand, tilde_val)]

        # if no completions so far, try bookmarks
        bks = self.db.get('bookmarks',{}).iterkeys()
        bkmatches = [s for s in bks if s.startswith(event.symbol)]
        if bkmatches:
            return bkmatches

        raise TryNext

    return [compress_user(p, tilde_expand, tilde_val) for p in found]
def cd_completer ( self , event ) : ip = get_ipython ( ) relpath = event . symbol #print(event) # dbg if event . line . endswith ( '-b' ) or ' -b ' in event . line : # return only bookmark completions bkms = self . db . get ( 'bookmarks' , None ) if bkms : return bkms . keys ( ) else : return [ ] if event . symbol == '-' : width_dh = str ( len ( str ( len ( ip . user_ns [ '_dh' ] ) + 1 ) ) ) # jump in directory history by number fmt = '-%0' + width_dh + 'd [%s]' ents = [ fmt % ( i , s ) for i , s in enumerate ( ip . user_ns [ '_dh' ] ) ] if len ( ents ) > 1 : return ents return [ ] if event . symbol . startswith ( '--' ) : return [ "--" + os . path . basename ( d ) for d in ip . user_ns [ '_dh' ] ] # Expand ~ in path and normalize directory separators. relpath , tilde_expand , tilde_val = expand_user ( relpath ) relpath = relpath . replace ( '\\' , '/' ) found = [ ] for d in [ f . replace ( '\\' , '/' ) + '/' 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 TryNext found . append ( d ) if not found : if os . path . isdir ( relpath ) : return [ compress_user ( relpath , tilde_expand , tilde_val ) ] # if no completions so far, try bookmarks bks = self . db . get ( 'bookmarks' , { } ) . iterkeys ( ) bkmatches = [ s for s in bks if s . startswith ( event . symbol ) ] if bkmatches : return bkmatches raise TryNext return [ compress_user ( p , tilde_expand , tilde_val ) for p in found ]
Completer function for cd, which only returns directories.
Completer function for cd which only returns directories .