def _is_same_origin(websocket_origin, host_scheme, host_port, host_policy):
 if (websocket_origin == 'null'):
  return False
 if ((not isinstance(websocket_origin, tuple)) or (not (len(websocket_origin) == 3))):
  raise ValueError("'websocket_origin' must be a 3-tuple")
 (origin_scheme, origin_host, origin_port) = websocket_origin
 template = '{scheme}://{host}:{port}'
 origin_header = template.format(scheme=origin_scheme, host=origin_host, port=origin_port)
 for origin_pattern in host_policy:
  if origin_pattern.match(origin_header):
   return True
 return False

def _is_same_origin ( websocket_origin , host_scheme , host_port , host_policy ) : if ( websocket_origin == 'null' ) : return False if ( ( not isinstance ( websocket_origin , tuple ) ) or ( not ( len ( websocket_origin ) == 3 ) ) ) : raise ValueError ( "'websocket_origin' must be a 3-tuple" ) ( origin_scheme , origin_host , origin_port ) = websocket_origin template = '{scheme}://{host}:{port}' origin_header = template . format ( scheme = origin_scheme , host = origin_host , port = origin_port ) for origin_pattern in host_policy : if origin_pattern . match ( origin_header ) : return True return False
internal helper .