parameters: (path)
return_statement: return path
docstring: Escape any invalid characters in HTTP URL, and uppercase all escapes.
docstring_summary: Escape any invalid characters in HTTP URL, and uppercase all escapes.
docstring_tokens: Escape any invalid characters in HTTP URL and uppercase all escapes .
function: def escape_path(path):
      """Escape any invalid characters in HTTP URL, and uppercase all escapes."""
      # There's no knowing what character encoding was used to create URLs
      # containing %-escapes, but since we have to pick one to escape invalid
      # path characters, we pick UTF-8, as recommended in the HTML 4.0
      # specification:
      # http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1
      # And here, kind of: draft-fielding-uri-rfc2396bis-03
      # (And in draft IRI specification: draft-duerst-iri-05)
      # (And here, for new URI schemes: RFC 2718)
      if isinstance(path, unicode):
          path = path.encode("utf-8")
      path = urllib.quote(path, HTTP_PATH_SAFE)
      path = ESCAPED_CHAR_RE.sub(uppercase_escaped_char, path)
      return path
function_tokens: def escape_path ( path ) : # There's no knowing what character encoding was used to create URLs # containing %-escapes, but since we have to pick one to escape invalid # path characters, we pick UTF-8, as recommended in the HTML 4.0 # specification: # http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1 # And here, kind of: draft-fielding-uri-rfc2396bis-03 # (And in draft IRI specification: draft-duerst-iri-05) # (And here, for new URI schemes: RFC 2718) if isinstance ( path , unicode ) : path = path . encode ( "utf-8" ) path = urllib . quote ( path , HTTP_PATH_SAFE ) path = ESCAPED_CHAR_RE . sub ( uppercase_escaped_char , path ) return path