Remove six

Replace the following items with Python 3 style code.

- six.moves
- six.StringIO

Change-Id: Ie06dc3b6cc5a3d88defa4fdfd071ed2c9dcfb1d0
This commit is contained in:
wangzihao 2020-10-02 09:47:01 +08:00
parent 81352d08e9
commit 0e62293a43
6 changed files with 11 additions and 16 deletions

View File

@ -28,7 +28,6 @@ PyYAML==3.13
reno==3.1.0
requests==2.14.2
requestsexceptions==1.2.0
six==1.10.0
smmap==0.9.0
snowballstemmer==1.2.1
stestr==2.0.0

View File

@ -29,7 +29,7 @@
Service packaging should deploy .filters files only on nodes where
they are needed, to avoid allowing more than is necessary.
"""
import configparser
import logging
import os
import sys
@ -37,8 +37,6 @@ import sys
from oslo_rootwrap import subprocess
from oslo_rootwrap import wrapper
from six import moves
try:
# This isn't available on all platforms (e.g. Windows).
import resource
@ -79,13 +77,13 @@ def main(run_daemon=False):
# Load configuration
try:
rawconfig = moves.configparser.RawConfigParser()
rawconfig = configparser.RawConfigParser()
rawconfig.read(configfile)
config = wrapper.RootwrapConfig(rawconfig)
except ValueError as exc:
msg = "Incorrect value in %s: %s" % (configfile, exc.args[0])
_exit_error(execname, msg, RC_BADCONFIG, log=False)
except moves.configparser.Error:
except configparser.Error:
_exit_error(execname, "Incorrect configuration file: %s" % configfile,
RC_BADCONFIG, log=False)

View File

@ -31,10 +31,10 @@ except ImportError:
eventlet = None
import fixtures
import six
import testtools
from testtools import content
from oslo_rootwrap import client
from oslo_rootwrap import cmd
from oslo_rootwrap import subprocess
@ -159,7 +159,7 @@ class RootwrapDaemonTest(_FunctionalBase, testtools.TestCase):
self.addCleanup(p.stop)
# Collect client logs
client_log = six.StringIO()
client_log = io.StringIO()
handler = logging.StreamHandler(client_log)
log_format = run_daemon.log_format.replace('+', ' ')
handler.setFormatter(logging.Formatter(log_format))

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import configparser
import logging
import logging.handlers
import os
@ -20,7 +21,6 @@ from unittest import mock
import uuid
import fixtures
from six import moves
import testtools
from oslo_rootwrap import cmd
@ -299,7 +299,7 @@ class RootwrapTestCase(testtools.TestCase):
mock_readlink.return_value = command + ';90bfb2 (deleted)'
m = mock.mock_open(read_data=command)
with mock.patch("six.moves.builtins.open", m, create=True):
with mock.patch("builtins.open", m, create=True):
mock_isfile.side_effect = fake_os_func
mock_exists.side_effect = fake_os_func
mock_access.side_effect = fake_os_func
@ -454,10 +454,10 @@ class RootwrapTestCase(testtools.TestCase):
self.assertTrue(filtermatch is self.filters[-1])
def test_RootwrapConfig(self):
raw = moves.configparser.RawConfigParser()
raw = configparser.RawConfigParser()
# Empty config should raise configparser.Error
self.assertRaises(moves.configparser.Error,
self.assertRaises(configparser.Error,
wrapper.RootwrapConfig, raw)
# Check default values

View File

@ -13,14 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import configparser
import logging
import logging.handlers
import os
import signal
import sys
from six import moves
from oslo_rootwrap import filters
from oslo_rootwrap import subprocess
@ -142,7 +141,7 @@ def load_filters(filters_path):
if not os.path.isfile(filterfilepath):
continue
kwargs = {"strict": False}
filterconfig = moves.configparser.RawConfigParser(**kwargs)
filterconfig = configparser.RawConfigParser(**kwargs)
filterconfig.read(filterfilepath)
for (name, value) in filterconfig.items("Filters"):
filterdefinition = [s.strip() for s in value.split(',')]

View File

@ -2,4 +2,3 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
six>=1.10.0 # MIT