@classmethod<EOL><INDENT>def _prefix_from_ip_int(cls, ip_int):<DEDENT>
trailing_zeroes = _count_righthand_zero_bits(ip_int,<EOL>cls._max_prefixlen)<EOL>prefixlen = cls._max_prefixlen - trailing_zeroes<EOL>leading_ones = ip_int >> trailing_zeroes<EOL>all_ones = (<NUM_LIT:1> << prefixlen) - <NUM_LIT:1><EOL>if leading_ones != all_ones:<EOL><INDENT>byteslen = cls._max_prefixlen // <NUM_LIT:8><EOL>details = _compat_to_bytes(ip_int, byteslen, '<STR_LIT>')<EOL>msg = '<STR_LIT>'<EOL>raise ValueError(msg % details)<EOL><DEDENT>return prefixlen<EOL>
Return prefix length from the bitwise netmask.

        Args:
            ip_int: An integer, the netmask in expanded bitwise format

        Returns:
            An integer, the prefix length.

        Raises:
            ValueError: If the input intermingles zeroes & ones