def new_data(self, data):
        spawn = self.spawn
        searcher = self.searcher

        incoming = spawn.buffer + data
        freshlen = len(data)
        index = searcher.search(incoming, freshlen, self.searchwindowsize)
        if index >= 0:
            spawn.buffer = incoming[searcher.end:]
            spawn.before = incoming[: searcher.start]
            spawn.after = incoming[searcher.start: searcher.end]
            spawn.match = searcher.match
            spawn.match_index = index
            # Found a match
            return index

        spawn.buffer = incoming
dataset/ETHPy150Open Calysto/metakernel/metakernel/pexpect.py/Expecter.new_data/original