diff options
author | Cyril Roelandt <tipecaml@gmail.com> | 2020-06-15 21:28:17 +0200 |
---|---|---|
committer | Cyril Roelandt <cyril@redhat.com> | 2020-06-23 21:51:07 +0200 |
commit | b513c8db4bf6a5b2eb0366117ca22e042dd3529e (patch) | |
tree | bc8d62a16c78b4c80ced107266100a5b461b51d7 /glanceclient/shell.py | |
parent | 928935e5c0b8b43827fdf08b212d59d92b660924 (diff) | |
download | python-glanceclient-b513c8db4bf6a5b2eb0366117ca22e042dd3529e.tar.gz |
Do not use the six library.
Change-Id: I3dbfcfa0f5f590a41ed549afd44537d8ed41433a
Diffstat (limited to 'glanceclient/shell.py')
-rw-r--r-- | glanceclient/shell.py | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/glanceclient/shell.py b/glanceclient/shell.py index 3dfa14a..d0028fe 100644 --- a/glanceclient/shell.py +++ b/glanceclient/shell.py @@ -31,8 +31,7 @@ import traceback from oslo_utils import encodeutils from oslo_utils import importutils -import six -import six.moves.urllib.parse as urlparse +import urllib.parse import glanceclient from glanceclient._i18n import _ @@ -259,7 +258,7 @@ class OpenStackImagesShell(object): except ks_exc.ClientException as e: # Identity service may not support discover API version. # Lets trying to figure out the API version from the original URL. - url_parts = urlparse.urlparse(auth_url) + url_parts = urllib.parse.urlparse(auth_url) (scheme, netloc, path, params, query, fragment) = url_parts path = path.lower() if path.startswith('/v3'): @@ -522,12 +521,6 @@ class OpenStackImagesShell(object): self.do_help(options, parser=parser) return 0 - # NOTE(sigmavirus24): Above, args is defined as the left over - # arguments from parser.parse_known_args(). This allows us to - # skip any parameters to command-line flags that may have been passed - # to glanceclient, e.g., --os-auth-token. - self._fixup_subcommand(args, argv) - # short-circuit and deal with help command right away. sub_parser = _get_subparser(api_version) args = sub_parser.parse_args(argv) @@ -598,33 +591,6 @@ class OpenStackImagesShell(object): print("To display trace use next command:\n" "osprofiler trace show --html %s " % trace_id) - @staticmethod - def _fixup_subcommand(unknown_args, argv): - # NOTE(sigmavirus24): Sometimes users pass the wrong subcommand name - # to glanceclient. If they're using Python 2 they will see an error: - # > invalid choice: u'imgae-list' (choose from ...) - # To avoid this, we look at the extra args already parsed from above - # and try to predict what the subcommand will be based on it being the - # first non - or -- prefixed argument in args. We then find that in - # argv and encode it from unicode so users don't see the pesky `u'` - # prefix. - for arg in unknown_args: - if not arg.startswith('-'): # This will cover both - and -- - subcommand_name = arg - break - else: - subcommand_name = '' - - if (subcommand_name and six.PY2 and - isinstance(subcommand_name, six.text_type)): - # NOTE(sigmavirus24): if we found a subcommand name, then let's - # find it in the argv list and replace it with a bytes object - # instead. Note, that if we encode the argument on Python 3, the - # user will instead see a pesky `b'` string instead of the `u'` - # string we mention above. - subcommand_index = argv.index(subcommand_name) - argv[subcommand_index] = encodeutils.safe_encode(subcommand_name) - @utils.arg('command', metavar='<subcommand>', nargs='?', help='Display help for <subcommand>.') def do_help(self, args, parser): |