summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangzihao <wangzihao@yovole.com>2020-10-02 09:47:01 +0800
committerwangzihao <wangzihao@yovole.com>2020-10-09 09:19:18 +0800
commit0e62293a43ab9ec936759cc53ba21d318f1182cd (patch)
tree30e821f4df9f8e2ed2b6e256a3b4848031ce0f92
parent81352d08e90ff9949322374a4930d29ec102124c (diff)
downloadoslo-rootwrap-0e62293a43ab9ec936759cc53ba21d318f1182cd.tar.gz
Remove six
Replace the following items with Python 3 style code. - six.moves - six.StringIO Change-Id: Ie06dc3b6cc5a3d88defa4fdfd071ed2c9dcfb1d0
-rw-r--r--lower-constraints.txt1
-rw-r--r--oslo_rootwrap/cmd.py8
-rw-r--r--oslo_rootwrap/tests/test_functional.py4
-rw-r--r--oslo_rootwrap/tests/test_rootwrap.py8
-rw-r--r--oslo_rootwrap/wrapper.py5
-rw-r--r--requirements.txt1
6 files changed, 11 insertions, 16 deletions
diff --git a/lower-constraints.txt b/lower-constraints.txt
index e30bcbf..b432cda 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -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
diff --git a/oslo_rootwrap/cmd.py b/oslo_rootwrap/cmd.py
index 8e3ec99..b28a200 100644
--- a/oslo_rootwrap/cmd.py
+++ b/oslo_rootwrap/cmd.py
@@ -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)
diff --git a/oslo_rootwrap/tests/test_functional.py b/oslo_rootwrap/tests/test_functional.py
index da59b21..42c33c4 100644
--- a/oslo_rootwrap/tests/test_functional.py
+++ b/oslo_rootwrap/tests/test_functional.py
@@ -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))
diff --git a/oslo_rootwrap/tests/test_rootwrap.py b/oslo_rootwrap/tests/test_rootwrap.py
index d5a8c0a..e89f49d 100644
--- a/oslo_rootwrap/tests/test_rootwrap.py
+++ b/oslo_rootwrap/tests/test_rootwrap.py
@@ -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
diff --git a/oslo_rootwrap/wrapper.py b/oslo_rootwrap/wrapper.py
index 5a9bc4c..b0ce0f5 100644
--- a/oslo_rootwrap/wrapper.py
+++ b/oslo_rootwrap/wrapper.py
@@ -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(',')]
diff --git a/requirements.txt b/requirements.txt
index 1b9f30c..2683dd4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -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