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 requests==2.14.2
requestsexceptions==1.2.0 requestsexceptions==1.2.0
rfc3986==0.3.1 rfc3986==0.3.1
six==1.10.0
stestr==2.0.0 stestr==2.0.0
stevedore==1.20.0 stevedore==1.20.0
testscenarios==0.4 testscenarios==0.4

View File

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

View File

@@ -21,7 +21,6 @@ import abc
import argparse import argparse
import os import os
import six
from stevedore import extension from stevedore import extension
from solumclient.common.apiclient import exceptions from solumclient.common.apiclient import exceptions
@@ -85,7 +84,7 @@ def load_plugin_from_args(args):
plugin.sufficient_options() plugin.sufficient_options()
return plugin 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_class = _discovered_plugins[plugin_auth_system]
plugin = plugin_class() plugin = plugin_class()
plugin.parse_opts(args) plugin.parse_opts(args)
@@ -97,8 +96,7 @@ def load_plugin_from_args(args):
raise exceptions.AuthPluginOptionsMissing(["auth_system"]) raise exceptions.AuthPluginOptionsMissing(["auth_system"])
@six.add_metaclass(abc.ABCMeta) class BaseAuthPlugin(object, metaclass=abc.ABCMeta):
class BaseAuthPlugin(object):
"""Base class for authentication plugins. """Base class for authentication plugins.
An authentication plugin needs to override at least the authenticate 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 abc
import copy import copy
import six from urllib import parse
from six.moves.urllib import parse
from solumclient.common.apiclient import exceptions from solumclient.common.apiclient import exceptions
from solumclient.i18n import _ from solumclient.i18n import _
@@ -211,8 +210,7 @@ class BaseManager(HookableMixin):
return self.client.delete(url) return self.client.delete(url)
@six.add_metaclass(abc.ABCMeta) class ManagerWithFind(BaseManager, metaclass=abc.ABCMeta):
class ManagerWithFind(BaseManager):
"""Manager with additional `find()`/`findall()` methods.""" """Manager with additional `find()`/`findall()` methods."""
@abc.abstractmethod @abc.abstractmethod

View File

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

View File

@@ -18,7 +18,7 @@ from keystoneclient import discover
from keystoneclient import exceptions as ks_exc from keystoneclient import exceptions as ks_exc
from keystoneclient import session from keystoneclient import session
from oslo_utils import strutils 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 auth
from solumclient.common.apiclient import exceptions from solumclient.common.apiclient import exceptions

View File

@@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # 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 base
from solumclient.common.apiclient import exceptions from solumclient.common.apiclient import exceptions

View File

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

View File

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

View File

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

View File

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