Callback for when new memory data has been fetched

def new_data(self, mem, addr, data):
        """Callback for when new memory data has been fetched"""
        if mem.id == self.id:
            if addr == 0:
                done = False
                # Check for header
                if data[0:4] == EEPROM_TOKEN:
                    logger.debug('Got new data: {}'.format(data))
                    [self.elements['version'],
                     self.elements['radio_channel'],
                     self.elements['radio_speed'],
                     self.elements['pitch_trim'],
                     self.elements['roll_trim']] = struct.unpack('<BBBff',
                                                                 data[4:15])
                    if self.elements['version'] == 0:
                        done = True
                    elif self.elements['version'] == 1:
                        self.datav0 = data
                        self.mem_handler.read(self, 16, 5)
                else:
                    self.valid = False
                    if self._update_finished_cb:
                        self._update_finished_cb(self)
                        self._update_finished_cb = None

            if addr == 16:
                [radio_address_upper, radio_address_lower] = struct.unpack(
                    '<BI', self.datav0[15:16] + data[0:4])
                self.elements['radio_address'] = int(
                    radio_address_upper) << 32 | radio_address_lower

                logger.debug(self.elements)
                data = self.datav0 + data
                done = True

            if done:
                if self._checksum256(data[:len(data) - 1]) == \
                        data[len(data) - 1]:
                    self.valid = True
                if self._update_finished_cb:
                    self._update_finished_cb(self)
                    self._update_finished_cb = None