commit 91ba6d1d7cffea2c97259f7abf044d00cffbccb9 Author: wangzihao Date: Fri Oct 9 18:01:09 2020 +0800 Remove six.moves Remove six.moves Replace the following items with Python 3 style code. - six.moves.urllib - six.moves.http_client - six.moves.configparser - six.moves.cStringIO Change-Id: I004b6b9a81079c67451395bfe31ec75d58802c16 diff --git a/run_tests.py b/run_tests.py index caa8a1f..024a93a 100644 --- a/run_tests.py +++ b/run_tests.py @@ -25,7 +25,7 @@ import traceback import eventlet from oslo_log import log as logging import proboscis -from six.moves import urllib +import urllib import wsgi_intercept from wsgi_intercept.httplib2_intercept import install as wsgi_install diff --git a/tools/trove-pylint.py b/tools/trove-pylint.py index fa8a5d9..088203c 100755 --- a/tools/trove-pylint.py +++ b/tools/trove-pylint.py @@ -15,6 +15,7 @@ import fnmatch import json from collections import OrderedDict +import io import os import re import six @@ -22,7 +23,6 @@ import sys from pylint import lint from pylint.reporters import text -from six.moves import cStringIO as csio DEFAULT_CONFIG_FILE = "tools/trove-pylint.config" DEFAULT_IGNORED_FILES = ['trove/tests'] @@ -210,7 +210,7 @@ class LintRunner(object): def dolint(self, filename): exceptions = set() - buffer = csio() + buffer = io.StringIO() reporter = ParseableTextReporter(output=buffer) options = list(self.config.get('options')) options.append(filename) diff --git a/trove/common/limits.py b/trove/common/limits.py index 4549a7e..bb1fee0 100644 --- a/trove/common/limits.py +++ b/trove/common/limits.py @@ -23,9 +23,9 @@ import math import re import time +from http import client as http_client from oslo_serialization import jsonutils from oslo_utils import importutils -from six.moves import http_client import webob.dec import webob.exc diff --git a/trove/common/stream_codecs.py b/trove/common/stream_codecs.py index 2aff564..824273d 100644 --- a/trove/common/stream_codecs.py +++ b/trove/common/stream_codecs.py @@ -16,12 +16,12 @@ import abc import ast import csv +import configparser import io import re import sys import six -from six.moves import configparser import xmltodict import yaml diff --git a/trove/guestagent/datastore/mysql_common/service.py b/trove/guestagent/datastore/mysql_common/service.py index 2bba511..9f6e5d9 100644 --- a/trove/guestagent/datastore/mysql_common/service.py +++ b/trove/guestagent/datastore/mysql_common/service.py @@ -18,10 +18,10 @@ import re from oslo_log import log as logging from oslo_utils import encodeutils import six -from six.moves import urllib import sqlalchemy from sqlalchemy import exc from sqlalchemy.sql.expression import text +import urllib from trove.common import cfg from trove.common import exception diff --git a/trove/tests/fakes/swift.py b/trove/tests/fakes/swift.py index 7b8da07..79ee401 100644 --- a/trove/tests/fakes/swift.py +++ b/trove/tests/fakes/swift.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from http import client as http_client from hashlib import md5 from unittest.mock import MagicMock, patch import json @@ -24,7 +25,6 @@ import uuid from oslo_log import log as logging import six -from six.moves import http_client from swiftclient import client as swift diff --git a/trove/tests/unittests/api/common/test_extensions.py b/trove/tests/unittests/api/common/test_extensions.py index d034c77..a82326d 100644 --- a/trove/tests/unittests/api/common/test_extensions.py +++ b/trove/tests/unittests/api/common/test_extensions.py @@ -13,12 +13,11 @@ # under the License. +import configparser import os import pkg_resources from unittest import mock -from six.moves import configparser as config_parser - import trove from trove.common import extensions from trove.extensions.routes.mgmt import Mgmt @@ -76,7 +75,7 @@ class TestExtensionLoading(trove_testtools.TestCase): setup_path = "%s/setup.cfg" % trove_base # check if we are running as unit test without module installed if os.path.isfile(setup_path): - parser = config_parser.ConfigParser() + parser = configparser.ConfigParser() parser.read(setup_path) entry_points = parser.get( 'entry_points', extensions.ExtensionManager.EXT_NAMESPACE) diff --git a/trove/tests/unittests/api/common/test_limits.py b/trove/tests/unittests/api/common/test_limits.py index 7d8ee34..a6aee3f 100644 --- a/trove/tests/unittests/api/common/test_limits.py +++ b/trove/tests/unittests/api/common/test_limits.py @@ -18,10 +18,10 @@ Tests dealing with HTTP rate-limiting. """ +from http import client as http_client from unittest.mock import Mock, MagicMock, patch from oslo_serialization import jsonutils import six -from six.moves import http_client import webob from trove.common import limits