Пример #1
0
    def test_unpack_from(self):
        '''
        TODO: just a sanity test for now.  Needs far more testing.
        '''
        import array
        _struct.unpack_from("", array.array("c"))

        self.assertEqual(_struct.unpack_from("", array.array("c")), ())
Пример #2
0
def test_unpack_from():
    '''
    TODO: just a sanity test for now.  Needs far more testing.
    '''
    import array
    _struct.unpack_from("", array.array("c"))
    
    AreEqual(_struct.unpack_from("", array.array("c")),
             ())
Пример #3
0
 def get_ref_block_params(self):
     props = self.get_dynamic_global_properties()
     ref_block_num = props['head_block_number'] - 1 & 0xFFFF
     ref_block = self.get_block(props['head_block_number'])
     ref_block_prefix = _struct.unpack_from(
         "<I", unhexlify(ref_block["previous"]), 4)[0]
     return ref_block_num, ref_block_prefix
Пример #4
0
def getUInt8A(data, offset, size):
    end = int(offset + size)
    assert end <= len(
        data), "Trying to read UInt8 array beyond data end (%d, %X > %X)" % (
            size, end, len(data))
    val = unpack_from('<' + 'B' * int(size), data, offset)
    val = list(val)
    return val, end
Пример #5
0
def getSInt32A(data, offset, size):
    val = unpack_from('<' + 'l' * int(size), data, offset)
    val = list(val)
    return val, int(offset + 4 * size)
Пример #6
0
def getUInt16A(data, offset, size):
    val = unpack_from('<' + 'H' * int(size), data, offset)
    val = list(val)
    return val, int(offset + 2 * size)
Пример #7
0
def getFloat64A(data, offset, size):
    val = unpack_from('<' + 'd' * int(size), data, offset)
    val = list(val)
    return val, int(offset + 8 * size)
Пример #8
0
def getFloat32A(data, offset, size):
    singles = unpack_from('<' + 'f' * int(size), data, offset)
    val = [float(s) for s in singles]
    return val, int(offset + 4 * size)