Remove six usage

Change-Id: I0218c36b7c3c71ebd4c92f18c8bf4c6d7a766c9f
This commit is contained in:
zhurong 2020-04-16 02:17:13 -07:00
parent 62c7f5adfe
commit 54c82d6be8
11 changed files with 41 additions and 51 deletions

View File

@ -42,7 +42,6 @@ PyYAML==3.12
requests==2.14.2
requestsexceptions==1.2.0
rfc3986==0.3.1
six==1.10.0
stestr==2.0.0
stevedore==1.20.0
testscenarios==0.4

View File

@ -14,6 +14,5 @@ requests>=2.14.2 # Apache-2.0
python-keystoneclient>=3.8.0 # Apache-2.0
PyYAML>=3.12 # MIT
stevedore>=1.20.0 # Apache-2.0
six>=1.10.0 # MIT
PrettyTable<0.8,>=0.7.2 # BSD
debtcollector>=1.2.0 # Apache-2.0

View File

@ -21,7 +21,6 @@ import abc
import argparse
import os
import six
from stevedore import extension
from solumclient.common.apiclient import exceptions
@ -85,7 +84,7 @@ def load_plugin_from_args(args):
plugin.sufficient_options()
return plugin
for plugin_auth_system in sorted(six.iterkeys(_discovered_plugins)):
for plugin_auth_system in sorted(_discovered_plugins.keys()):
plugin_class = _discovered_plugins[plugin_auth_system]
plugin = plugin_class()
plugin.parse_opts(args)
@ -97,8 +96,7 @@ def load_plugin_from_args(args):
raise exceptions.AuthPluginOptionsMissing(["auth_system"])
@six.add_metaclass(abc.ABCMeta)
class BaseAuthPlugin(object):
class BaseAuthPlugin(object, metaclass=abc.ABCMeta):
"""Base class for authentication plugins.
An authentication plugin needs to override at least the authenticate

View File

@ -26,8 +26,7 @@ Base utilities to build API operation managers and objects on top of.
import abc
import copy
import six
from six.moves.urllib import parse
from urllib import parse
from solumclient.common.apiclient import exceptions
from solumclient.i18n import _
@ -211,8 +210,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

View File

@ -27,8 +27,7 @@ places where actual behavior differs from the spec.
import json
import requests
import six
from six.moves.urllib import parse
from urllib import parse
from solumclient.common.apiclient import client
@ -63,7 +62,7 @@ class TestResponse(requests.Response):
else:
self._content = text
default_headers = {}
if six.PY3 and isinstance(self._content, six.string_types):
if isinstance(self._content, str):
self._content = self._content.encode('utf-8', 'strict')
self.headers = data.get('headers') or default_headers
else:

View File

@ -18,7 +18,7 @@ from keystoneclient import discover
from keystoneclient import exceptions as ks_exc
from keystoneclient import session
from oslo_utils import strutils
import six.moves.urllib.parse as urlparse
from urllib import parse as urlparse
from solumclient.common.apiclient import auth
from solumclient.common.apiclient import exceptions

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from six.moves.urllib import parse as urlparse
from urllib import parse as urlparse
from solumclient.common.apiclient import base
from solumclient.common.apiclient import exceptions

View File

@ -25,8 +25,6 @@ import sys
import textwrap
import prettytable
import six
from six import moves
from solumclient.common.apiclient import exceptions
from solumclient.i18n import _
@ -190,14 +188,14 @@ def print_dict(dct, dict_property="Property", wrap=0):
for k, v in dct.items():
# convert dict to str to check length
if isinstance(v, dict):
v = six.text_type(v)
v = str(v)
if wrap > 0:
v = textwrap.fill(six.text_type(v), wrap)
v = textwrap.fill(str(v), wrap)
elif wrap < 0:
raise ValueError(_("Wrap argument should be a positive integer"))
# if value has a newline, add in multiple rows
# e.g. fault with stacktrace
if v and isinstance(v, six.string_types) and r'\n' in v:
if v and isinstance(v, str) and r'\n' in v:
lines = v.strip().split(r'\n')
col1 = k
for line in lines:
@ -215,7 +213,7 @@ def get_password(max_password_prompts=3):
if hasattr(sys.stdin, "isatty") and sys.stdin.isatty():
# Check for Ctrl-D
try:
for __ in moves.range(max_password_prompts):
for __ in range(max_password_prompts):
pw1 = getpass.getpass("OS Password: ")
if verify:
pw2 = getpass.getpass("Please verify: ")
@ -249,7 +247,7 @@ def find_resource(manager, name_or_id, **find_args):
# now try to get entity as uuid
try:
if six.PY2:
if isinstance(name_or_id, str):
tmp_id = encodeutils.safe_encode(name_or_id)
else:
tmp_id = encodeutils.safe_decode(name_or_id)

View File

@ -23,7 +23,6 @@ import re
import string
import httplib2
import six
class GitHubException(Exception):
@ -67,7 +66,7 @@ class GitHubAuth(object):
if self._username is None:
prompt = ("Username for repo '%s' [%s]:" %
(self.full_repo_name, self.user_org_name))
self._username = six.moves.input(prompt) or self.user_org_name
self._username = input(prompt) or self.user_org_name
return self._username
@property

View File

@ -45,7 +45,6 @@ import sys
import httplib2
import jsonschema
from keystoneclient.v2_0 import client as keystoneclient
import six
import solumclient
from solumclient.common.apiclient import exceptions
@ -544,7 +543,7 @@ Available commands:
app_name = args.name
elif app_data.get('name') is None:
while True:
app_name = six.moves.input("Please name the application.\n> ")
app_name = input("Please name the application.\n> ")
if name_is_valid(app_name):
break
print(error_message)
@ -591,12 +590,12 @@ Available commands:
fields = ['uuid', 'name', 'description',
'status', 'source_uri']
self._print_list(filtered_list, fields)
languagepack = six.moves.input("Please choose a languagepack "
"from the above list.\n> ")
languagepack = input("Please choose a languagepack "
"from the above list.\n> ")
while languagepack not in lpnames + lp_uuids:
languagepack = six.moves.input("You must choose one of "
"the named language "
"packs.\n> ")
languagepack = input("You must choose one of "
"the named language "
"packs.\n> ")
app_data['languagepack'] = languagepack
else:
raise exc.CommandError("No languagepack in READY state. "
@ -624,10 +623,10 @@ Available commands:
elif (app_data.get('source') is None or
app_data['source'].get('repository') is None or
app_data['source']['repository'] == ''):
git_url = six.moves.input("Please specify a git repository URL "
"for your application.\n> ")
git_rev_i = six.moves.input("Please specify revision"
"(default is master).\n> ")
git_url = input("Please specify a git repository URL "
"for your application.\n> ")
git_rev_i = input("Please specify revision"
"(default is master).\n> ")
if git_rev_i == '':
git_rev = 'master'
else:
@ -644,8 +643,8 @@ Available commands:
private_sshkey = app_data['source'].get('private_ssh_key', '')
if is_private and not private_sshkey:
sshkey_file = six.moves.input("Please specify private sshkey file "
"full path: ")
sshkey_file = input("Please specify private sshkey file "
"full path: ")
sshkey_file = sshkey_file.strip()
private_sshkey = read_private_sshkey(sshkey_file)
@ -668,8 +667,8 @@ Available commands:
elif (app_data.get('workflow_config') is None or
app_data['workflow_config'].get('run_cmd') == '' or
app_data['workflow_config'].get('run_cmd') is None):
run_cmd = six.moves.input("Please specify start/run command for "
"your application.\n> ")
run_cmd = input("Please specify start/run command for "
"your application.\n> ")
if app_data.get('workflow_config') is None:
run_cmd_dict = dict()
@ -1483,7 +1482,7 @@ Available commands:
# Just ask.
else:
while True:
app_name = six.moves.input("Please name the application.\n> ")
app_name = input("Please name the application.\n> ")
if name_is_valid(app_name):
break
print(error_message)
@ -1508,12 +1507,12 @@ Available commands:
fields = ['uuid', 'name', 'description',
'status', 'source_uri']
self._print_list(filtered_list, fields)
languagepack = six.moves.input("Please choose a languagepack "
"from the above list.\n> ")
languagepack = input("Please choose a languagepack "
"from the above list.\n> ")
while languagepack not in lpnames + lp_uuids:
languagepack = six.moves.input("You must choose one of "
"the named language "
"packs.\n> ")
languagepack = input("You must choose one of "
"the named language "
"packs.\n> ")
plan_definition['artifacts'][0]['language_pack'] = languagepack
else:
raise exc.CommandError("No languagepack in READY state. "
@ -1527,8 +1526,8 @@ Available commands:
if args.git_url is not None:
plan_definition['artifacts'][0]['content']['href'] = args.git_url
if plan_definition['artifacts'][0]['content'].get('href') is None:
git_url = six.moves.input("Please specify a git repository URL "
"for your application.\n> ")
git_url = input("Please specify a git repository URL "
"for your application.\n> ")
plan_definition['artifacts'][0]['content']['href'] = git_url
git_url = plan_definition['artifacts'][0]['content']['href']
@ -1560,8 +1559,8 @@ Available commands:
if args.run_cmd is not None:
plan_definition['artifacts'][0]['run_cmd'] = args.run_cmd
if plan_definition['artifacts'][0].get('run_cmd') is None:
run_cmd = six.moves.input("Please specify start/run command for "
"your application.\n> ")
run_cmd = input("Please specify start/run command for "
"your application.\n> ")
plan_definition['artifacts'][0]['run_cmd'] = run_cmd
# Check for unit test command

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from io import StringIO
import collections
import re
import sys
@ -21,7 +23,6 @@ import mock
from oslo_utils import uuidutils
import six
from stevedore import extension
import testtools
from testtools import matchers
@ -82,7 +83,7 @@ class TestSolum(base.TestCase):
orig = sys.stdout
try:
sys.stdout = six.StringIO()
sys.stdout = StringIO()
argv = [__file__, ]
argv.extend(argstr.split())
self.useFixture(