Merge "Do not use the six library."
This commit is contained in:
@@ -41,8 +41,7 @@ import abc
|
||||
import copy
|
||||
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
import urllib.parse
|
||||
|
||||
from glanceclient._i18n import _
|
||||
from glanceclient.v1.apiclient import exceptions
|
||||
@@ -224,8 +223,7 @@ class BaseManager(HookableMixin):
|
||||
return self.client.delete(url)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class ManagerWithFind(BaseManager):
|
||||
class ManagerWithFind(BaseManager, metaclass=abc.ABCMeta):
|
||||
"""Manager with additional `find()`/`findall()` methods."""
|
||||
|
||||
@abc.abstractmethod
|
||||
@@ -350,10 +348,11 @@ class CrudManager(BaseManager):
|
||||
"""
|
||||
kwargs = self._filter_kwargs(kwargs)
|
||||
|
||||
query = urllib.parse.urlencode(kwargs) if kwargs else '',
|
||||
return self._list(
|
||||
'%(base_url)s%(query)s' % {
|
||||
'base_url': self.build_url(base_url=base_url, **kwargs),
|
||||
'query': '?%s' % parse.urlencode(kwargs) if kwargs else '',
|
||||
'query': '?%s' % query,
|
||||
},
|
||||
self.collection_key)
|
||||
|
||||
@@ -389,10 +388,11 @@ class CrudManager(BaseManager):
|
||||
"""
|
||||
kwargs = self._filter_kwargs(kwargs)
|
||||
|
||||
query = urllib.parse.urlencode(kwargs) if kwargs else '',
|
||||
rl = self._list(
|
||||
'%(base_url)s%(query)s' % {
|
||||
'base_url': self.build_url(base_url=base_url, **kwargs),
|
||||
'query': '?%s' % parse.urlencode(kwargs) if kwargs else '',
|
||||
'query': '?%s' % query,
|
||||
},
|
||||
self.collection_key)
|
||||
num = len(rl)
|
||||
|
||||
@@ -36,8 +36,6 @@ Exception definitions.
|
||||
import inspect
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
from glanceclient._i18n import _
|
||||
|
||||
|
||||
@@ -461,7 +459,7 @@ def from_response(response, method, url):
|
||||
kwargs["message"] = (error.get("message") or
|
||||
error.get("faultstring"))
|
||||
kwargs["details"] = (error.get("details") or
|
||||
six.text_type(body))
|
||||
str(body))
|
||||
elif content_type.startswith("text/"):
|
||||
kwargs["details"] = getattr(response, 'text', '')
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from glanceclient._i18n import _
|
||||
from glanceclient.v1.apiclient import exceptions
|
||||
@@ -52,10 +51,7 @@ def find_resource(manager, name_or_id, **find_args):
|
||||
|
||||
# now try to get entity as uuid
|
||||
try:
|
||||
if six.PY2:
|
||||
tmp_id = encodeutils.safe_encode(name_or_id)
|
||||
else:
|
||||
tmp_id = encodeutils.safe_decode(name_or_id)
|
||||
tmp_id = encodeutils.safe_decode(name_or_id)
|
||||
|
||||
if uuidutils.is_uuid_like(tmp_id):
|
||||
return manager.get(tmp_id)
|
||||
|
||||
@@ -17,8 +17,7 @@ import copy
|
||||
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import urllib.parse
|
||||
|
||||
from glanceclient.common import utils
|
||||
from glanceclient.v1.apiclient import base
|
||||
@@ -101,7 +100,7 @@ class ImageManager(base.ManagerWithFind):
|
||||
# headers will be encoded later, before the
|
||||
# request is sent.
|
||||
def to_str(value):
|
||||
if not isinstance(value, six.string_types):
|
||||
if not isinstance(value, str):
|
||||
return str(value)
|
||||
return value
|
||||
|
||||
@@ -129,7 +128,7 @@ class ImageManager(base.ManagerWithFind):
|
||||
"""
|
||||
image_id = base.getid(image)
|
||||
resp, body = self.client.head('/v1/images/%s'
|
||||
% urlparse.quote(str(image_id)))
|
||||
% urllib.parse.quote(str(image_id)))
|
||||
meta = self._image_meta_from_headers(resp.headers)
|
||||
return_request_id = kwargs.get('return_req_id', None)
|
||||
if return_request_id is not None:
|
||||
@@ -145,7 +144,7 @@ class ImageManager(base.ManagerWithFind):
|
||||
"""
|
||||
image_id = base.getid(image)
|
||||
resp, body = self.client.get('/v1/images/%s'
|
||||
% urlparse.quote(str(image_id)))
|
||||
% urllib.parse.quote(str(image_id)))
|
||||
content_length = int(resp.headers.get('content-length', 0))
|
||||
checksum = resp.headers.get('x-image-meta-checksum', None)
|
||||
if do_checksum and checksum is not None:
|
||||
@@ -225,7 +224,7 @@ class ImageManager(base.ManagerWithFind):
|
||||
|
||||
def paginate(qp, return_request_id=None):
|
||||
for param, value in qp.items():
|
||||
if isinstance(value, six.string_types):
|
||||
if isinstance(value, str):
|
||||
# Note(flaper87) Url encoding should
|
||||
# be moved inside http utils, at least
|
||||
# shouldn't be here.
|
||||
@@ -234,7 +233,7 @@ class ImageManager(base.ManagerWithFind):
|
||||
# trying to encode them
|
||||
qp[param] = encodeutils.safe_decode(value)
|
||||
|
||||
url = '/v1/images/detail?%s' % urlparse.urlencode(qp)
|
||||
url = '/v1/images/detail?%s' % urllib.parse.urlencode(qp)
|
||||
images, resp = self._list(url, "images")
|
||||
|
||||
if return_request_id is not None:
|
||||
|
||||
Reference in New Issue
Block a user