Make a (netmask, prefix_len) tuple from the given argument. Argument can be: - an integer (the prefix length) - a string representing the prefix length (e.g. "24") - a string representing the prefix netmask (e.g. "255.255.255.0")
(cls, arg)
| 1627 | |
| 1628 | @classmethod |
| 1629 | def _make_netmask(cls, arg): |
| 1630 | """Make a (netmask, prefix_len) tuple from the given argument. |
| 1631 | |
| 1632 | Argument can be: |
| 1633 | - an integer (the prefix length) |
| 1634 | - a string representing the prefix length (e.g. "24") |
| 1635 | - a string representing the prefix netmask (e.g. "255.255.255.0") |
| 1636 | """ |
| 1637 | if arg not in cls._netmask_cache: |
| 1638 | if isinstance(arg, int): |
| 1639 | prefixlen = arg |
| 1640 | if not (0 <= prefixlen <= cls.max_prefixlen): |
| 1641 | cls._report_invalid_netmask(prefixlen) |
| 1642 | else: |
| 1643 | prefixlen = cls._prefix_from_prefix_string(arg) |
| 1644 | netmask = IPv6Address(cls._ip_int_from_prefix(prefixlen)) |
| 1645 | cls._netmask_cache[arg] = netmask, prefixlen |
| 1646 | return cls._netmask_cache[arg] |
| 1647 | |
| 1648 | @classmethod |
| 1649 | def _ip_int_from_string(cls, ip_str): |
nothing calls this directly
no test coverage detected