parameters: (uri)
docstring: Re-quote the given URI.
  
      This function passes the given URI through an unquote/quote cycle to
      ensure that it is fully and consistently quoted.
  
      :rtype: str
docstring_summary: Re-quote the given URI.
docstring_tokens: Re - quote the given URI .
function: def requote_uri(uri):
      """Re-quote the given URI.
  
      This function passes the given URI through an unquote/quote cycle to
      ensure that it is fully and consistently quoted.
  
      :rtype: str
      """
      safe_with_percent = "!#$%&'()*+,/:;=?@[]~"
      safe_without_percent = "!#$&'()*+,/:;=?@[]~"
      try:
          # Unquote only the unreserved characters
          # Then quote only illegal characters (do not quote reserved,
          # unreserved, or '%')
          return quote(unquote_unreserved(uri), safe=safe_with_percent)
      except InvalidURL:
          # We couldn't unquote the given URI, so let's try quoting it, but
          # there may be unquoted '%'s in the URI. We need to make sure they're
          # properly quoted so they do not cause issues elsewhere.
          return quote(uri, safe=safe_without_percent)
function_tokens: def requote_uri ( uri ) : safe_with_percent = "!#$%&'()*+,/:;=?@[]~" safe_without_percent = "!#$&'()*+,/:;=?@[]~" try : # Unquote only the unreserved characters # Then quote only illegal characters (do not quote reserved, # unreserved, or '%') return quote ( unquote_unreserved ( uri ) , safe = safe_with_percent ) except InvalidURL : # We couldn't unquote the given URI, so let's try quoting it, but # there may be unquoted '%'s in the URI. We need to make sure they're # properly quoted so they do not cause issues elsewhere. return quote ( uri , safe = safe_without_percent )