def parse_valid_host_port(host_port):
 try:
  try:
   (host, port) = netutils.parse_host_port(host_port)
  except Exception:
   raise ValueError((_('Host and port "%s" is not valid.') % host_port))
  if (not netutils.is_valid_port(port)):
   raise ValueError((_('Port "%s" is not valid.') % port))
  if (not (netutils.is_valid_ipv6(host) or netutils.is_valid_ipv4(host) or is_valid_hostname(host) or is_valid_fqdn(host))):
   raise ValueError((_('Host "%s" is not valid.') % host))
 except Exception as ex:
  raise ValueError((_('%s Please specify a host:port pair, where host is an IPv4 address, IPv6 address, hostname, or FQDN. If using an IPv6 address, enclose it in brackets separately from the port (i.e., "[fe80::a:b:c]:9876").') % ex))
 return (host, int(port))

def parse_valid_host_port ( host_port ) : try : try : ( host , port ) = netutils . parse_host_port ( host_port ) except Exception : raise ValueError ( ( _ ( 'Host and port "%s" is not valid.' ) % host_port ) ) if ( not netutils . is_valid_port ( port ) ) : raise ValueError ( ( _ ( 'Port "%s" is not valid.' ) % port ) ) if ( not ( netutils . is_valid_ipv6 ( host ) or netutils . is_valid_ipv4 ( host ) or is_valid_hostname ( host ) or is_valid_fqdn ( host ) ) ) : raise ValueError ( ( _ ( 'Host "%s" is not valid.' ) % host ) ) except Exception as ex : raise ValueError ( ( _ ( '%s Please specify a host:port pair, where host is an IPv4 address, IPv6 address, hostname, or FQDN. If using an IPv6 address, enclose it in brackets separately from the port (i.e., "[fe80::a:b:c]:9876").' ) % ex ) ) return ( host , int ( port ) )
given a "host:port" string .