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

Function _is_local_authority

Lib/urllib/request.py:1485–1503  ·  view source on GitHub ↗
(authority, resolve)

Source from the content-addressed store, hash-verified

1483 file_open = open_local_file
1484
1485def _is_local_authority(authority, resolve):
1486 # Compare hostnames
1487 if not authority or authority == 'localhost':
1488 return True
1489 try:
1490 hostname = socket.gethostname()
1491 except (socket.gaierror, AttributeError):
1492 pass
1493 else:
1494 if authority == hostname:
1495 return True
1496 # Compare IP addresses
1497 if not resolve:
1498 return False
1499 try:
1500 address = socket.gethostbyname(authority)
1501 except (socket.gaierror, AttributeError, UnicodeEncodeError):
1502 return False
1503 return address in FileHandler().get_names()
1504
1505class FTPHandler(BaseHandler):
1506 def ftp_open(self, req):

Callers 1

url2pathnameFunction · 0.85

Calls 2

FileHandlerClass · 0.70
get_namesMethod · 0.45

Tested by

no test coverage detected