Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 def _encode(self, outstream):
     write_int(0x1A2B3C4D, outstream, 32, endianness=self.endianness)
     super(SectionHeader, self)._encode(outstream)
Esempio n. 5
0
 def _encode(self, outstream):
     write_int(0x1A2B3C4D, outstream, 32)
     struct_encode(self.schema, self, outstream, endianness=self.endianness)