def complete(text, state):
tokens = readline.get_line_buffer().split()
thistoken = tokens[-1]
thisdir = os.path.dirname(thistoken)
thispath = os.path.abspath(os.path.join(current_path, thisdir))
if thispath != '/':
thispath += '/'
if thispath not in tab_complete:
populateTabComplete(thispath)
if thispath not in tab_complete:
return False
suffix = [x for x in tab_complete[thispath] if x.startswith(text)][state:]
if len(suffix):
result = suffix[0]
if result[-1] != '/':
result += ' '
return result
return False
评论列表
文章目录