diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-06-26 11:42:23 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-06-26 11:42:23 +0000 |
commit | e9f567c8ed31d71002b7e3149aeea274e42b9321 (patch) | |
tree | 3b1a87432bb1940172600aa6929fb32388e82b74 /openstack/common | |
parent | b7b4dbc41c4b361ca1afcc8ded0d47f78b53a131 (diff) | |
parent | 0bf03b753c45dd3663a0839bb0ad15187a517bf3 (diff) | |
download | oslo-e9f567c8ed31d71002b7e3149aeea274e42b9321.tar.gz oslo-e9f567c8ed31d71002b7e3149aeea274e42b9321.tar.xz oslo-e9f567c8ed31d71002b7e3149aeea274e42b9321.zip |
Merge "Add network_utils.urlsplit"
Diffstat (limited to 'openstack/common')
-rw-r--r-- | openstack/common/network_utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/openstack/common/network_utils.py b/openstack/common/network_utils.py index 0fbf171..dbed1ce 100644 --- a/openstack/common/network_utils.py +++ b/openstack/common/network_utils.py @@ -19,6 +19,8 @@ Network-related utilities and helper functions. """ +import urlparse + def parse_host_port(address, default_port=None): """Interpret a string as a host:port pair. @@ -62,3 +64,18 @@ def parse_host_port(address, default_port=None): port = default_port return (host, None if port is None else int(port)) + + +def urlsplit(url, scheme='', allow_fragments=True): + """Parse a URL using urlparse.urlsplit(), splitting query and fragments. + This function papers over Python issue9374 when needed. + + The parameters are the same as urlparse.urlsplit. + """ + scheme, netloc, path, query, fragment = urlparse.urlsplit( + url, scheme, allow_fragments) + if allow_fragments and '#' in path: + path, fragment = path.split('#', 1) + if '?' in path: + path, query = path.split('?', 1) + return urlparse.SplitResult(scheme, netloc, path, query, fragment) |