def complete(self, text, state):
        response = None
        if state == 0:
            origline = readline.get_line_buffer()
            begin = readline.get_begidx()
            end = readline.get_endidx()
            being_completed = origline[begin:end]
            words = origline.split()

            if not words:
                self.current_candidates = sorted([c for c in self.options])
            else:
                try:
                    if begin == 0:
                        candidates = [c for c in self.options]
                    elif words[-1] in self.options[words[0]]:
                        candidates = []
                    else:
                        first = words[0]
                        candidates = self.options[first]

                    if being_completed:
                        self.current_candidates = [w for w in candidates
                                                   if w.startswith(being_completed)]
                    else:
                        self.current_candidates = candidates

                except (KeyError, IndexError):
                    self.current_candidates = []

        try:
            response = self.current_candidates[state]
        except IndexError:
            response = None
        return response
Decorator for canvas route
dataset/ETHPy150Open DTVD/rainbowstream/rainbowstream/interactive.py/RainbowCompleter.complete--crossover with--dataset/ETHPy150Open demianbrecht/flask-canvas/flask_canvas.py/_canvas_route