def EncodeUrl(base, params, escape_url, use_html_entities):
  """Escape params, combine and append them to base to generate a full URL."""
  real_params = []
  for key, value in params.iteritems():
    if escape_url:
      value = urllib.quote(value)
    if value:
      real_params.append('%s=%s' % (key, value))
  if real_params:
    url = '%s?%s' % (base, '&'.join(real_params))
  else:
    url = base
  if use_html_entities:
    url = cgi.escape(url, quote=True)
  return url
Escape params, combine and append them to base to generate a full URL.
mapreduce/lib/graphy/backends/google_chart_api/util.py