Previous topic

SFLvaultAccess object

Next topic

SFLVault Client Release Notes

This Page

Other utilities

URL parsing utilites

class sflvault.client.utils.URLParser(url=None)

Parses URLs and splits scheme, hostname, username, port, path, query, fragment, etc.. apart in an string representing an URL

>>> u = URLParser('http://www.example.com/path')
>>> u
...
>>> u.hostname
'www.example.com'
>>> u.path
'/path'
>>> u2 = URLParser('git+ssh://[user@host]@git.example.com/var/www/repos')
>>> u2.username
'user@host'
>>> u2.hostname
'git.example.com'
>>> u2.path
'/var/www/repos'
>>> u3 = URLParser('https://[user@host]:passwd123@[2009::10:ab]:123/var/my/path?q=hello#frag123')
>>> u3.scheme
'https'
>>> u3.username
'user@host'
>>> u3.password
'passwd123'
>>> u3.hostname
'2009::10:ab'
>>> u3.port
'123'
>>> u3.path
'/var/my/path'
>>> u3.query
'q=hello'
>>> u3.fragment
'frag123'
>>> u3.gen_url(with_password=False)  # Default behavior
'https://[user@host]@[2009::10:ab]:123/var/my/path?q=hello#frag123'

Parse an URL or create a new empty object

gen_url(with_password=False)

Renders the URL, optionally without the password, based on the internal state of it’s attributes (hostname, username, etc..)

>>> u = URLParser('http://www.example.com/path')
>>> u.