'Protocol.dataReceived.
Translates bytes into lines, and calls lineReceived (or
rawDataReceived, depending on mode.)'

def dataReceived(self, data):

    if self._busyReceiving:
        self._buffer += data
        return
    try:
        self._busyReceiving = True
        self._buffer += data
        while (self._buffer and (not self.paused)):
            if self.line_mode:
                try:
                    (line, self._buffer) = self._buffer.split(self.delimiter, 1)
                except ValueError:
                    if (len(self._buffer) > self.MAX_LENGTH):
                        (line, self._buffer) = (self._buffer, '')
                        return self.lineLengthExceeded(line)
                    return
                else:
                    lineLength = len(line)
                    if (lineLength > self.MAX_LENGTH):
                        exceeded = ((line + self.delimiter) + self._buffer)
                        self._buffer = ''
                        return self.lineLengthExceeded(exceeded)
                    why = self.lineReceived(line)
                    if (why or (self.transport and self.transport.disconnecting)):
                        return why
            else:
                data = self._buffer
                self._buffer = ''
                why = self.rawDataReceived(data)
                if why:
                    return why
    finally:
        self._busyReceiving = False
