def write(self, value):
    self._objlist = []
    self._objtable = {}
    self._objidtable = {}
    self._flatten(value)
    num_objects = len(self._objlist)
    self._object_offsets = ([0] * num_objects)
    self._ref_size = _count_to_size(num_objects)
    self._ref_format = _BINARY_FORMAT[self._ref_size]
    self._fp.write(b'bplist00')
    for obj in self._objlist:
        self._write_object(obj)
    top_object = self._getrefnum(value)
    offset_table_offset = self._fp.tell()
    offset_size = _count_to_size(offset_table_offset)
    offset_format = ('>' + (_BINARY_FORMAT[offset_size] * num_objects))
    self._fp.write(struct.pack(offset_format, *self._object_offsets))
    sort_version = 0
    trailer = (sort_version, offset_size, self._ref_size, num_objects, top_object, offset_table_offset)
    self._fp.write(struct.pack('>5xBBBQQQ', *trailer))
def write(self, value):
    self._objlist = []
    self._objtable = {}
    self._objidtable = {}
    self._flatten(value)
    num_objects = len(self._objlist)
    self._object_offsets = ([0] * num_objects)
    self._ref_size = _count_to_size(num_objects)
    self._ref_format = _BINARY_FORMAT[self._ref_size]
    self._fp.write(b'bplist00')
    for obj in self._objlist:
        self._write_object(obj)
    top_object = self._getrefnum(value)
    offset_table_offset = self._fp.tell()
    offset_size = _count_to_size(offset_table_offset)
    offset_format = ('>' + (_BINARY_FORMAT[offset_size] * num_objects))
    self._fp.write(struct.pack(offset_format, *self._object_offsets))
    sort_version = 0
    trailer = (sort_version, offset_size, self._ref_size, num_objects, top_object, offset_table_offset)
    self._fp.write(struct.pack('>5xBBBQQQ', *trailer))