def mask_bits(bitstring):
    """Returns an int corresponding to the bitmask of the bitpattern

    For example "100xx01" is translated to 0b1110011.

    :returns: The integer value where only don't cares are mapped to 0
    :rtype: int
    """

    return int(bitstring.translate({ord('x'): '0', ord('0'): '1'}), 2)