def asStr(self, noAuth=False, quoted=False): path = self.path if self.extension: path += '.' + self.extension if quoted: path = urllib.quote(path) if noAuth: return util.urlUnsplit( (self.scheme, None, None, self.host, self.port, path, self.params, self.fragment)) return util.urlUnsplit((self.scheme, self.user, self.passwd, self.host, self.port, path, self.params, self.fragment))
def asStr(self, noAuth=False, quoted=False): path = self.path if self.extension: path += '.' + self.extension if quoted: path = urllib.quote(path) if noAuth: return util.urlUnsplit((self.scheme, None, None, self.host, self.port, path, self.params, self.fragment)) return util.urlUnsplit((self.scheme, self.user, self.passwd, self.host, self.port, path, self.params, self.fragment))
def testUrlSplitUnsplit(self): for tup, url in self.Tests: nurl = util.urlUnsplit(tup) self.assertEqual(nurl, url) self.assertEqual(util.urlSplit(url), tup) # One-way tests tests = [ (("http", None, None, "localhost", "10", "/path", "", ""), "http://localhost:10/path"), ((None, None, None, None, None, "/path", "q", "f"), "/path?q#f"), ] for tup, url in tests: nurl = util.urlUnsplit(tup) self.assertEqual(nurl, url)
def urlAddAuth(url, username, password): urlArr = list(util.urlSplit(url)) if username is not None: urlArr[1] = username if password is not None: urlArr[2] = password return util.urlUnsplit(urlArr)
def __init__(self, rbuilderUrl, user, pw, handle): _AbstractRbuilderClient.__init__(self, rbuilderUrl, user, pw, handle) scheme, _, _, host, port, path, _, _ = util.urlSplit(rbuilderUrl) path = util.joinPaths(path, 'api') self._url = util.urlUnsplit( (scheme, user, pw, host, port, path, None, None)) self._api = None
def unsplit(self): username, password = self.userpass host, port = self.hostport if port in (80, 443): port = None return util.urlUnsplit((self.scheme, username, password, str(host), port, self.path, None, None))
def unsplit(self): username, password = self.userpass host, port = self.hostport if (self.scheme == 'http' and port == 80) or (self.scheme == 'https' and port == 443): port = None return util.urlUnsplit((self.scheme, username, password, str(host), port, self.path, None, None))
def _requestPath(cls, request): path = getattr(request, 'path', None) if path is not None: return path path = request.META.get('SCRIPT_NAME', '') path += request.META.get('PATH_INFO', '') qs = request.META.get('QUERY_STRING') path = util.urlUnsplit((None, None, None, None, None, path, qs, None)) return path
def fromString(cls, url, host=None, port=None): arr = util.urlSplit(url) o = cls() (o.scheme, o.username, o.password, o.host, o.port, o.path, o.query, o.fragment) = arr o.unparsedPath = util.urlUnsplit((None, None, None, None, None, o.path, o.query, o.fragment)) if o.host is None: o.host = host if o.port is None: o.port = port return o
def asString(self): return util.urlUnsplit((self.scheme, self.username, self.password, self.host, self.port, self.path, self.query, self.fragment)).encode('ascii')