def generate_byte(bools):
    """Generate a byte based on a list of bools

    :bools: a list of bools from which to generate the byte
    :returns: a byte representing the bools

    """
    bools_len = len(bools)
    if bools_len > 8:
        # we should never encounter this, wrong length
        raise ValueError
    rtn = 0  # initialize the bool we are returning
    for i in range(bools_len):
        rtn += ((1 if bools[bools_len - i - 1] else 0) << i)
    return rtn