From feb22145a1d47e8dd51c29d6ba22aaaa4664a9ea Mon Sep 17 00:00:00 2001 From: wangzihao Date: Tue, 13 Oct 2020 14:02:43 +0800 Subject: [PATCH] Remove six Remove all usages of six Change-Id: I3a5dedade263337aeef12eac1c4daf2f7e82e306 Story: 2008305 Task: 41190 --- lower-constraints.txt | 1 - monascaclient/common/monasca_manager.py | 2 +- monascaclient/common/utils.py | 9 ++++----- monascaclient/osc/migration.py | 4 +--- monascaclient/shell.py | 8 -------- monascaclient/v2_0/alarms.py | 2 +- requirements.txt | 1 - tox.ini | 1 - 8 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index c798d4e..a02a1c7 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -59,7 +59,6 @@ requests==2.14.2 requestsexceptions==1.2.0 restructuredtext-lint==1.1.1 simplejson==3.5.1 -six==1.10.0 smmap==0.9.0 snowballstemmer==1.2.1 Sphinx==2.0.0 diff --git a/monascaclient/common/monasca_manager.py b/monascaclient/common/monasca_manager.py index f973abd..a30843a 100644 --- a/monascaclient/common/monasca_manager.py +++ b/monascaclient/common/monasca_manager.py @@ -15,7 +15,7 @@ # limitations under the License. -from six.moves.urllib import parse +from urllib import parse class MonascaManager(object): diff --git a/monascaclient/common/utils.py b/monascaclient/common/utils.py index 53f3dd8..84d8bef 100644 --- a/monascaclient/common/utils.py +++ b/monascaclient/common/utils.py @@ -16,7 +16,6 @@ import numbers import prettytable -import six import yaml from osc_lib import exceptions as exc @@ -41,7 +40,7 @@ def arg(*args, **kwargs): def json_formatter(js): formatter = (jsonutils.dumps(js, indent=2, ensure_ascii=False)) - return formatter if six.PY3 else formatter.encode('utf-8') + return formatter def print_list(objs, fields, field_labels=None, formatters=None, sortby=None): @@ -66,7 +65,7 @@ def print_list(objs, fields, field_labels=None, formatters=None, sortby=None): pt.add_row(row) field_to_sort_by = field_labels[sortby] if sortby else None pt_string = pt.get_string(sortby=field_to_sort_by) - print(pt_string if six.PY3 else pt_string.encode('utf-8')) + print(pt_string) def print_dict(d, formatters=None): @@ -83,7 +82,7 @@ def print_dict(d, formatters=None): pt.add_row([field, d[field]]) pt_string = pt.get_string(sortby='Property') - print(pt_string if six.PY3 else pt_string.encode('utf-8')) + print(pt_string) def format_parameters(params): @@ -193,7 +192,7 @@ def format_dict(dict): def format_list(in_list): string_list = list() for k in in_list: - if isinstance(k, six.text_type): + if isinstance(k, str): key = k.encode('utf-8') else: key = k diff --git a/monascaclient/osc/migration.py b/monascaclient/osc/migration.py index 9c73da9..b9bca4c 100644 --- a/monascaclient/osc/migration.py +++ b/monascaclient/osc/migration.py @@ -13,7 +13,6 @@ # under the License. import logging -import six from osc_lib.command import command from osc_lib import utils @@ -95,8 +94,7 @@ class MigratingCommandMeta(command.CommandMeta): bases, cls_dict) -@six.add_metaclass(MigratingCommandMeta) -class MigratingCommand(command.Command): +class MigratingCommand(command.Command, metaclass=MigratingCommandMeta): """MigratingCommand is temporary command. MigratingCommand allows to map function defined diff --git a/monascaclient/shell.py b/monascaclient/shell.py index e5b949f..b52258c 100644 --- a/monascaclient/shell.py +++ b/monascaclient/shell.py @@ -19,7 +19,6 @@ Command-line interface to the monasca-client API. """ import argparse -import locale import sys from osc_lib.api import auth @@ -27,7 +26,6 @@ from osc_lib.cli import client_config as cloud_config from osc_lib import shell from osc_lib import utils from oslo_utils import importutils -import six from monascaclient.osc import migration from monascaclient import version as mc_version @@ -100,12 +98,6 @@ def main(args=None): try: if args is None: args = sys.argv[1:] - if six.PY2: - # Emulate Py3, decode argv into Unicode based on locale so that - # commands always see arguments as text instead of binary data - encoding = locale.getpreferredencoding() - if encoding: - args = map(lambda arg: arg.decode(encoding), args) return MonascaShell().run(args) except Exception as e: if '--debug' in args or '-d' in args: diff --git a/monascaclient/v2_0/alarms.py b/monascaclient/v2_0/alarms.py index fc51644..b55c782 100644 --- a/monascaclient/v2_0/alarms.py +++ b/monascaclient/v2_0/alarms.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from six.moves.urllib import parse +from urllib import parse from monascaclient.common import monasca_manager diff --git a/requirements.txt b/requirements.txt index 2709321..729d294 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,4 +13,3 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 PrettyTable<0.8,>=0.7.2 # BSD PyYAML>=3.12 # MIT -six>=1.10.0 # MIT diff --git a/tox.ini b/tox.ini index 1e9cb85..e9d5c40 100644 --- a/tox.ini +++ b/tox.ini @@ -87,7 +87,6 @@ commands = {posargs} [hacking] import_exceptions = - six.moves [flake8] show-source = True