/usr/lib/python3/dist-packages/kazoo/hosts.py is in python3-kazoo 2.2.1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import random
from six.moves import urllib_parse
def collect_hosts(hosts, randomize=True):
"""Collect a set of hosts and an optional chroot from a string."""
host_ports, chroot = hosts.partition("/")[::2]
chroot = "/" + chroot if chroot else None
result = []
for host_port in host_ports.split(","):
# put all complexity of dealing with
# IPv4 & IPv6 address:port on the urlsplit
res = urllib_parse.urlsplit("xxx://" + host_port)
host = res.hostname
if host is None:
raise ValueError("bad hostname")
port = int(res.port) if res.port else 2181
result.append((host.strip(), port))
if randomize:
random.shuffle(result)
return result, chroot
|