def write(self): ret = "" for pp_item, pp_type, _ in self._compound: conv = select_converter(pp_type) ret += conv(self.data[pp_item], pp_type).write() ret += Array(self.data['essence_containers'], 'Batch of Universal Labels').write() self.pos = self.fdesc.tell() self.length = len(ret) self.fdesc.write(self.key + self.ber_encode_length(self.length, bytes_num=8).decode('hex_codec') + ret) return
def write(self): ret = "" for pp_item, pp_type, _ in self._compound: conv = select_converter(pp_type) ret += conv(self.data[pp_item], pp_type).write() ret += Array(self.data['essence_containers'], 'Batch of Universal Labels').write() self.pos = self.fdesc.tell() self.length = len(ret) self.fdesc.write(self.key + self.ber_encode_length( self.length, bytes_num=8).decode('hex_codec') + ret) return
def read(self): idx = 0 data = self.fdesc.read(self.length) # Read Partition Pack items for pp_item, pp_type, pp_size in self._compound: conv = select_converter(pp_type) self.data[pp_item] = conv(data[idx:idx+pp_size], pp_type).read() idx += pp_size # Read essence containers list, if any self.data['essence_containers'] = Array(data[idx:], 'Batch of Universal Labels').read() self.__smtpe_377m_check() if self.debug: print "%d essences in partition:" % len(self.data['essence_containers']) return
def read(self): idx = 0 data = self.fdesc.read(self.length) # Read Partition Pack items for pp_item, pp_type, pp_size in self._compound: conv = select_converter(pp_type) self.data[pp_item] = conv(data[idx:idx + pp_size], pp_type).read() idx += pp_size # Read essence containers list, if any self.data['essence_containers'] = Array( data[idx:], 'Batch of Universal Labels').read() self.__smtpe_377m_check() if self.debug: print "%d essences in partition:" % len( self.data['essence_containers']) return