Remove six
Replace the following items with Python 3 style code. - six.string_types - six.integer_types - six.moves - six.PY2 Implements: blueprint six-removal Change-Id: I2a0624bd4b455c7e5a0617f1253efa05485dc673
This commit is contained in:
@@ -56,9 +56,6 @@ Here is an example showing how you can write a plugin called ``NewStrategy``:
|
|||||||
# filepath: thirdparty/new.py
|
# filepath: thirdparty/new.py
|
||||||
# import path: thirdparty.new
|
# import path: thirdparty.new
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from watcher._i18n import _
|
from watcher._i18n import _
|
||||||
from watcher.decision_engine.strategy.strategies import base
|
from watcher.decision_engine.strategy.strategies import base
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ Service mechanism provides ability to monitor Watcher services state.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
@@ -70,7 +68,7 @@ class Service(base.APIBase):
|
|||||||
service = objects.Service.get(pecan.request.context, id)
|
service = objects.Service.get(pecan.request.context, id)
|
||||||
last_heartbeat = (service.last_seen_up or service.updated_at or
|
last_heartbeat = (service.last_seen_up or service.updated_at or
|
||||||
service.created_at)
|
service.created_at)
|
||||||
if isinstance(last_heartbeat, six.string_types):
|
if isinstance(last_heartbeat, str):
|
||||||
# NOTE(russellb) If this service came in over rpc via
|
# NOTE(russellb) If this service came in over rpc via
|
||||||
# conductor, then the timestamp will be a string and needs to be
|
# conductor, then the timestamp will be a string and needs to be
|
||||||
# converted back to a datetime.
|
# converted back to a datetime.
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import six
|
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
@@ -132,7 +131,7 @@ class JsonType(wtypes.UserType):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# These are the json serializable native types
|
# These are the json serializable native types
|
||||||
return ' | '.join(map(str, (wtypes.text, six.integer_types, float,
|
return ' | '.join(map(str, (wtypes.text, int, float,
|
||||||
BooleanType, list, dict, None)))
|
BooleanType, list, dict, None)))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ SQLAlchemy models for watcher service
|
|||||||
|
|
||||||
from oslo_db.sqlalchemy import models
|
from oslo_db.sqlalchemy import models
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
from sqlalchemy import Boolean
|
from sqlalchemy import Boolean
|
||||||
from sqlalchemy import Column
|
from sqlalchemy import Column
|
||||||
from sqlalchemy import DateTime
|
from sqlalchemy import DateTime
|
||||||
@@ -33,7 +32,7 @@ from sqlalchemy import String
|
|||||||
from sqlalchemy import Text
|
from sqlalchemy import Text
|
||||||
from sqlalchemy.types import TypeDecorator, TEXT
|
from sqlalchemy.types import TypeDecorator, TEXT
|
||||||
from sqlalchemy import UniqueConstraint
|
from sqlalchemy import UniqueConstraint
|
||||||
|
import urllib.parse as urlparse
|
||||||
from watcher import conf
|
from watcher import conf
|
||||||
|
|
||||||
CONF = conf.CONF
|
CONF = conf.CONF
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import six
|
|
||||||
|
|
||||||
from watcher._i18n import _
|
from watcher._i18n import _
|
||||||
from watcher.common import exception
|
from watcher.common import exception
|
||||||
from watcher.decision_engine.model import element
|
from watcher.decision_engine.model import element
|
||||||
@@ -103,7 +101,7 @@ class HostMaintenance(base.HostMaintenanceBaseStrategy):
|
|||||||
|
|
||||||
def get_instance_state_str(self, instance):
|
def get_instance_state_str(self, instance):
|
||||||
"""Get instance state in string format"""
|
"""Get instance state in string format"""
|
||||||
if isinstance(instance.state, six.string_types):
|
if isinstance(instance.state, str):
|
||||||
return instance.state
|
return instance.state
|
||||||
elif isinstance(instance.state, element.InstanceState):
|
elif isinstance(instance.state, element.InstanceState):
|
||||||
return instance.state.value
|
return instance.state.value
|
||||||
@@ -116,7 +114,7 @@ class HostMaintenance(base.HostMaintenanceBaseStrategy):
|
|||||||
|
|
||||||
def get_node_status_str(self, node):
|
def get_node_status_str(self, node):
|
||||||
"""Get node status in string format"""
|
"""Get node status in string format"""
|
||||||
if isinstance(node.status, six.string_types):
|
if isinstance(node.status, str):
|
||||||
return node.status
|
return node.status
|
||||||
elif isinstance(node.status, element.ServiceState):
|
elif isinstance(node.status, element.ServiceState):
|
||||||
return node.status.value
|
return node.status.value
|
||||||
|
|||||||
@@ -14,14 +14,11 @@
|
|||||||
|
|
||||||
"""Tests for the Pecan API hooks."""
|
"""Tests for the Pecan API hooks."""
|
||||||
|
|
||||||
from unittest import mock
|
from http import client as http_client
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import oslo_messaging as messaging
|
import oslo_messaging as messaging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six
|
from unittest import mock
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from watcher.api.controllers import root
|
from watcher.api.controllers import root
|
||||||
from watcher.api import hooks
|
from watcher.api import hooks
|
||||||
from watcher.common import context
|
from watcher.common import context
|
||||||
@@ -144,7 +141,7 @@ class TestNoExceptionTracebackHook(base.FunctionalTest):
|
|||||||
# we don't care about this garbage.
|
# we don't care about this garbage.
|
||||||
expected_msg = ("Remote error: %s %s"
|
expected_msg = ("Remote error: %s %s"
|
||||||
% (test_exc_type, self.MSG_WITHOUT_TRACE) +
|
% (test_exc_type, self.MSG_WITHOUT_TRACE) +
|
||||||
("\n[u'" if six.PY2 else "\n['"))
|
"\n['")
|
||||||
actual_msg = jsonutils.loads(
|
actual_msg = jsonutils.loads(
|
||||||
response.json['error_message'])['faultstring']
|
response.json['error_message'])['faultstring']
|
||||||
self.assertEqual(expected_msg, actual_msg)
|
self.assertEqual(expected_msg, actual_msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user