def escape_path(path):
 if isinstance(path, types.UnicodeType):
  path = path.encode('utf-8')
 path = urllib.quote(path, HTTP_PATH_SAFE)
 path = ESCAPED_CHAR_RE.sub(uppercase_escaped_char, path)
 return path

def escape_path ( path ) : if isinstance ( path , types . UnicodeType ) : path = path . encode ( 'utf-8' ) path = urllib . quote ( path , HTTP_PATH_SAFE ) path = ESCAPED_CHAR_RE . sub ( uppercase_escaped_char , path ) return path
escape any invalid characters in http url .