diff options
author | Stephen Finucane <sfinucan@redhat.com> | 2020-02-20 09:42:03 +0000 |
---|---|---|
committer | Stephen Finucane <sfinucan@redhat.com> | 2020-02-21 09:48:38 +0000 |
commit | c4c44bcb2df01b77089139b267b1219008f9421e (patch) | |
tree | 1d9d4d068dd2ac3355d15cb7106a3f7c0a460b94 /novaclient/v2 | |
parent | 9dee28ae6c32814494031ef503b835d4728d91dc (diff) | |
download | python-novaclient-c4c44bcb2df01b77089139b267b1219008f9421e.tar.gz |
Remove six
Mostly a find-replace job. Let's do this now so we don't have to carry
it for the next decade.
Change-Id: I7bef9fb7c6895f746cee1aca6522786f38b9857c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'novaclient/v2')
-rw-r--r-- | novaclient/v2/hypervisors.py | 6 | ||||
-rw-r--r-- | novaclient/v2/instance_usage_audit_log.py | 6 | ||||
-rw-r--r-- | novaclient/v2/servers.py | 27 | ||||
-rw-r--r-- | novaclient/v2/services.py | 7 | ||||
-rw-r--r-- | novaclient/v2/shell.py | 13 | ||||
-rw-r--r-- | novaclient/v2/versions.py | 4 |
6 files changed, 23 insertions, 40 deletions
diff --git a/novaclient/v2/hypervisors.py b/novaclient/v2/hypervisors.py index e6f5038c..c705dc65 100644 --- a/novaclient/v2/hypervisors.py +++ b/novaclient/v2/hypervisors.py @@ -17,9 +17,7 @@ Hypervisors interface """ -from oslo_utils import encodeutils -import six -from six.moves.urllib import parse +from urllib import parse from novaclient import api_versions from novaclient import base @@ -92,8 +90,6 @@ class HypervisorManager(base.ManagerWithFind): # Starting with microversion 2.53, the /servers and /search routes are # deprecated and we get the same results using GET /os-hypervisors # using query parameters for the hostname pattern and servers. - if six.PY2: - hypervisor_match = encodeutils.safe_encode(hypervisor_match) if self.api_version >= api_versions.APIVersion('2.53'): url = ('/os-hypervisors%s?hypervisor_hostname_pattern=%s' % ('/detail' if detailed else '', diff --git a/novaclient/v2/instance_usage_audit_log.py b/novaclient/v2/instance_usage_audit_log.py index 9ada06c1..83db8c8e 100644 --- a/novaclient/v2/instance_usage_audit_log.py +++ b/novaclient/v2/instance_usage_audit_log.py @@ -13,9 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_utils import encodeutils -import six -from six.moves.urllib import parse +from urllib import parse from novaclient import base @@ -34,8 +32,6 @@ class InstanceUsageAuditLogManager(base.Manager): before which to list usage audits. """ if before: - if six.PY2: - before = encodeutils.safe_encode(before) return self._get('/os-instance_usage_audit_log/%s' % parse.quote(before, safe=''), 'instance_usage_audit_log') diff --git a/novaclient/v2/servers.py b/novaclient/v2/servers.py index 1351189b..ff8c166e 100644 --- a/novaclient/v2/servers.py +++ b/novaclient/v2/servers.py @@ -21,10 +21,7 @@ Server interface. import base64 import collections - -from oslo_utils import encodeutils -import six -from six.moves.urllib import parse +from urllib import parse from novaclient import api_versions from novaclient import base @@ -690,17 +687,11 @@ class ServerManager(base.BootingManagerWithFind): # NOTE(melwitt): Text file data is converted to bytes prior to # base64 encoding. The utf-8 encoding will fail for binary files. - if six.PY3: - try: - userdata = userdata.encode("utf-8") - except AttributeError: - # In python 3, 'bytes' object has no attribute 'encode' - pass - else: - try: - userdata = encodeutils.safe_encode(userdata) - except UnicodeDecodeError: - pass + try: + userdata = userdata.encode("utf-8") + except AttributeError: + # In python 3, 'bytes' object has no attribute 'encode' + pass return base64.b64encode(userdata).decode('utf-8') @@ -761,7 +752,7 @@ class ServerManager(base.BootingManagerWithFind): else: data = file_or_string - if six.PY3 and isinstance(data, str): + if isinstance(data, str): data = data.encode('utf-8') cont = base64.b64encode(data).decode('utf-8') personality.append({ @@ -791,7 +782,7 @@ class ServerManager(base.BootingManagerWithFind): if nics is not None: # With microversion 2.37+ nics can be an enum of 'auto' or 'none' # or a list of dicts. - if isinstance(nics, six.string_types): + if isinstance(nics, str): all_net_data = nics else: # NOTE(tr3buchet): nics can be an empty list @@ -899,7 +890,7 @@ class ServerManager(base.BootingManagerWithFind): for opt, val in search_opts.items(): # support locked=False from 2.73 microversion if val or (opt == 'locked' and val is False): - if isinstance(val, six.text_type): + if isinstance(val, str): val = val.encode('utf-8') qparams[opt] = val diff --git a/novaclient/v2/services.py b/novaclient/v2/services.py index f3d1255d..7adbf137 100644 --- a/novaclient/v2/services.py +++ b/novaclient/v2/services.py @@ -14,9 +14,10 @@ # under the License. """ -service interface +Service interface. """ -from six.moves import urllib + +from urllib import parse from novaclient import api_versions from novaclient import base @@ -48,7 +49,7 @@ class ServiceManager(base.ManagerWithFind): if binary: filters.append(("binary", binary)) if filters: - url = "%s?%s" % (url, urllib.parse.urlencode(filters)) + url = "%s?%s" % (url, parse.urlencode(filters)) return self._list(url, "services") @api_versions.wraps("2.0", "2.10") diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index 0f8b5ce6..d8de74e8 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -31,7 +31,6 @@ import time from oslo_utils import netutils from oslo_utils import strutils from oslo_utils import timeutils -import six import novaclient from novaclient import api_versions @@ -478,7 +477,7 @@ def _boot(cs, args): # NOTE(vish): multiple copies of the same hint will # result in a list of values if key in hints: - if isinstance(hints[key], six.string_types): + if isinstance(hints[key], str): hints[key] = [hints[key]] hints[key] += [value] else: @@ -2447,7 +2446,7 @@ def _print_server(cs, args, server=None, wrap=0): try: networks = server.networks except Exception as e: - raise exceptions.CommandError(six.text_type(e)) + raise exceptions.CommandError(str(e)) info = server.to_dict() for network_label, address_list in networks.items(): @@ -2556,7 +2555,7 @@ def _find_server(cs, server, raise_if_notfound=True, **find_args): return utils.find_resource(cs.servers, server, wrap_exception=False) except exceptions.NoUniqueMatch as e: - raise exceptions.CommandError(six.text_type(e)) + raise exceptions.CommandError(str(e)) except exceptions.NotFound: # The server can be deleted return server @@ -2567,7 +2566,7 @@ def _find_image(cs, image): try: return cs.glance.find_image(image) except (exceptions.NotFound, exceptions.NoUniqueMatch) as e: - raise exceptions.CommandError(six.text_type(e)) + raise exceptions.CommandError(str(e)) def _find_images(cs, images): @@ -2575,7 +2574,7 @@ def _find_images(cs, images): try: return cs.glance.find_images(images) except (exceptions.NotFound, exceptions.NoUniqueMatch) as e: - raise exceptions.CommandError(six.text_type(e)) + raise exceptions.CommandError(str(e)) def _find_flavor(cs, flavor): @@ -2591,7 +2590,7 @@ def _find_network_id(cs, net_name): try: return cs.neutron.find_network(net_name).id except (exceptions.NotFound, exceptions.NoUniqueMatch) as e: - raise exceptions.CommandError(six.text_type(e)) + raise exceptions.CommandError(str(e)) def _print_volume(volume): diff --git a/novaclient/v2/versions.py b/novaclient/v2/versions.py index dd157d9f..b9895f91 100644 --- a/novaclient/v2/versions.py +++ b/novaclient/v2/versions.py @@ -16,7 +16,7 @@ version interface """ -from six.moves import urllib +from urllib import parse from novaclient import base from novaclient import exceptions as exc @@ -79,7 +79,7 @@ class VersionManager(base.ManagerWithFind): """List all versions.""" endpoint = self.api.client.get_endpoint() - url = urllib.parse.urlparse(endpoint) + url = parse.urlparse(endpoint) # NOTE(andreykurilin): endpoint URL has at least 3 formats: # 1. the classic (legacy) endpoint: # http://{host}:{optional_port}/v{2 or 2.1}/{project-id} |