#NEWLINE# def complete( self , text , state ) : #NEWLINE# #INDENT# '\n        Complete\n        ' #NEWLINE# response = None #NEWLINE# if ( state == 0 ) : #NEWLINE# #INDENT# origline = readline . get_line_buffer ( ) #NEWLINE# begin = readline . get_begidx ( ) #NEWLINE# end = readline . get_endidx ( ) #NEWLINE# being_completed = origline [ begin : end ] #NEWLINE# words = origline . split ( ) #NEWLINE# if ( not words ) : #NEWLINE# #INDENT# self . current_candidates = sorted ( [ c for c in self . options ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( begin == 0 ) : #NEWLINE# #INDENT# candidates = [ c for c in self . options ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( words [ ( - 1 ) ] in self . options [ words [ 0 ] ] ) : #NEWLINE# #INDENT# candidates = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# first = words [ 0 ] #NEWLINE# candidates = self . options [ first ] #NEWLINE# #UNINDENT# #UNINDENT# if being_completed : #NEWLINE# #INDENT# self . current_candidates = [ w for w in candidates if w . startswith ( being_completed ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . current_candidates = candidates #NEWLINE# #UNINDENT# #UNINDENT# except ( KeyError , IndexError ) : #NEWLINE# #INDENT# self . current_candidates = [ ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# response = self . current_candidates [ state ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# response = None #NEWLINE# #UNINDENT# return response