parameters: (uri, component)
return_statement: return (0 <= port <= 65535)
docstring: Determine if the userinfo, host, and port are valid.
docstring_summary: Determine if the userinfo, host, and port are valid.
docstring_tokens: Determine if the userinfo host and port are valid .
function: def subauthority_component_is_valid(uri, component):
      """Determine if the userinfo, host, and port are valid."""
      try:
          subauthority_dict = uri.authority_info()
      except exceptions.InvalidAuthority:
          return False
  
      # If we can parse the authority into sub-components and we're not
      # validating the port, we can assume it's valid.
      if component == 'host':
          return host_is_valid(subauthority_dict['host'])
      elif component != 'port':
          return True
  
      try:
          port = int(subauthority_dict['port'])
      except TypeError:
          # If the port wasn't provided it'll be None and int(None) raises a
          # TypeError
          return True
  
      return (0 <= port <= 65535)
function_tokens: def subauthority_component_is_valid ( uri , component ) : try : subauthority_dict = uri . authority_info ( ) except exceptions . InvalidAuthority : return False # If we can parse the authority into sub-components and we're not # validating the port, we can assume it's valid. if component == 'host' : return host_is_valid ( subauthority_dict [ 'host' ] ) elif component != 'port' : return True try : port = int ( subauthority_dict [ 'port' ] ) except TypeError : # If the port wasn't provided it'll be None and int(None) raises a # TypeError return True return ( 0 <= port <= 65535 )