Merge "Remove usage of six"
This commit is contained in:
commit
d45f12cc83
|
@ -167,7 +167,6 @@ Example
|
|||
|
||||
from osc_lib.api import auth
|
||||
from osc_lib import utils
|
||||
import six
|
||||
|
||||
from openstackclient import shell
|
||||
from openstackclient.tests import utils
|
||||
|
|
|
@ -52,7 +52,6 @@ requests-mock==1.2.0
|
|||
requests==2.14.2
|
||||
requestsexceptions==1.2.0
|
||||
simplejson==3.5.1
|
||||
six==1.10.0
|
||||
snowballstemmer==1.2.1
|
||||
Sphinx==2.0.0
|
||||
sphinxcontrib-websupport==1.0.1
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
import os
|
||||
import prettytable
|
||||
import six
|
||||
import textwrap
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
@ -122,7 +121,7 @@ def print_list(objs, fields, formatters={}, sortby_index=None):
|
|||
if data is None:
|
||||
data = '-'
|
||||
# '\r' would break the table, so remove it.
|
||||
data = six.text_type(data).replace("\r", "")
|
||||
data = str(data).replace("\r", "")
|
||||
row.append(data)
|
||||
pt.add_row(row)
|
||||
|
||||
|
@ -131,8 +130,7 @@ def print_list(objs, fields, formatters={}, sortby_index=None):
|
|||
else:
|
||||
result = encodeutils.safe_encode(pt.get_string())
|
||||
|
||||
if six.PY3:
|
||||
result = result.decode()
|
||||
result = result.decode()
|
||||
|
||||
print(result)
|
||||
|
||||
|
@ -147,10 +145,10 @@ def print_dict(d, dict_property="Property", dict_value="Value", wrap=0):
|
|||
if isinstance(v, (dict, list)):
|
||||
v = jsonutils.dumps(v)
|
||||
if wrap > 0:
|
||||
v = textwrap.fill(six.text_type(v), wrap)
|
||||
v = textwrap.fill(str(v), wrap)
|
||||
# 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 or '\r' in v):
|
||||
if v and isinstance(v, str) and (r'\n' in v or '\r' in v):
|
||||
# '\r' would break the table, so remove it.
|
||||
if '\r' in v:
|
||||
v = v.replace('\r', '')
|
||||
|
@ -166,8 +164,7 @@ def print_dict(d, dict_property="Property", dict_value="Value", wrap=0):
|
|||
|
||||
result = encodeutils.safe_encode(pt.get_string())
|
||||
|
||||
if six.PY3:
|
||||
result = result.decode()
|
||||
result = result.decode()
|
||||
|
||||
print(result)
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import logging
|
|||
import sys
|
||||
|
||||
from oslo_utils import encodeutils
|
||||
import six
|
||||
|
||||
import masakariclient
|
||||
from masakariclient import cliargs
|
||||
|
@ -199,7 +198,7 @@ def main(args=None):
|
|||
if '--debug' in args or '-d' in args:
|
||||
raise
|
||||
else:
|
||||
print(encodeutils.safe_encode(six.text_type(e)), sys.stderr)
|
||||
print(encodeutils.safe_encode(str(e), sys.stderr))
|
||||
return 1
|
||||
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ test_shell
|
|||
|
||||
Tests for `masakariclient` module.
|
||||
"""
|
||||
import io
|
||||
import logging
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
import sys
|
||||
import testtools
|
||||
|
||||
|
@ -61,7 +61,7 @@ class TestMasakariShell(base.TestCase):
|
|||
|
||||
def _shell(self, func, *args, **kwargs):
|
||||
orig_out = sys.stdout
|
||||
sys.stdout = six.StringIO()
|
||||
sys.stdout = io.StringIO()
|
||||
func(*args, **kwargs)
|
||||
output = sys.stdout.getvalue()
|
||||
sys.stdout.close()
|
||||
|
|
|
@ -21,7 +21,7 @@ Tests for `masakariclient` module.
|
|||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import six
|
||||
import io
|
||||
import sys
|
||||
|
||||
from openstack import exceptions as sdk_exc
|
||||
|
@ -231,7 +231,7 @@ class TestV1Shell(base.TestCase):
|
|||
args = mock.Mock()
|
||||
|
||||
original = sys.stdout
|
||||
sys.stdout = six.StringIO()
|
||||
sys.stdout = io.StringIO()
|
||||
ms.do_segment_delete(service, args)
|
||||
output = sys.stdout.getvalue()
|
||||
sys.stdout = original
|
||||
|
@ -364,7 +364,7 @@ class TestV1Shell(base.TestCase):
|
|||
args = mock.Mock()
|
||||
|
||||
original = sys.stdout
|
||||
sys.stdout = six.StringIO()
|
||||
sys.stdout = io.StringIO()
|
||||
ms.do_host_delete(service, args)
|
||||
output = sys.stdout.getvalue()
|
||||
sys.stdout = original
|
||||
|
|
Loading…
Reference in New Issue