Merge "Remove six"
This commit is contained in:
commit
dccfd35c1d
@ -39,8 +39,7 @@ Five ways to add a new trace point.
|
||||
def _traced_only_if_trace_private_true(self):
|
||||
pass
|
||||
|
||||
@six.add_metaclass(profiler.TracedMeta)
|
||||
class RpcManagerClass(object):
|
||||
class RpcManagerClass(object, metaclass=profiler.TracedMeta):
|
||||
__trace_args__ = {'name': 'rpc',
|
||||
'info': None,
|
||||
'hide_args': False,
|
||||
|
@ -15,7 +15,6 @@ pymongo===3.0.2
|
||||
redis===2.10.0
|
||||
reno==3.1.0
|
||||
requests===2.14.2
|
||||
six===1.10.0
|
||||
Sphinx===2.0.0
|
||||
stestr==2.0.0
|
||||
testtools===2.2.0
|
||||
|
@ -22,7 +22,6 @@ import uuid
|
||||
|
||||
from oslo_utils import secretutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
|
||||
def split(text, strip=True):
|
||||
@ -32,7 +31,7 @@ def split(text, strip=True):
|
||||
"""
|
||||
if isinstance(text, (tuple, list)):
|
||||
return text
|
||||
if not isinstance(text, six.string_types):
|
||||
if not isinstance(text, str):
|
||||
raise TypeError("Unknown how to split '%s': %s" % (text, type(text)))
|
||||
if strip:
|
||||
return [t.strip() for t in text.split(",") if t.strip()]
|
||||
@ -45,9 +44,9 @@ def binary_encode(text, encoding="utf-8"):
|
||||
|
||||
Does nothing if text not unicode string.
|
||||
"""
|
||||
if isinstance(text, six.binary_type):
|
||||
if isinstance(text, bytes):
|
||||
return text
|
||||
elif isinstance(text, six.text_type):
|
||||
elif isinstance(text, str):
|
||||
return text.encode(encoding)
|
||||
else:
|
||||
raise TypeError("Expected binary or string type")
|
||||
@ -58,9 +57,9 @@ def binary_decode(data, encoding="utf-8"):
|
||||
|
||||
Does nothing if data is already unicode string.
|
||||
"""
|
||||
if isinstance(data, six.binary_type):
|
||||
if isinstance(data, bytes):
|
||||
return data.decode(encoding)
|
||||
elif isinstance(data, six.text_type):
|
||||
elif isinstance(data, str):
|
||||
return data
|
||||
else:
|
||||
raise TypeError("Expected binary or string type")
|
||||
@ -154,7 +153,7 @@ def import_modules_from_package(package):
|
||||
def shorten_id(span_id):
|
||||
"""Convert from uuid4 to 64 bit id for OpenTracing"""
|
||||
int64_max = (1 << 64) - 1
|
||||
if isinstance(span_id, six.integer_types):
|
||||
if isinstance(span_id, int):
|
||||
return span_id & int64_max
|
||||
try:
|
||||
short_id = uuid.UUID(span_id).int & int64_max
|
||||
|
@ -19,7 +19,6 @@ import os
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import uuidutils
|
||||
import prettytable
|
||||
import six
|
||||
|
||||
from osprofiler.cmd import cliutils
|
||||
from osprofiler.drivers import base
|
||||
@ -188,7 +187,4 @@ class TraceCommands(BaseCommand):
|
||||
for trace in traces:
|
||||
row = [trace[field] for field in fields]
|
||||
pretty_table.add_row(row)
|
||||
if six.PY3:
|
||||
print(encodeutils.safe_encode(pretty_table.get_string()).decode())
|
||||
else:
|
||||
print(encodeutils.safe_encode(pretty_table.get_string()))
|
||||
print(encodeutils.safe_encode(pretty_table.get_string()).decode())
|
||||
|
@ -15,8 +15,7 @@
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from osprofiler import _utils
|
||||
|
||||
|
@ -13,8 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from urllib import parse as parser
|
||||
|
||||
from oslo_config import cfg
|
||||
import six.moves.urllib.parse as parser
|
||||
|
||||
from osprofiler.drivers import base
|
||||
from osprofiler import exc
|
||||
|
@ -16,10 +16,10 @@
|
||||
import collections
|
||||
import datetime
|
||||
import time
|
||||
from urllib import parse as parser
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
import six.moves.urllib.parse as parser
|
||||
|
||||
from osprofiler import _utils as utils
|
||||
from osprofiler.drivers import base
|
||||
|
@ -19,11 +19,11 @@ Classes to use VMware vRealize Log Insight as the trace data store.
|
||||
|
||||
import json
|
||||
import logging as log
|
||||
from urllib import parse as urlparse
|
||||
|
||||
import netaddr
|
||||
from oslo_concurrency.lockutils import synchronized
|
||||
import requests
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from osprofiler.drivers import base
|
||||
from osprofiler import exc
|
||||
|
@ -14,10 +14,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from urllib import parse as parser
|
||||
|
||||
from debtcollector import removals
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
import six.moves.urllib.parse as parser
|
||||
|
||||
from osprofiler.drivers import base
|
||||
from osprofiler import exc
|
||||
|
@ -364,7 +364,7 @@ def check_using_unicode(logical_line, filename):
|
||||
|
||||
if re.search(r"\bunicode\(", logical_line):
|
||||
yield (0, "N353 'unicode' function is absent in python3. Please "
|
||||
"use 'six.text_type' instead.")
|
||||
"use 'str' instead.")
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
|
@ -22,7 +22,6 @@ import threading
|
||||
|
||||
from oslo_utils import reflection
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from osprofiler import _utils as utils
|
||||
from osprofiler import notifier
|
||||
@ -161,7 +160,7 @@ def trace(name, info=None, hide_args=False, hide_result=True,
|
||||
except Exception as ex:
|
||||
stop_info = {
|
||||
"etype": reflection.get_class_name(ex),
|
||||
"message": six.text_type(ex)
|
||||
"message": str(ex)
|
||||
}
|
||||
raise
|
||||
else:
|
||||
@ -274,8 +273,7 @@ class TracedMeta(type):
|
||||
|
||||
Possible usage:
|
||||
|
||||
>>> @six.add_metaclass(profiler.TracedMeta)
|
||||
>>> class RpcManagerClass(object):
|
||||
>>> class RpcManagerClass(object, metaclass=profiler.TracedMeta):
|
||||
>>> __trace_args__ = {'name': 'rpc',
|
||||
>>> 'info': None,
|
||||
>>> 'hide_args': False,
|
||||
|
@ -13,13 +13,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import six
|
||||
|
||||
from osprofiler.cmd import shell
|
||||
from osprofiler import exc
|
||||
@ -43,7 +43,7 @@ class ShellTestCase(test.TestCase):
|
||||
cmd = "trace show --connection-string redis:// %s" % self.TRACE_ID
|
||||
return cmd if format_ is None else "%s --%s" % (cmd, format_)
|
||||
|
||||
@mock.patch("sys.stdout", six.StringIO())
|
||||
@mock.patch("sys.stdout", io.StringIO())
|
||||
@mock.patch("osprofiler.cmd.shell.OSProfilerShell")
|
||||
def test_shell_main(self, mock_shell):
|
||||
mock_shell.side_effect = exc.CommandError("some_message")
|
||||
@ -99,7 +99,7 @@ class ShellTestCase(test.TestCase):
|
||||
}
|
||||
return notifications
|
||||
|
||||
@mock.patch("sys.stdout", six.StringIO())
|
||||
@mock.patch("sys.stdout", io.StringIO())
|
||||
@mock.patch("osprofiler.drivers.redis_driver.Redis.get_report")
|
||||
def test_trace_show_in_json(self, mock_get):
|
||||
notifications = self._create_mock_notifications()
|
||||
@ -110,7 +110,7 @@ class ShellTestCase(test.TestCase):
|
||||
separators=(",", ": "),),
|
||||
sys.stdout.getvalue())
|
||||
|
||||
@mock.patch("sys.stdout", six.StringIO())
|
||||
@mock.patch("sys.stdout", io.StringIO())
|
||||
@mock.patch("osprofiler.drivers.redis_driver.Redis.get_report")
|
||||
def test_trace_show_in_html(self, mock_get):
|
||||
notifications = self._create_mock_notifications()
|
||||
@ -139,7 +139,7 @@ class ShellTestCase(test.TestCase):
|
||||
separators=(",", ": ")),
|
||||
sys.stdout.getvalue())
|
||||
|
||||
@mock.patch("sys.stdout", six.StringIO())
|
||||
@mock.patch("sys.stdout", io.StringIO())
|
||||
@mock.patch("osprofiler.drivers.redis_driver.Redis.get_report")
|
||||
def test_trace_show_write_to_file(self, mock_get):
|
||||
notifications = self._create_mock_notifications()
|
||||
|
@ -19,7 +19,6 @@ import datetime
|
||||
import re
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
|
||||
from osprofiler import profiler
|
||||
from osprofiler.tests import test
|
||||
@ -462,7 +461,6 @@ class TraceClsDecoratorTestCase(test.TestCase):
|
||||
# - and FakeTraceStatic.method4 in PY3
|
||||
"name":
|
||||
"osprofiler.tests.unit.test_profiler"
|
||||
".method4" if six.PY2 else
|
||||
"osprofiler.tests.unit.test_profiler.FakeTraceStatic"
|
||||
".method4",
|
||||
"args": str((25,)),
|
||||
@ -490,8 +488,7 @@ class TraceClsDecoratorTestCase(test.TestCase):
|
||||
self.assertFalse(mock_stop.called)
|
||||
|
||||
|
||||
@six.add_metaclass(profiler.TracedMeta)
|
||||
class FakeTraceWithMetaclassBase(object):
|
||||
class FakeTraceWithMetaclassBase(object, metaclass=profiler.TracedMeta):
|
||||
__trace_args__ = {"name": "rpc",
|
||||
"info": {"a": 10}}
|
||||
|
||||
@ -534,8 +531,8 @@ class TraceWithMetaclassTestCase(test.TestCase):
|
||||
|
||||
def test_no_name_exception(self):
|
||||
def define_class_with_no_name():
|
||||
@six.add_metaclass(profiler.TracedMeta)
|
||||
class FakeTraceWithMetaclassNoName(FakeTracedCls):
|
||||
class FakeTraceWithMetaclassNoName(FakeTracedCls,
|
||||
metaclass=profiler.TracedMeta):
|
||||
pass
|
||||
self.assertRaises(TypeError, define_class_with_no_name, 1)
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import webob.dec
|
||||
|
||||
from osprofiler import _utils as utils
|
||||
@ -98,7 +97,7 @@ class WsgiMiddleware(object):
|
||||
def _trace_is_valid(self, trace_info):
|
||||
if not isinstance(trace_info, dict):
|
||||
return False
|
||||
trace_keys = set(six.iterkeys(trace_info))
|
||||
trace_keys = set(trace_info.keys())
|
||||
if not all(k in trace_keys for k in _REQUIRED_KEYS):
|
||||
return False
|
||||
if trace_keys.difference(_REQUIRED_KEYS + _OPTIONAL_KEYS):
|
||||
|
@ -4,6 +4,5 @@ oslo.serialization>=2.18.0 # Apache-2.0
|
||||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
PrettyTable>=0.7.2 # BSD
|
||||
requests>=2.14.2 # Apache-2.0
|
||||
six>=1.10.0 # MIT
|
||||
WebOb>=1.7.1 # MIT
|
||||
importlib_metadata>=1.7.0;python_version<'3.8' # Apache-2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user