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

Function getfqdn

Lib/socket.py:808–832  ·  view source on GitHub ↗

Get fully qualified domain name from name. An empty argument is interpreted as meaning the local host. First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available and `name` was given, it is returned unchanged. If `name` w

(name='')

Source from the content-addressed store, hash-verified

806
807
808def getfqdn(name=''):
809 """Get fully qualified domain name from name.
810
811 An empty argument is interpreted as meaning the local host.
812
813 First the hostname returned by gethostbyaddr() is checked, then
814 possibly existing aliases. In case no FQDN is available and `name`
815 was given, it is returned unchanged. If `name` was empty, '0.0.0.0' or '::',
816 hostname from gethostname() is returned.
817 """
818 name = name.strip()
819 if not name or name in ('0.0.0.0', '::'):
820 name = gethostname()
821 try:
822 hostname, aliases, ipaddrs = gethostbyaddr(name)
823 except error:
824 pass
825 else:
826 aliases.insert(0, hostname)
827 for name in aliases:
828 if '.' in name:
829 break
830 else:
831 name = hostname
832 return name
833
834
835_GLOBAL_DEFAULT_TIMEOUT = object()

Callers

nothing calls this directly

Calls 3

gethostnameFunction · 0.85
stripMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…