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

Method __init__

Lib/ipaddress.py:2293–2339  ·  view source on GitHub ↗

Instantiate a new IPv6 Network object. Args: address: A string or integer representing the IPv6 network or the IP and prefix/netmask. '2001:db8::/128' '2001:db8:0000:0000:0000:0000:0000:0000/128' '2001:db8::'

(self, address, strict=True)

Source from the content-addressed store, hash-verified

2291 _address_class = IPv6Address
2292
2293 def __init__(self, address, strict=True):
2294 """Instantiate a new IPv6 Network object.
2295
2296 Args:
2297 address: A string or integer representing the IPv6 network or the
2298 IP and prefix/netmask.
2299 '2001:db8::/128'
2300 '2001:db8:0000:0000:0000:0000:0000:0000/128'
2301 '2001:db8::'
2302 are all functionally the same in IPv6. That is to say,
2303 failing to provide a subnetmask will create an object with
2304 a mask of /128.
2305
2306 Additionally, an integer can be passed, so
2307 IPv6Network('2001:db8::') ==
2308 IPv6Network(42540766411282592856903984951653826560)
2309 or, more generally
2310 IPv6Network(int(IPv6Network('2001:db8::'))) ==
2311 IPv6Network('2001:db8::')
2312
2313 strict: A boolean. If true, ensure that we have been passed
2314 A true network address, eg, 2001:db8::1000/124 and not an
2315 IP address on a network, eg, 2001:db8::1/124.
2316
2317 Raises:
2318 AddressValueError: If address isn't a valid IPv6 address.
2319 NetmaskValueError: If the netmask isn't valid for
2320 an IPv6 address.
2321 ValueError: If strict was True and a network address was not
2322 supplied.
2323 """
2324 addr, mask = self._split_addr_prefix(address)
2325
2326 self.network_address = IPv6Address(addr)
2327 self.netmask, self._prefixlen = self._make_netmask(mask)
2328 packed = int(self.network_address)
2329 if packed & int(self.netmask) != packed:
2330 if strict:
2331 raise ValueError('%s has host bits set' % self)
2332 else:
2333 self.network_address = IPv6Address(packed &
2334 int(self.netmask))
2335
2336 if self._prefixlen == (self.max_prefixlen - 1):
2337 self.hosts = self.__iter__
2338 elif self._prefixlen == self.max_prefixlen:
2339 self.hosts = lambda: iter((IPv6Address(addr),))
2340
2341 def hosts(self):
2342 """Generate Iterator over usable hosts in a network.

Callers

nothing calls this directly

Calls 4

IPv6AddressClass · 0.85
iterFunction · 0.85
_split_addr_prefixMethod · 0.80
_make_netmaskMethod · 0.45

Tested by

no test coverage detected