Remove need to inherit/adjust netutils split
The code we had for adjusting the netutils urlsplit function to add in a params method/property is no longer needed as that functionality is now pushed into the oslo.utils repo/package where it can be maintained there in a more proper manner instead; so we can now remove our adjustment code and just use the upstream code instead. Change-Id: I5ca05c0ac6a6221157a737ba20814cfd63adf51e
This commit is contained in:
@@ -140,7 +140,7 @@ class UriParseTest(test.TestCase):
|
|||||||
self.assertEqual('192.168.0.1', parsed.hostname)
|
self.assertEqual('192.168.0.1', parsed.hostname)
|
||||||
self.assertEqual('', parsed.fragment)
|
self.assertEqual('', parsed.fragment)
|
||||||
self.assertEqual('/a/b/', parsed.path)
|
self.assertEqual('/a/b/', parsed.path)
|
||||||
self.assertEqual({'c': 'd'}, parsed.params)
|
self.assertEqual({'c': 'd'}, parsed.params())
|
||||||
|
|
||||||
def test_port_provided(self):
|
def test_port_provided(self):
|
||||||
url = "rabbitmq://www.yahoo.com:5672"
|
url = "rabbitmq://www.yahoo.com:5672"
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ from oslo.utils import reflection
|
|||||||
import six
|
import six
|
||||||
from six.moves import map as compat_map
|
from six.moves import map as compat_map
|
||||||
from six.moves import range as compat_range
|
from six.moves import range as compat_range
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
|
|
||||||
from taskflow.types import failure
|
from taskflow.types import failure
|
||||||
from taskflow.types import notifier
|
from taskflow.types import notifier
|
||||||
@@ -46,22 +45,6 @@ NUMERIC_TYPES = six.integer_types + (float,)
|
|||||||
_SCHEME_REGEX = re.compile(r"^([A-Za-z][A-Za-z0-9+.-]*):")
|
_SCHEME_REGEX = re.compile(r"^([A-Za-z][A-Za-z0-9+.-]*):")
|
||||||
|
|
||||||
|
|
||||||
# FIXME(harlowja): This should be removed with the next version of oslo.utils
|
|
||||||
# which now has this functionality built-in, until then we are deriving from
|
|
||||||
# there base class and adding this functionality on...
|
|
||||||
#
|
|
||||||
# The change was merged @ https://review.openstack.org/#/c/118881/
|
|
||||||
class ModifiedSplitResult(netutils._ModifiedSplitResult):
|
|
||||||
"""A split result that exposes the query parameters as a dictionary."""
|
|
||||||
|
|
||||||
@property
|
|
||||||
def params(self):
|
|
||||||
if self.query:
|
|
||||||
return dict(urlparse.parse_qsl(self.query))
|
|
||||||
else:
|
|
||||||
return {}
|
|
||||||
|
|
||||||
|
|
||||||
def merge_uri(uri, conf):
|
def merge_uri(uri, conf):
|
||||||
"""Merges a parsed uri into the given configuration dictionary.
|
"""Merges a parsed uri into the given configuration dictionary.
|
||||||
|
|
||||||
@@ -80,7 +63,7 @@ def merge_uri(uri, conf):
|
|||||||
if uri.port is not None:
|
if uri.port is not None:
|
||||||
hostname += ":%s" % (uri.port)
|
hostname += ":%s" % (uri.port)
|
||||||
conf.setdefault('hostname', hostname)
|
conf.setdefault('hostname', hostname)
|
||||||
for (k, v) in six.iteritems(uri.params):
|
for (k, v) in six.iteritems(uri.params()):
|
||||||
conf.setdefault(k, v)
|
conf.setdefault(k, v)
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
@@ -140,10 +123,7 @@ def parse_uri(uri):
|
|||||||
if not match:
|
if not match:
|
||||||
raise ValueError("Uri %r does not start with a RFC 3986 compliant"
|
raise ValueError("Uri %r does not start with a RFC 3986 compliant"
|
||||||
" scheme" % (uri))
|
" scheme" % (uri))
|
||||||
split = netutils.urlsplit(uri)
|
return netutils.urlsplit(uri)
|
||||||
return ModifiedSplitResult(scheme=split.scheme, fragment=split.fragment,
|
|
||||||
path=split.path, netloc=split.netloc,
|
|
||||||
query=split.query)
|
|
||||||
|
|
||||||
|
|
||||||
def clamp(value, minimum, maximum, on_clamped=None):
|
def clamp(value, minimum, maximum, on_clamped=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user