def dataReceived(self, data):
        """
        Interpret data from a request or response body which uses the
        I{chunked} Transfer-Encoding.
        """
        data = self._buffer + data
        self._buffer = ''
        while data:
            if self.state == 'chunk-length':
                if data in '\r\n':
                    line, rest = data.split('\r\n', 1)
                    parts = line.split(';')
                    self.length = int(parts[0], 16)
                    if self.length == 0:
                        self.state = 'trailer'
                        self.finish = True
                    else:
                        self.state = 'body'
                    data = rest
                else:
                    self._buffer = data
                    data = ''
            elif self.state == 'trailer':
                if data.startswith('\r\n'):
                    data = data[2:]
                    if self.finish:
                        self.state = 'finished'
                        self.finishCallback(data)
                        data = ''
                    else:
                        self.state = 'chunk-length'
                else:
                    self._buffer = data
                    data = ''
            elif self.state == 'body':
                if len(data) >= self.length:
                    chunk, data = data[:self.length], data[self.length:]
                    self.dataCallback(chunk)
                    self.state = 'trailer'
                elif len(data) < self.length:
                    self.length -= len(data)
                    self.dataCallback(data)
                    data = ''
            elif self.state == 'finished':
                raise RuntimeError(
                    "_ChunkedTransferDecoder.dataReceived called after last "
                    "chunk was processed")
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/web/http.py/_ChunkedTransferDecoder.dataReceived/swapped operands of `in`