def __init__(self, url=''): '''Create a new Url object.''' Object.__init__(self) self._apitype = 'saga.base' if type(url) == str: self._urlobj = urlparse.urlparse(url) elif type(url) == Url: self._urlobj = urlparse.urlparse(str(url)) else: raise bliss.saga.Exception(bliss.saga.Error.NoSuccess, "URL constructor expects str or bliss.saga.Url type as parameter")
def __init__(self, url=''): '''Create a new Url object.''' Object.__init__(self) self._apitype = 'saga.base' if type(url) == str: self._urlobj = urlparse.urlparse(url) elif type(url) == Url: self._urlobj = urlparse.urlparse(str(url)) else: raise bliss.saga.Exception( bliss.saga.Error.NoSuccess, "URL constructor expects str or bliss.saga.Url type as parameter" )
def __init__(self, urlstring=''): '''Create a new Url object.''' Object.__init__(self, objtype=Object.Type.Url, apitype=Object.Type.BaseAPI) self._urlobj = urlparse.urlparse(urlstring) self.scheme = self._urlobj.scheme '''The scheme part of the Url.''' self.host = self._urlobj.hostname #host '''The host part of the Url.''' if self._urlobj.port is not None: self.port = int(self._urlobj.port) # int(port) '''The port part of the Url.''' else: self.port = None '''The port part of the Url.''' self.username = self._urlobj.username '''The username part of the Url.''' self.password = self._urlobj.password '''The password part of the Url.''' self.path = self._urlobj.path '''The path part of the Url.''' self.query = self._urlobj.query '''The query part of the Url.''' self.fragment = self._urlobj.fragment '''The fragment part of the Url.''' self.url = str(self._urlobj.geturl()) '''The Url as string (same as __str__).'''
def set_query(self, path): """Set the 'query' component of the URL. @type path: str """ newurl = urlparse.urlunparse( (self._urlobj.scheme, self._urlobj.netloc, self._urlobj.path, self._urlobj.params, query, self._urlobj.fragment)) self._urlobj = urlparse.urlparse(newurl)
def set_fragment(self, fragment): """Set the 'fragment' component of the URL. @type fragment: str """ newurl = urlparse.urlunparse( (self._urlobj.scheme, self._urlobj.netloc, self._urlobj.path, self._urlobj.params, self._urlobj.query, fragment)) self._urlobj = urlparse.urlparse(newurl)
def set_scheme(self, scheme): """Set the 'scheme' component of the URL. @type scheme: str """ newurl = urlparse.urlunparse( (scheme, self._urlobj.netloc, self._urlobj.path, self._urlobj.params, self._urlobj.query, self._urlobj.fragment)) self._urlobj = urlparse.urlparse(newurl)
def set_password(self, password): """Set the 'password' component of the URL. @type password: str """ netloc = self._make_netloc(self._urlobj.username, password, self._urlobj.hostname, self._urlobj.port) newurl = urlparse.urlunparse( (self._urlobj.scheme, netloc, self._urlobj.path, self._urlobj.params, self._urlobj.query, self._urlobj.fragment)) self._urlobj = urlparse.urlparse(newurl)
def set_query(self, path): """Set the 'query' component of the URL. @type path: str """ newurl = urlparse.urlunparse((self._urlobj.scheme, self._urlobj.netloc, self._urlobj.path, self._urlobj.params, query, self._urlobj.fragment)) self._urlobj = urlparse.urlparse(newurl)
def set_fragment(self, fragment): """Set the 'fragment' component of the URL. @type fragment: str """ newurl = urlparse.urlunparse((self._urlobj.scheme, self._urlobj.netloc, self._urlobj.path, self._urlobj.params, self._urlobj.query, fragment)) self._urlobj = urlparse.urlparse(newurl)
def set_scheme(self, scheme): """Set the 'scheme' component of the URL. @type scheme: str """ newurl = urlparse.urlunparse((scheme, self._urlobj.netloc, self._urlobj.path, self._urlobj.params, self._urlobj.query, self._urlobj.fragment)) self._urlobj = urlparse.urlparse(newurl)
def set_host(self, host): """Set the 'host' component of the URL. @type host: str """ netloc = self._make_netloc(self._urlobj.username, self._urlobj.password, host, self._urlobj.port) newurl = urlparse.urlunparse( (self._urlobj.scheme, netloc, self._urlobj.path, self._urlobj.params, self._urlobj.query, self._urlobj.fragment)) self._urlobj = urlparse.urlparse(newurl)
def set_password(self, password): """Set the 'password' component of the URL. @type password: str """ netloc = self._make_netloc(self._urlobj.username, password, self._urlobj.hostname, self._urlobj.port) newurl = urlparse.urlunparse((self._urlobj.scheme, netloc, self._urlobj.path, self._urlobj.params, self._urlobj.query, self._urlobj.fragment)) self._urlobj = urlparse.urlparse(newurl)
def set_host(self, host): """Set the 'host' component of the URL. @type host: str """ netloc = self._make_netloc(self._urlobj.username, self._urlobj.password, host, self._urlobj.port) newurl = urlparse.urlunparse((self._urlobj.scheme, netloc, self._urlobj.path, self._urlobj.params, self._urlobj.query, self._urlobj.fragment)) self._urlobj = urlparse.urlparse(newurl)