MCPcopy Create free account
hub / github.com/apache/impala / split_host_port

Function split_host_port

tests/common/network.py:36–51  ·  view source on GitHub ↗

Checks if the host name also contains a port and separates the two. Returns either (host, None) or (host, port). Detects if host is an ipv6 address like "[::]" and removes the brackets from it.

(host_port)

Source from the content-addressed store, hash-verified

34
35
36def split_host_port(host_port):
37 """Checks if the host name also contains a port and separates the two.
38 Returns either (host, None) or (host, port). Detects if host is an ipv6 address
39 like "[::]" and removes the brackets from it.
40 """
41 is_ipv6_address = host_port[0] == "["
42 if is_ipv6_address:
43 parts = host_port[1:].split("]")
44 if len(parts) == 1 or not parts[1]:
45 return (parts[0], None)
46 return (parts[0], int(parts[1][1:]))
47 else:
48 parts = host_port.split(":")
49 if len(parts) == 1:
50 return (parts[0], None)
51 return (parts[0], int(parts[1]))
52
53
54def to_host_port(host, port):

Callers 2

__init__Method · 0.90
connectMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected