MCPcopy Create free account
hub / github.com/python/cpython / _ipv4_mapped_ipv6_to_str

Method _ipv4_mapped_ipv6_to_str

Lib/ipaddress.py:1976–1992  ·  view source on GitHub ↗

Return convenient text representation of IPv4-mapped IPv6 address See RFC 4291 2.5.5.2, 2.2 p.3 for details. Returns: A string, 'x:x:x:x:x:x:d.d.d.d', where the 'x's are the hexadecimal values of the six high-order 16-bit pieces of the address, and the 'd's

(self)

Source from the content-addressed store, hash-verified

1974 return '.'.join(reverse_chars) + '.ip6.arpa'
1975
1976 def _ipv4_mapped_ipv6_to_str(self):
1977 """Return convenient text representation of IPv4-mapped IPv6 address
1978
1979 See RFC 4291 2.5.5.2, 2.2 p.3 for details.
1980
1981 Returns:
1982 A string, 'x:x:x:x:x:x:d.d.d.d', where the 'x's are the hexadecimal values of
1983 the six high-order 16-bit pieces of the address, and the 'd's are
1984 the decimal values of the four low-order 8-bit pieces of the
1985 address (standard IPv4 representation) as defined in RFC 4291 2.2 p.3.
1986
1987 """
1988 ipv4_mapped = self.ipv4_mapped
1989 if ipv4_mapped is None:
1990 raise AddressValueError("Can not apply to non-IPv4-mapped IPv6 address %s" % str(self))
1991 high_order_bits = self._ip >> 32
1992 return "%s:%s" % (self._string_from_ip_int(high_order_bits), str(ipv4_mapped))
1993
1994 def __str__(self):
1995 ipv4_mapped = self.ipv4_mapped

Callers 1

__str__Method · 0.95

Calls 3

AddressValueErrorClass · 0.85
strFunction · 0.85
_string_from_ip_intMethod · 0.45

Tested by

no test coverage detected