MCPcopy Index your code
hub / github.com/python/cpython / _explode_shorthand_ip_string

Method _explode_shorthand_ip_string

Lib/ipaddress.py:1861–1880  ·  view source on GitHub ↗

Expand a shortened IPv6 address. Returns: A string, the expanded IPv6 address.

(self)

Source from the content-addressed store, hash-verified

1859 return ':'.join(hextets)
1860
1861 def _explode_shorthand_ip_string(self):
1862 """Expand a shortened IPv6 address.
1863
1864 Returns:
1865 A string, the expanded IPv6 address.
1866
1867 """
1868 if isinstance(self, IPv6Network):
1869 ip_str = str(self.network_address)
1870 elif isinstance(self, IPv6Interface):
1871 ip_str = str(self.ip)
1872 else:
1873 ip_str = str(self)
1874
1875 ip_int = self._ip_int_from_string(ip_str)
1876 hex_str = '%032x' % ip_int
1877 parts = [hex_str[x:x+4] for x in range(0, 32, 4)]
1878 if isinstance(self, (_BaseNetwork, IPv6Interface)):
1879 return '%s/%d' % (':'.join(parts), self._prefixlen)
1880 return ':'.join(parts)
1881
1882 def _reverse_pointer(self):
1883 """Return the reverse DNS pointer name for the IPv6 address.

Callers

nothing calls this directly

Calls 3

_ip_int_from_stringMethod · 0.95
strFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected