'recvline_pred(pred, keepends = False) -> str
Receive data until ``pred(line)`` returns a truthy value.
Drop all other data.
If the request is not satisfied before ``timeout`` seconds pass,
all data is buffered and an empty string (``\'\'``) is returned.
Arguments:
pred(callable): Function to call.  Returns the line for which
this function returns :const:`True`.
Examples:
>>> t = tube()
>>> t.recv_raw = lambda n: "Foo\nBar\nBaz\n"
>>> t.recvline_pred(lambda line: line == "Bar\n")
\'Bar\'
>>> t.recvline_pred(lambda line: line == "Bar\n", keepends=True)
\'Bar\n\'
>>> t.recvline_pred(lambda line: line == \'Nope!\', timeout=0.1)'

def recvline_pred(self, pred, keepends=False, timeout=default):

    tmpbuf = Buffer()
    line = ''
    with self.countdown(timeout):
        while self.countdown_active():
            try:
                line = self.recvline(keepends=True)
            except Exception:
                self.buffer.add(tmpbuf)
                raise
            if (not line):
                self.buffer.add(tmpbuf)
                return ''
            if pred(line):
                if (not keepends):
                    line = line[:(- len(self.newline))]
                return line
            else:
                tmpbuf.add(line)
    return ''
