def to_data(self, key, val): t = self.find_type(key, val) self.add_type(key, t) return bytearray_utils.value_to_ba(t, val)