MCPcopy Index your code
hub / github.com/RustPython/RustPython / _make_netmask

Method _make_netmask

Lib/ipaddress.py:1628–1645  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

isinstanceFunction · 0.85
IPv6AddressClass · 0.85
_ip_int_from_prefixMethod · 0.80

Tested by

no test coverage detected