def validate_host(host, allowed_hosts):
 host = host.lower()
 if (not host_validation_re.match(host)):
  return False
 if (host[(-1)] == u']'):
  domain = host
 else:
  domain = host.rsplit(u':', 1)[0]
 for pattern in allowed_hosts:
  pattern = pattern.lower()
  match = ((pattern == u'*') or (pattern.startswith(u'.') and (domain.endswith(pattern) or (domain == pattern[1:]))) or (pattern == domain))
  if match:
   return True
 return False

def validate_host ( host , allowed_hosts ) : host = host . lower ( ) if ( not host_validation_re . match ( host ) ) : return False if ( host [ ( - 1 ) ] == u']' ) : domain = host else : domain = host . rsplit ( u':' , 1 ) [ 0 ] for pattern in allowed_hosts : pattern = pattern . lower ( ) match = ( ( pattern == u'*' ) or ( pattern . startswith ( u'.' ) and ( domain . endswith ( pattern ) or ( domain == pattern [ 1 : ] ) ) ) or ( pattern == domain ) ) if match : return True return False
validate the given host for this site .