'This method checks the to see if a trust root represents a
reasonable (sane) set of URLs.  \'http://*.com/\', for example
is not a reasonable pattern, as it cannot meaningfully specify
the site claiming it.  This function attempts to find many
related examples, but it can only work via heuristics.
Negative responses from this method should be treated as
advisory, used only to alert the user to examine the trust
root carefully.
@return: Whether the trust root is sane
@rtype: C{bool}'

def isSane(self):

    if (self.host == 'localhost'):
        return True
    host_parts = self.host.split('.')
    if self.wildcard:
        assert (host_parts[0] == ''), host_parts
        del host_parts[0]
    if (host_parts and (not host_parts[(-1)])):
        del host_parts[(-1)]
    if (not host_parts):
        return False
    if ('' in host_parts):
        return False
    tld = host_parts[(-1)]
    if (tld not in _top_level_domains):
        return False
    if (len(host_parts) == 1):
        return False
    if self.wildcard:
        if ((len(tld) == 2) and (len(host_parts[(-2)]) <= 3)):
            return (len(host_parts) > 2)
    return True
