def encode(self, outstream): encoded_block = io.BytesIO() self._encode(encoded_block) encoded_block = encoded_block.getvalue() subblock_length = len(encoded_block) block_length = 12 + subblock_length if subblock_length % 4 != 0: block_length += (4 - (subblock_length % 4)) write_int(self.magic_number, outstream, 32) write_int(block_length, outstream, 32) write_bytes_padded(outstream, encoded_block) write_int(block_length, outstream, 32)
def write(self, outstream): """Writes this block into the given output stream""" encoded_block = six.BytesIO() self._encode(encoded_block) encoded_block = encoded_block.getvalue() subblock_length = len(encoded_block) block_length = 12 + subblock_length if subblock_length % 4 != 0: block_length += (4 - (subblock_length % 4)) write_int(self.magic_number, outstream, 32) write_int(block_length, outstream, 32) write_bytes_padded(outstream, encoded_block) write_int(block_length, outstream, 32)
def _write(self, outstream): """Writes this block into the given output stream""" encoded_block = io.BytesIO() self._encode(encoded_block) encoded_block = encoded_block.getvalue() subblock_length = len(encoded_block) if subblock_length == 0: return block_length = 12 + subblock_length if subblock_length % 4 != 0: block_length += 4 - (subblock_length % 4) write_int(self.magic_number, outstream, 32, endianness=self.section.endianness) write_int(block_length, outstream, 32, endianness=self.section.endianness) write_bytes_padded(outstream, encoded_block) write_int(block_length, outstream, 32, endianness=self.section.endianness)
def _encode(self, outstream): write_int(0x1A2B3C4D, outstream, 32, endianness=self.endianness) super(SectionHeader, self)._encode(outstream)
def _encode(self, outstream): write_int(0x1A2B3C4D, outstream, 32) struct_encode(self.schema, self, outstream, endianness=self.endianness)