def fromBytes(klass, url): """ Make a L{URLPath} from a L{bytes}. @param url: A L{bytes} representation of a URL. @type url: L{bytes} @return: a new L{URLPath} derived from the given L{bytes}. @rtype: L{URLPath} @since: 15.4 """ if not isinstance(url, bytes): raise ValueError("'url' must be bytes") parts = urlparse.urlsplit(urlquote(url, safe=_allascii)) return klass(*parts)
def click(self, st): """Return a path which is the URL where a browser would presumably take you if you clicked on a link with an HREF as given. """ scheme, netloc, path, query, fragment = urlparse.urlsplit(st) if not scheme: scheme = self.scheme if not netloc: netloc = self.netloc if not path: path = self.path if not query: query = self.query elif path[0] != "/": l = self.pathList() l[-1] = path path = "/".join(l) return URLPath(scheme, netloc, path, query, fragment)
def click(self, st): """Return a path which is the URL where a browser would presumably take you if you clicked on a link with an HREF as given. """ scheme, netloc, path, query, fragment = urlparse.urlsplit(st) if not scheme: scheme = self.scheme if not netloc: netloc = self.netloc if not path: path = self.path if not query: query = self.query elif path[0] != '/': l = self.pathList() l[-1] = path path = '/'.join(l) return URLPath(scheme, netloc, path, query, fragment)
def fromString(klass, st): t = urlparse.urlsplit(st) u = klass(*t) return u