Merge "Remove six in files under cinder/*"
This commit is contained in:
commit
2ce35aa94b
@ -26,7 +26,6 @@ from oslo_context import context
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from cinder import exception
|
||||
from cinder.i18n import _
|
||||
@ -105,7 +104,7 @@ class RequestContext(context.RequestContext):
|
||||
self.remote_address = remote_address
|
||||
if not timestamp:
|
||||
timestamp = timeutils.utcnow()
|
||||
elif isinstance(timestamp, six.string_types):
|
||||
elif isinstance(timestamp, str):
|
||||
timestamp = timeutils.parse_isotime(timestamp)
|
||||
self.timestamp = timestamp
|
||||
self.quota_class = quota_class
|
||||
|
@ -24,7 +24,6 @@ SHOULD include dedicated exception logging.
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_versionedobjects import exception as obj_exc
|
||||
import six
|
||||
import webob.exc
|
||||
from webob.util import status_generic_reasons
|
||||
from webob.util import status_reasons
|
||||
@ -85,7 +84,7 @@ class CinderException(Exception):
|
||||
# NOTE(tommylikehu): If this is a cinder exception it will
|
||||
# return the msg object, so we won't be preventing
|
||||
# translations.
|
||||
self.kwargs[k] = six.text_type(v)
|
||||
self.kwargs[k] = str(v)
|
||||
|
||||
if self._should_format():
|
||||
try:
|
||||
@ -100,7 +99,7 @@ class CinderException(Exception):
|
||||
# NOTE(tommylikehu): If this is a cinder exception it will
|
||||
# return the msg object, so we won't be preventing
|
||||
# translations.
|
||||
message = six.text_type(message)
|
||||
message = str(message)
|
||||
|
||||
# NOTE(luisg): We put the actual message in 'msg' so that we can access
|
||||
# it, because if we try to access the message via 'message' it will be
|
||||
|
@ -25,13 +25,14 @@ __all__ = [
|
||||
'get_notifier',
|
||||
]
|
||||
|
||||
import functools
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging as messaging
|
||||
from oslo_messaging.rpc import dispatcher
|
||||
from oslo_utils import importutils
|
||||
profiler = importutils.try_import('osprofiler.profiler')
|
||||
import six
|
||||
|
||||
import cinder.context
|
||||
import cinder.exception
|
||||
@ -177,7 +178,7 @@ def assert_min_rpc_version(min_ver, exc=None):
|
||||
exc = cinder.exception.ServiceTooOld
|
||||
|
||||
def decorator(f):
|
||||
@six.wraps(f)
|
||||
@functools.wraps(f)
|
||||
def _wrapper(self, *args, **kwargs):
|
||||
if not self.client.can_send_version(min_ver):
|
||||
msg = _('One of %(binary)s services is too old to accept '
|
||||
|
@ -25,7 +25,6 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
import paramiko
|
||||
import six
|
||||
|
||||
from cinder import exception
|
||||
from cinder.i18n import _
|
||||
@ -159,7 +158,7 @@ class SSHPool(pools.Pool):
|
||||
transport.set_keepalive(self.conn_timeout)
|
||||
return ssh
|
||||
except Exception as e:
|
||||
msg = _("Error connecting via ssh: %s") % six.text_type(e)
|
||||
msg = _("Error connecting via ssh: %s") % str(e)
|
||||
LOG.error(msg)
|
||||
raise paramiko.SSHException(msg)
|
||||
|
||||
|
@ -46,12 +46,10 @@ from oslo_concurrency import lockutils
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
import tenacity
|
||||
|
||||
from cinder import exception
|
||||
@ -309,7 +307,7 @@ def monkey_patch():
|
||||
if isinstance(module_data[key], pyclbr.Class):
|
||||
clz = importutils.import_class("%s.%s" % (module, key))
|
||||
# On Python 3, unbound methods are regular functions
|
||||
predicate = inspect.isfunction if six.PY3 else inspect.ismethod
|
||||
predicate = inspect.isfunction
|
||||
for method, func in inspect.getmembers(clz, predicate):
|
||||
setattr(
|
||||
clz, method,
|
||||
@ -415,8 +413,7 @@ def tempdir(**kwargs):
|
||||
try:
|
||||
shutil.rmtree(tmpdir)
|
||||
except OSError as e:
|
||||
LOG.debug('Could not remove tmpdir: %s',
|
||||
six.text_type(e))
|
||||
LOG.debug('Could not remove tmpdir: %s', str(e))
|
||||
|
||||
|
||||
def get_root_helper():
|
||||
@ -670,7 +667,7 @@ def retry(exceptions, interval=1, retries=3, backoff_rate=2,
|
||||
|
||||
def _decorator(f):
|
||||
|
||||
@six.wraps(f)
|
||||
@functools.wraps(f)
|
||||
def _wrapper(*args, **kwargs):
|
||||
r = tenacity.Retrying(
|
||||
sleep=tenacity.nap.sleep,
|
||||
@ -696,9 +693,6 @@ def convert_str(text):
|
||||
encode Unicode using encodeutils.safe_encode()
|
||||
* convert to Unicode on Python 3: decode bytes from UTF-8
|
||||
"""
|
||||
if six.PY2:
|
||||
return encodeutils.to_utf8(text)
|
||||
else:
|
||||
if isinstance(text, bytes):
|
||||
return text.decode('utf-8')
|
||||
else:
|
||||
@ -778,7 +772,7 @@ def trace(*dec_args, **dec_kwargs):
|
||||
logger.debug('==> %(func)s: call %(all_args)r',
|
||||
{'func': func_name,
|
||||
'all_args': strutils.mask_password(
|
||||
six.text_type(all_args))})
|
||||
str(all_args))})
|
||||
|
||||
start_time = time.time() * 1000
|
||||
try:
|
||||
@ -794,7 +788,7 @@ def trace(*dec_args, **dec_kwargs):
|
||||
|
||||
if isinstance(result, dict):
|
||||
mask_result = strutils.mask_dict_password(result)
|
||||
elif isinstance(result, six.string_types):
|
||||
elif isinstance(result, str):
|
||||
mask_result = strutils.mask_password(result)
|
||||
else:
|
||||
mask_result = result
|
||||
@ -822,8 +816,7 @@ class TraceWrapperMetaclass(type):
|
||||
decorated with the trace_method decorator.
|
||||
|
||||
To use the metaclass you define a class like so:
|
||||
@six.add_metaclass(utils.TraceWrapperMetaclass)
|
||||
class MyClass(object):
|
||||
class MyClass(object, metaclass=utils.TraceWrapperMetaclass):
|
||||
"""
|
||||
def __new__(meta, classname, bases, classDict):
|
||||
newClassDict = {}
|
||||
@ -877,7 +870,7 @@ def build_or_str(elements, str_format=None):
|
||||
if not elements:
|
||||
return ''
|
||||
|
||||
if not isinstance(elements, six.string_types):
|
||||
if not isinstance(elements, str):
|
||||
elements = _(' or ').join(elements)
|
||||
|
||||
if str_format:
|
||||
|
Loading…
Reference in New Issue
Block a user