Exemplo n.º 1
0
def unpack_record(record):
    """(record:str) -> oid:str, data:str, refs:str
    The inverse of pack_record().
    """
    oid = record[:8]
    data_length = u32(record[8:12])
    data_end = 12 + data_length
    data = record[12:data_end]
    refs = record[data_end:]
    return oid, data, refs
Exemplo n.º 2
0
 def _read_block(self):
     size_str = self.fp.read(4)
     if len(size_str) == 0:
         raise IOError, "eof"
     size = u32(size_str)
     if size == 0:
         return ''
     result = self.fp.read(size)
     if len(result) != size:
         raise IOError, "short read"
     return result
Exemplo n.º 3
0
 def test_check_p32_u32(self):
     for x in range(3):
         assert len(p32(x)) == 4
         assert x == u32(p32(x))