diff options
| author | Cyril Roelandt <cyril.roelandt@enovance.com> | 2013-12-12 14:25:06 +0100 |
|---|---|---|
| committer | Cyril Roelandt <cyril.roelandt@enovance.com> | 2013-12-12 15:11:51 +0100 |
| commit | 11eb5109a144ce10471fa8bf8afc046d4de61c1f (patch) | |
| tree | ed76a715446962878899f464900d938a71fd4edb /keystoneclient/base.py | |
| parent | 581265448cf40caddb71678a52335f8f0f49d45d (diff) | |
| download | python-keystoneclient-11eb5109a144ce10471fa8bf8afc046d4de61c1f.tar.gz | |
Python3: replace urllib by six.moves.urllib
This makes the code compatible with both Python 2 and 3.
Change-Id: I721a5567842f2df6ce2a8af501787204daba3082
Diffstat (limited to 'keystoneclient/base.py')
| -rw-r--r-- | keystoneclient/base.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/keystoneclient/base.py b/keystoneclient/base.py index 529e0c3..df88f09 100644 --- a/keystoneclient/base.py +++ b/keystoneclient/base.py @@ -23,9 +23,9 @@ Base utilities to build API operation managers and objects on top of. import abc import functools -import urllib import six +from six.moves import urllib from keystoneclient import exceptions from keystoneclient.openstack.common import strutils @@ -331,10 +331,14 @@ class CrudManager(Manager): def list(self, **kwargs): url = self.build_url(dict_args_in_out=kwargs) + if kwargs: + query = '?%s' % urllib.parse.urlencode(kwargs) + else: + query = '' return self._list( '%(url)s%(query)s' % { 'url': url, - 'query': '?%s' % urllib.urlencode(kwargs) if kwargs else '', + 'query': query, }, self.collection_key) @@ -364,10 +368,14 @@ class CrudManager(Manager): """Find a single item with attributes matching ``**kwargs``.""" url = self.build_url(dict_args_in_out=kwargs) + if kwargs: + query = '?%s' % urllib.parse.urlencode(kwargs) + else: + query = '' rl = self._list( '%(url)s%(query)s' % { 'url': url, - 'query': '?%s' % urllib.urlencode(kwargs) if kwargs else '', + 'query': query, }, self.collection_key) num = len(rl) |
