import struct


def reformat_int(src_format, dst_format, value):
    """Reformat a packed integer. This is used to convert between signed
    and unsigned, not network and host endian (which protobuf is supposed
    to take care of)."""

    return struct.unpack(dst_format, struct.pack(src_format, value))[0]