def _rewrite_url(url):
  """Used by _rewrite_links"""
  scheme, netloc, path, params, query, fragment = urlparse(url)
  if scheme != "http": # scheme
    # Only re-write http URLs, since that's all
    # we proxy.
    return url
  if ":" in netloc: # netloc
    host, port = netloc.rsplit(":", 1)
  else:
    host, port = netloc, str(80)
  path = path or "/"

  try:
    # We may hit invalid urls. Return None to strip out the link entirely.
    out = _reverse(host, port, path)
  except urlresolvers.NoReverseMatch, ex:
    LOGGER.error((url,) % "Encountered malformed URL '%s' when rewriting proxied page.")
    return None

  if query:
    out = out + "?" + query
  return out
dataset/ETHPy150Open cloudera/hue/apps/proxy/src/proxy/views.py/_rewrite_url/swapped operands of `%`