@classmethod
    def _prefix_from_ip_string(cls, ip_str):
        # Parse the netmask/hostmask like an IP address.
        try:
            ip_int = cls._ip_int_from_string(ip_str)
        except AddressValueError:
            cls._report_invalid_netmask(ip_str)

        # Try matching a netmask (this would be /1*0*/ as a bitwise regexp).
        # Note that the two ambiguous cases (all-ones and all-zeroes) are
        # treated as netmasks.
        try:
            return cls._prefix_from_ip_int(ip_int)
        except ValueError:
            pass

        # Invert the bits, and try matching a /0+1+/ hostmask instead.
        ip_int ^= cls._ALL_ONES
        try:
            return cls._prefix_from_ip_int(ip_int)
        except ValueError:
            cls._report_invalid_netmask(ip_str)
Create a database for testing in the shell or server.
dataset/ETHPy150Open anzev/hedwig/build/pip/pip/_vendor/ipaddress.py/_IPAddressBase._prefix_from_ip_string--crossover with--dataset/ETHPy150Open jsocol/django-waffle/fabfile.py/syncdb